Merge pull request #42 from TheBlueMatt/main
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 24 Sep 2021 21:25:35 +0000 (21:25 +0000)
committerGitHub <noreply@github.com>
Fri, 24 Sep 2021 21:25:35 +0000 (21:25 +0000)
Update to v0.0.101

41 files changed:
c-bindings-gen/src/blocks.rs
c-bindings-gen/src/main.rs
c-bindings-gen/src/types.rs
lightning-c-bindings/Cargo.toml
lightning-c-bindings/demo.c
lightning-c-bindings/demo.cpp
lightning-c-bindings/include/ldk_rust_types.h
lightning-c-bindings/include/lightning.h
lightning-c-bindings/include/lightningpp.hpp
lightning-c-bindings/src/c_types/derived.rs
lightning-c-bindings/src/c_types/mod.rs
lightning-c-bindings/src/lightning/chain/chaininterface.rs
lightning-c-bindings/src/lightning/chain/chainmonitor.rs
lightning-c-bindings/src/lightning/chain/channelmonitor.rs
lightning-c-bindings/src/lightning/chain/keysinterface.rs
lightning-c-bindings/src/lightning/chain/mod.rs
lightning-c-bindings/src/lightning/chain/transaction.rs
lightning-c-bindings/src/lightning/ln/chan_utils.rs
lightning-c-bindings/src/lightning/ln/channelmanager.rs
lightning-c-bindings/src/lightning/ln/features.rs
lightning-c-bindings/src/lightning/ln/mod.rs
lightning-c-bindings/src/lightning/ln/msgs.rs
lightning-c-bindings/src/lightning/ln/peer_handler.rs
lightning-c-bindings/src/lightning/ln/script.rs
lightning-c-bindings/src/lightning/ln/wire.rs [new file with mode: 0644]
lightning-c-bindings/src/lightning/mod.rs
lightning-c-bindings/src/lightning/routing/mod.rs
lightning-c-bindings/src/lightning/routing/network_graph.rs
lightning-c-bindings/src/lightning/routing/router.rs
lightning-c-bindings/src/lightning/util/config.rs
lightning-c-bindings/src/lightning/util/errors.rs
lightning-c-bindings/src/lightning/util/events.rs
lightning-c-bindings/src/lightning/util/logger.rs
lightning-c-bindings/src/lightning/util/message_signing.rs
lightning-c-bindings/src/lightning/util/mod.rs
lightning-c-bindings/src/lightning/util/ser.rs
lightning-c-bindings/src/lightning_background_processor.rs
lightning-c-bindings/src/lightning_invoice/constants.rs
lightning-c-bindings/src/lightning_invoice/mod.rs
lightning-c-bindings/src/lightning_invoice/utils.rs
lightning-c-bindings/src/lightning_persister.rs

index 2bbe298189cb54f54d2bfd695ce1be04fe77cf71..b214445584b6f6439413f8e5c7e277b5d4af6ad1 100644 (file)
@@ -200,7 +200,7 @@ pub fn write_result_block<W: std::io::Write>(w: &mut W, mangled_container: &str,
                writeln!(w, "#[no_mangle]").unwrap();
                writeln!(w, "/// Creates a new {} which has the same data as `orig`", mangled_container).unwrap();
                writeln!(w, "/// but with all dynamically-allocated buffers duplicated in new buffers.").unwrap();
-               writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{ orig.clone() }}", mangled_container, mangled_container, mangled_container).unwrap();
+               writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{ Clone::clone(&orig) }}", mangled_container, mangled_container, mangled_container).unwrap();
        }
 }
 
@@ -301,7 +301,7 @@ pub fn write_tuple_block<W: std::io::Write>(w: &mut W, mangled_container: &str,
                writeln!(w, "\tfn clone(&self) -> Self {{").unwrap();
                writeln!(w, "\t\tSelf {{").unwrap();
                for idx in 0..types.len() {
-                       writeln!(w, "\t\t\t{}: self.{}.clone(),", ('a' as u8 + idx as u8) as char, ('a' as u8 + idx as u8) as char).unwrap();
+                       writeln!(w, "\t\t\t{}: Clone::clone(&self.{}),", ('a' as u8 + idx as u8) as char, ('a' as u8 + idx as u8) as char).unwrap();
                }
                writeln!(w, "\t\t}}").unwrap();
                writeln!(w, "\t}}").unwrap();
@@ -309,7 +309,7 @@ pub fn write_tuple_block<W: std::io::Write>(w: &mut W, mangled_container: &str,
                writeln!(w, "#[no_mangle]").unwrap();
                writeln!(w, "/// Creates a new tuple which has the same data as `orig`").unwrap();
                writeln!(w, "/// but with all dynamically-allocated buffers duplicated in new buffers.").unwrap();
-               writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{ orig.clone() }}", mangled_container, mangled_container, mangled_container).unwrap();
+               writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{ Clone::clone(&orig) }}", mangled_container, mangled_container, mangled_container).unwrap();
        }
 
        writeln!(w, "/// Creates a new {} from the contained elements.", mangled_container).unwrap();
@@ -349,6 +349,9 @@ pub fn write_option_block<W: std::io::Write>(w: &mut W, mangled_container: &str,
        writeln!(w, "\t#[allow(unused)] pub(crate) fn is_some(&self) -> bool {{").unwrap();
        writeln!(w, "\t\tif let Self::Some(_) = self {{ true }} else {{ false }}").unwrap();
        writeln!(w, "\t}}").unwrap();
+       writeln!(w, "\t#[allow(unused)] pub(crate) fn is_none(&self) -> bool {{").unwrap();
+       writeln!(w, "\t\t!self.is_some()").unwrap();
+       writeln!(w, "\t}}").unwrap();
        writeln!(w, "\t#[allow(unused)] pub(crate) fn take(mut self) -> {} {{", inner_type).unwrap();
        writeln!(w, "\t\tif let Self::Some(v) = self {{ v }} else {{ unreachable!() }}").unwrap();
        writeln!(w, "\t}}").unwrap();
@@ -373,7 +376,7 @@ pub fn write_option_block<W: std::io::Write>(w: &mut W, mangled_container: &str,
                writeln!(w, "#[no_mangle]").unwrap();
                writeln!(w, "/// Creates a new {} which has the same data as `orig`", mangled_container).unwrap();
                writeln!(w, "/// but with all dynamically-allocated buffers duplicated in new buffers.").unwrap();
-               writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{ orig.clone() }}", mangled_container, mangled_container, mangled_container).unwrap();
+               writeln!(w, "pub extern \"C\" fn {}_clone(orig: &{}) -> {} {{ Clone::clone(&orig) }}", mangled_container, mangled_container, mangled_container).unwrap();
        }
 }
 
@@ -734,7 +737,7 @@ pub fn maybe_write_generics<W: std::io::Write>(w: &mut W, generics: &syn::Generi
                                        for bound in type_param.bounds.iter() {
                                                if let syn::TypeParamBound::Trait(trait_bound) = bound {
                                                        assert_simple_bound(&trait_bound);
-                                                       write!(w, "{}{}", if idx != 0 { ", " } else { "" }, gen_types.maybe_resolve_ident(&type_param.ident).unwrap()).unwrap();
+                                                       write!(w, "{}crate::{}", if idx != 0 { ", " } else { "" }, gen_types.maybe_resolve_ident(&type_param.ident).unwrap()).unwrap();
                                                        if printed_param {
                                                                unimplemented!("Can't print generic params that have multiple non-lifetime bounds");
                                                        }
index ce69294928af16714f3e7b645d34cbc2faa9f510..f56f30ff34e04c2d360822b1d2aa670d4e0b083a 100644 (file)
@@ -33,7 +33,7 @@ mod blocks;
 use types::*;
 use blocks::*;
 
-const DEFAULT_IMPORTS: &'static str = "\nuse std::str::FromStr;\nuse std::ffi::c_void;\nuse bitcoin::hashes::Hash;\nuse crate::c_types::*;\n";
+const DEFAULT_IMPORTS: &'static str = "\nuse std::str::FromStr;\nuse std::ffi::c_void;\nuse core::convert::Infallible;\nuse bitcoin::hashes::Hash;\nuse crate::c_types::*;\n";
 
 // *************************************
 // *** Manually-expanded conversions ***
@@ -163,7 +163,6 @@ fn write_trait_impl_field_assign<W: std::io::Write>(w: &mut W, trait_path: &str,
 
 /// Write out the impl block for a defined trait struct which has a supertrait
 fn do_write_impl_trait<W: std::io::Write>(w: &mut W, trait_path: &str, _trait_name: &syn::Ident, for_obj: &str) {
-eprintln!("{}", trait_path);
        match trait_path {
                "lightning::util::ser::Writeable" => {
                        writeln!(w, "impl {} for {} {{", trait_path, for_obj).unwrap();
@@ -176,6 +175,11 @@ eprintln!("{}", trait_path);
        }
 }
 
+/// Returns true if an instance of the given type must never exist
+fn is_type_unconstructable(path: &str) -> bool {
+       path == "core::convert::Infallible" || path == "crate::c_types::NotConstructable"
+}
+
 // *******************************
 // *** Per-Type Printing Logic ***
 // *******************************
@@ -213,6 +217,18 @@ macro_rules! walk_supertraits { ($t: expr, $types: expr, ($( $($pat: pat)|* => $
        }
 } } }
 
+macro_rules! get_module_type_resolver {
+       ($module: expr, $crate_libs: expr, $crate_types: expr) => { {
+               let module: &str = &$module;
+               let mut module_iter = module.rsplitn(2, "::");
+               module_iter.next().unwrap();
+               let module = module_iter.next().unwrap();
+               let imports = ImportResolver::new(module.splitn(2, "::").next().unwrap(), &$crate_types.lib_ast.dependencies,
+                               module, &$crate_types.lib_ast.modules.get(module).unwrap().items);
+               TypeResolver::new(module, imports, $crate_types)
+       } }
+}
+
 /// Prints a C-mapped trait object containing a void pointer and a jump table for each function in
 /// the original trait.
 /// Implements the native Rust trait and relevant parent traits for the new C-mapped trait.
@@ -230,6 +246,22 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
        writeln_docs(w, &t.attrs, "");
 
        let mut gen_types = GenericTypes::new(None);
+
+       // Add functions which may be required for supertrait implementations.
+       // Due to borrow checker limitations, we only support one in-crate supertrait here.
+       let supertrait_name;
+       let supertrait_resolver;
+       walk_supertraits!(t, Some(&types), (
+               (s, _i) => {
+                       if let Some(supertrait) = types.crate_types.traits.get(s) {
+                               supertrait_name = s.to_string();
+                               supertrait_resolver = get_module_type_resolver!(supertrait_name, types.crate_libs, types.crate_types);
+                               gen_types.learn_associated_types(&supertrait, &supertrait_resolver);
+                               break;
+                       }
+               }
+       ) );
+
        assert!(gen_types.learn_generics(&t.generics, types));
        gen_types.learn_associated_types(&t, types);
 
@@ -330,6 +362,13 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                                Some(format!("\t/**\n\t * {}\n\t * {}\n\t */\n", hash_docs_a, hash_docs_b))));
                },
                ("Send", _) => {}, ("Sync", _) => {},
+               ("std::fmt::Debug", _)|("core::fmt::Debug", _) => {
+                       let debug_docs = "Return a human-readable \"debug\" string describing this object";
+                       writeln!(w, "\t/// {}", debug_docs).unwrap();
+                       writeln!(w, "\tpub debug_str: extern \"C\" fn (this_arg: *const c_void) -> crate::c_types::Str,").unwrap();
+                       generated_fields.push(("debug_str".to_owned(), None,
+                               Some(format!("\t/**\n\t * {}\n\t */\n", debug_docs))));
+               },
                (s, i) => {
                        // TODO: Both of the below should expose supertrait methods in C++, but doing so is
                        // nontrivial.
@@ -368,8 +407,11 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                                                }
                                                let mut meth_gen_types = gen_types.push_ctx();
                                                assert!(meth_gen_types.learn_generics(&m.sig.generics, $type_resolver));
+                                               // Note that we do *not* use the method generics when printing "native"
+                                               // rust parts - if the method is generic, we need to print a generic
+                                               // method.
                                                write!(w, "\tfn {}", m.sig.ident).unwrap();
-                                               $type_resolver.write_rust_generic_param(w, Some(&meth_gen_types), m.sig.generics.params.iter());
+                                               $type_resolver.write_rust_generic_param(w, Some(&gen_types), m.sig.generics.params.iter());
                                                write!(w, "(").unwrap();
                                                for inp in m.sig.inputs.iter() {
                                                        match inp {
@@ -397,7 +439,7 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                                                                                }
                                                                                _ => unimplemented!(),
                                                                        }
-                                                                       $type_resolver.write_rust_type(w, Some(&meth_gen_types), &*arg.ty);
+                                                                       $type_resolver.write_rust_type(w, Some(&gen_types), &*arg.ty);
                                                                }
                                                        }
                                                }
@@ -405,7 +447,7 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                                                match &m.sig.output {
                                                        syn::ReturnType::Type(_, rtype) => {
                                                                write!(w, " -> ").unwrap();
-                                                               $type_resolver.write_rust_type(w, Some(&meth_gen_types), &*rtype)
+                                                               $type_resolver.write_rust_type(w, Some(&gen_types), &*rtype)
                                                        },
                                                        _ => {},
                                                }
@@ -495,14 +537,16 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                        writeln!(w, "\t\t{}_clone(self)", trait_name).unwrap();
                        writeln!(w, "\t}}\n}}").unwrap();
                },
+               ("std::fmt::Debug", _)|("core::fmt::Debug", _) => {
+                       writeln!(w, "impl core::fmt::Debug for {} {{", 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.debug_str)(self.this_arg).into_str())").unwrap();
+                       writeln!(w, "\t}}").unwrap();
+                       writeln!(w, "}}").unwrap();
+               },
                (s, i) => {
                        if let Some(supertrait) = types.crate_types.traits.get(s) {
-                               let mut module_iter = s.rsplitn(2, "::");
-                               module_iter.next().unwrap();
-                               let supertrait_module = module_iter.next().unwrap();
-                               let imports = ImportResolver::new(supertrait_module.splitn(2, "::").next().unwrap(), &types.crate_types.lib_ast.dependencies,
-                                       supertrait_module, &types.crate_types.lib_ast.modules.get(supertrait_module).unwrap().items);
-                               let resolver = TypeResolver::new(&supertrait_module, imports, types.crate_types);
+                               let resolver = get_module_type_resolver!(s, types.crate_libs, types.crate_types);
                                writeln!(w, "impl {} for {} {{", s, trait_name).unwrap();
                                impl_trait_for_c!(supertrait, format!(".{}", i), &resolver);
                                writeln!(w, "}}").unwrap();
@@ -602,7 +646,7 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
                let mut self_path_segs = syn::punctuated::Punctuated::new();
                self_path_segs.push(s.ident.clone().into());
                let self_path = syn::Path { leading_colon: None, segments: self_path_segs};
-               let mut gen_types = GenericTypes::new(Some((types.resolve_path(&self_path, None), &self_path)));
+               let mut gen_types = GenericTypes::new(Some(types.resolve_path(&self_path, None)));
                assert!(gen_types.learn_generics(&s.generics, types));
 
                let mut all_fields_settable = true;
@@ -619,20 +663,19 @@ fn writeln_struct<'a, 'b, W: std::io::Write>(w: &mut W, s: &'a syn::ItemStruct,
                                }
 
                                if let Some(ident) = &field.ident {
-                                       let ref_type = syn::Type::Reference(syn::TypeReference {
-                                               and_token: syn::Token!(&)(Span::call_site()), lifetime: None, mutability: None,
-                                               elem: Box::new(field.ty.clone()) });
-                                       if types.understood_c_type(&ref_type, Some(&gen_types)) {
-                                               writeln_arg_docs(w, &field.attrs, "", types, Some(&gen_types), vec![].drain(..), Some(&ref_type));
-                                               write!(w, "#[no_mangle]\npub extern \"C\" fn {}_get_{}(this_ptr: &{}) -> ", struct_name, ident, struct_name).unwrap();
-                                               types.write_c_type(w, &ref_type, Some(&gen_types), true);
-                                               write!(w, " {{\n\tlet mut inner_val = &mut this_ptr.get_native_mut_ref().{};\n\t", ident).unwrap();
-                                               let local_var = types.write_to_c_conversion_new_var(w, &format_ident!("inner_val"), &ref_type, Some(&gen_types), true);
-                                               if local_var { write!(w, "\n\t").unwrap(); }
-                                               types.write_to_c_conversion_inline_prefix(w, &ref_type, Some(&gen_types), true);
-                                               write!(w, "inner_val").unwrap();
-                                               types.write_to_c_conversion_inline_suffix(w, &ref_type, Some(&gen_types), true);
-                                               writeln!(w, "\n}}").unwrap();
+                                       if let Some(ref_type) = types.create_ownable_reference(&field.ty, Some(&gen_types)) {
+                                               if types.understood_c_type(&ref_type, Some(&gen_types)) {
+                                                       writeln_arg_docs(w, &field.attrs, "", types, Some(&gen_types), vec![].drain(..), Some(&ref_type));
+                                                       write!(w, "#[no_mangle]\npub extern \"C\" fn {}_get_{}(this_ptr: &{}) -> ", struct_name, ident, struct_name).unwrap();
+                                                       types.write_c_type(w, &ref_type, Some(&gen_types), true);
+                                                       write!(w, " {{\n\tlet mut inner_val = &mut this_ptr.get_native_mut_ref().{};\n\t", ident).unwrap();
+                                                       let local_var = types.write_to_c_conversion_new_var(w, &format_ident!("inner_val"), &ref_type, Some(&gen_types), true);
+                                                       if local_var { write!(w, "\n\t").unwrap(); }
+                                                       types.write_to_c_conversion_inline_prefix(w, &ref_type, Some(&gen_types), true);
+                                                       write!(w, "inner_val").unwrap();
+                                                       types.write_to_c_conversion_inline_suffix(w, &ref_type, Some(&gen_types), true);
+                                                       writeln!(w, "\n}}").unwrap();
+                                               }
                                        }
 
                                        if types.understood_c_type(&field.ty, Some(&gen_types)) {
@@ -726,7 +769,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                if p.qself.is_some() { unimplemented!(); }
                if let Some(ident) = single_ident_generic_path_to_ident(&p.path) {
                        if let Some(resolved_path) = types.maybe_resolve_non_ignored_ident(&ident) {
-                               let mut gen_types = GenericTypes::new(Some((resolved_path.clone(), &p.path)));
+                               let mut gen_types = GenericTypes::new(Some(resolved_path.clone()));
                                if !gen_types.learn_generics(&i.generics, types) {
                                        eprintln!("Not implementing anything for impl {} due to not understood generics", ident);
                                        return;
@@ -738,11 +781,26 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                        if types.understood_c_path(&trait_path.1) {
                                                let full_trait_path = types.resolve_path(&trait_path.1, None);
                                                let trait_obj = *types.crate_types.traits.get(&full_trait_path).unwrap();
+
+                                               let supertrait_name;
+                                               let supertrait_resolver;
+                                               walk_supertraits!(trait_obj, Some(&types), (
+                                                       (s, _i) => {
+                                                               if let Some(supertrait) = types.crate_types.traits.get(s) {
+                                                                       supertrait_name = s.to_string();
+                                                                       supertrait_resolver = get_module_type_resolver!(supertrait_name, types.crate_libs, types.crate_types);
+                                                                       gen_types.learn_associated_types(&supertrait, &supertrait_resolver);
+                                                                       break;
+                                                               }
+                                                       }
+                                               ) );
                                                // We learn the associated types maping from the original trait object.
                                                // That's great, except that they are unresolved idents, so if we learn
                                                // mappings from a trai defined in a different file, we may mis-resolve or
-                                               // fail to resolve the mapped types.
-                                               gen_types.learn_associated_types(trait_obj, types);
+                                               // fail to resolve the mapped types. Thus, we have to construct a new
+                                               // resolver for the module that the trait was defined in here first.
+                                               let trait_resolver = get_module_type_resolver!(full_trait_path, types.crate_libs, types.crate_types);
+                                               gen_types.learn_associated_types(trait_obj, &trait_resolver);
                                                let mut impl_associated_types = HashMap::new();
                                                for item in i.items.iter() {
                                                        match item {
@@ -768,14 +826,27 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                // From<> implementation which does all the work to ensure free is handled
                                                // properly. This way we can call this method from deep in the
                                                // type-conversion logic without actually knowing the concrete native type.
+                                               if !resolved_path.starts_with(types.module_path) {
+                                                       writeln!(w, "use {} as native{};", resolved_path, ident).unwrap();
+                                               }
                                                writeln!(w, "impl From<native{}> for crate::{} {{", ident, full_trait_path).unwrap();
                                                writeln!(w, "\tfn from(obj: native{}) -> Self {{", ident).unwrap();
-                                               writeln!(w, "\t\tlet mut rust_obj = {} {{ inner: ObjOps::heap_alloc(obj), is_owned: true }};", ident).unwrap();
-                                               writeln!(w, "\t\tlet mut ret = {}_as_{}(&rust_obj);", ident, trait_obj.ident).unwrap();
-                                               writeln!(w, "\t\t// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn").unwrap();
-                                               writeln!(w, "\t\trust_obj.inner = std::ptr::null_mut();").unwrap();
-                                               writeln!(w, "\t\tret.free = Some({}_free_void);", ident).unwrap();
-                                               writeln!(w, "\t\tret\n\t}}\n}}").unwrap();
+                                               if is_type_unconstructable(&resolved_path) {
+                                                       writeln!(w, "\t\tunreachable!();").unwrap();
+                                               } else {
+                                                       writeln!(w, "\t\tlet mut rust_obj = {} {{ inner: ObjOps::heap_alloc(obj), is_owned: true }};", ident).unwrap();
+                                                       writeln!(w, "\t\tlet mut ret = {}_as_{}(&rust_obj);", ident, trait_obj.ident).unwrap();
+                                                       writeln!(w, "\t\t// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn").unwrap();
+                                                       writeln!(w, "\t\trust_obj.inner = std::ptr::null_mut();").unwrap();
+                                                       writeln!(w, "\t\tret.free = Some({}_free_void);", ident).unwrap();
+                                                       writeln!(w, "\t\tret").unwrap();
+                                               }
+                                               writeln!(w, "\t}}\n}}").unwrap();
+                                               if is_type_unconstructable(&resolved_path) {
+                                                       // We don't bother with Struct_as_Trait conversion for types which must
+                                                       // never be instantiated, so just return early.
+                                                       return;
+                                               }
 
                                                writeln!(w, "/// Constructs a new {} which calls the relevant methods on this_arg.", trait_obj.ident).unwrap();
                                                writeln!(w, "/// This copies the `inner` pointer in this_arg and thus the returned {} must be freed before this_arg is", trait_obj.ident).unwrap();
@@ -829,6 +900,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                        },
                                                        ("Sync", _) => {}, ("Send", _) => {},
                                                        ("std::marker::Sync", _) => {}, ("std::marker::Send", _) => {},
+                                                       ("core::fmt::Debug", _) => {},
                                                        (s, t) => {
                                                                if let Some(supertrait_obj) = types.crate_types.traits.get(s) {
                                                                        writeln!(w, "\t\t{}: crate::{} {{", t, s).unwrap();
@@ -851,7 +923,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                writeln!(w, "\t}}\n}}\n").unwrap();
 
                                                macro_rules! impl_meth {
-                                                       ($m: expr, $trait_path: expr, $trait: expr, $indent: expr) => {
+                                                       ($m: expr, $trait_meth: expr, $trait_path: expr, $trait: expr, $indent: expr) => {
                                                                let trait_method = $trait.items.iter().filter_map(|item| {
                                                                        if let syn::TraitItem::Method(t_m) = item { Some(t_m) } else { None }
                                                                }).find(|trait_meth| trait_meth.sig.ident == $m.sig.ident).unwrap();
@@ -867,39 +939,62 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                                write!(w, "extern \"C\" fn {}_{}_{}(", ident, $trait.ident, $m.sig.ident).unwrap();
                                                                let mut meth_gen_types = gen_types.push_ctx();
                                                                assert!(meth_gen_types.learn_generics(&$m.sig.generics, types));
-                                                               write_method_params(w, &$m.sig, "c_void", types, Some(&meth_gen_types), true, true);
-                                                               write!(w, " {{\n\t").unwrap();
-                                                               write_method_var_decl_body(w, &$m.sig, "", types, Some(&meth_gen_types), false);
-                                                               let mut takes_self = false;
+                                                               let mut uncallable_function = false;
                                                                for inp in $m.sig.inputs.iter() {
-                                                                       if let syn::FnArg::Receiver(_) = inp {
-                                                                               takes_self = true;
+                                                                       match inp {
+                                                                               syn::FnArg::Typed(arg) => {
+                                                                                       if types.skip_arg(&*arg.ty, Some(&meth_gen_types)) { continue; }
+                                                                                       let mut c_type = Vec::new();
+                                                                                       types.write_c_type(&mut c_type, &*arg.ty, Some(&meth_gen_types), false);
+                                                                                       if is_type_unconstructable(&String::from_utf8(c_type).unwrap()) {
+                                                                                               uncallable_function = true;
+                                                                                       }
+                                                                               }
+                                                                               _ => {}
                                                                        }
                                                                }
-
-                                                               let mut t_gen_args = String::new();
-                                                               for (idx, _) in $trait.generics.params.iter().enumerate() {
-                                                                       if idx != 0 { t_gen_args += ", " };
-                                                                       t_gen_args += "_"
-                                                               }
-                                                               if takes_self {
-                                                                       write!(w, "<native{} as {}<{}>>::{}(unsafe {{ &mut *(this_arg as *mut native{}) }}, ", ident, $trait_path, t_gen_args, $m.sig.ident, ident).unwrap();
+                                                               if uncallable_function {
+                                                                       let mut trait_resolver = get_module_type_resolver!(full_trait_path, types.crate_libs, types.crate_types);
+                                                                       write_method_params(w, &$trait_meth.sig, "c_void", &mut trait_resolver, Some(&meth_gen_types), true, true);
                                                                } else {
-                                                                       write!(w, "<native{} as {}<{}>>::{}(", ident, $trait_path, t_gen_args, $m.sig.ident).unwrap();
+                                                                       write_method_params(w, &$m.sig, "c_void", types, Some(&meth_gen_types), true, true);
                                                                }
+                                                               write!(w, " {{\n\t").unwrap();
+                                                               if uncallable_function {
+                                                                       write!(w, "unreachable!();").unwrap();
+                                                               } else {
+                                                                       write_method_var_decl_body(w, &$m.sig, "", types, Some(&meth_gen_types), false);
+                                                                       let mut takes_self = false;
+                                                                       for inp in $m.sig.inputs.iter() {
+                                                                               if let syn::FnArg::Receiver(_) = inp {
+                                                                                       takes_self = true;
+                                                                               }
+                                                                       }
+
+                                                                       let mut t_gen_args = String::new();
+                                                                       for (idx, _) in $trait.generics.params.iter().enumerate() {
+                                                                               if idx != 0 { t_gen_args += ", " };
+                                                                               t_gen_args += "_"
+                                                                       }
+                                                                       if takes_self {
+                                                                               write!(w, "<native{} as {}<{}>>::{}(unsafe {{ &mut *(this_arg as *mut native{}) }}, ", ident, $trait_path, t_gen_args, $m.sig.ident, ident).unwrap();
+                                                                       } else {
+                                                                               write!(w, "<native{} as {}<{}>>::{}(", ident, $trait_path, t_gen_args, $m.sig.ident).unwrap();
+                                                                       }
 
-                                                               let mut real_type = "".to_string();
-                                                               match &$m.sig.output {
-                                                                       syn::ReturnType::Type(_, rtype) => {
-                                                                               if let Some(mut remaining_path) = first_seg_self(&*rtype) {
-                                                                                       if let Some(associated_seg) = get_single_remaining_path_seg(&mut remaining_path) {
-                                                                                               real_type = format!("{}", impl_associated_types.get(associated_seg).unwrap());
+                                                                       let mut real_type = "".to_string();
+                                                                       match &$m.sig.output {
+                                                                               syn::ReturnType::Type(_, rtype) => {
+                                                                                       if let Some(mut remaining_path) = first_seg_self(&*rtype) {
+                                                                                               if let Some(associated_seg) = get_single_remaining_path_seg(&mut remaining_path) {
+                                                                                                       real_type = format!("{}", impl_associated_types.get(associated_seg).unwrap());
+                                                                                               }
                                                                                        }
-                                                                               }
-                                                                       },
-                                                                       _ => {},
+                                                                               },
+                                                                               _ => {},
+                                                                       }
+                                                                       write_method_call_params(w, &$m.sig, "", types, Some(&meth_gen_types), &real_type, false);
                                                                }
-                                                               write_method_call_params(w, &$m.sig, "", types, Some(&meth_gen_types), &real_type, false);
                                                                write!(w, "\n}}\n").unwrap();
                                                                if let syn::ReturnType::Type(_, rtype) = &$m.sig.output {
                                                                        if let syn::Type::Reference(r) = &**rtype {
@@ -918,10 +1013,21 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                        }
                                                }
 
-                                               for item in i.items.iter() {
+                                               'impl_item_loop: for item in i.items.iter() {
                                                        match item {
                                                                syn::ImplItem::Method(m) => {
-                                                                       impl_meth!(m, full_trait_path, trait_obj, "");
+                                                                       for trait_item in trait_obj.items.iter() {
+                                                                               match trait_item {
+                                                                                       syn::TraitItem::Method(meth) => {
+                                                                                               if meth.sig.ident == m.sig.ident {
+                                                                                                       impl_meth!(m, meth, full_trait_path, trait_obj, "");
+                                                                                                       continue 'impl_item_loop;
+                                                                                               }
+                                                                                       },
+                                                                                       _ => {},
+                                                                               }
+                                                                       }
+                                                                       unreachable!();
                                                                },
                                                                syn::ImplItem::Type(_) => {},
                                                                _ => unimplemented!(),
@@ -943,7 +1049,14 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                        writeln!(w, "}}").unwrap();
                                                }
                                                write!(w, "\n").unwrap();
-                                       } else if path_matches_nongeneric(&trait_path.1, &["From"]) {
+                                               return;
+                                       }
+                                       if is_type_unconstructable(&resolved_path) {
+                                               // Don't bother exposing trait implementations for objects which cannot be
+                                               // instantiated.
+                                               return;
+                                       }
+                                       if path_matches_nongeneric(&trait_path.1, &["From"]) {
                                        } else if path_matches_nongeneric(&trait_path.1, &["Default"]) {
                                                writeln!(w, "/// Creates a \"default\" {}. See struct and individual field documentaiton for details on which values are used.", ident).unwrap();
                                                write!(w, "#[must_use]\n#[no_mangle]\npub extern \"C\" fn {}_default() -> {} {{\n", ident, ident).unwrap();
@@ -1791,6 +1904,9 @@ fn main() {
        writeln!(header_file, "#endif").unwrap();
        writeln!(cpp_header_file, "#include <string.h>\nnamespace LDK {{").unwrap();
 
+       // Write a few manually-defined types into the C++ header file
+       write_cpp_wrapper(&mut cpp_header_file, "Str", true, None);
+
        // First parse the full crate's ASTs, caching them so that we can hold references to the AST
        // objects in other datastructures:
        let mut lib_src = String::new();
index d17148fe25d1378d2ecec2d9c1f2a4f10394f8e5..8063532e454b169d89dbb0be8b6c2e0283fd8d1c 100644 (file)
@@ -173,13 +173,13 @@ pub fn is_enum_opaque(e: &syn::ItemEnum) -> bool {
 /// concrete C container struct, etc).
 #[must_use]
 pub struct GenericTypes<'a, 'b> {
-       self_ty: Option<(String, &'a syn::Path)>,
+       self_ty: Option<String>,
        parent: Option<&'b GenericTypes<'b, 'b>>,
-       typed_generics: HashMap<&'a syn::Ident, (String, Option<&'a syn::Path>)>,
+       typed_generics: HashMap<&'a syn::Ident, String>,
        default_generics: HashMap<&'a syn::Ident, (syn::Type, syn::Type)>,
 }
 impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
-       pub fn new(self_ty: Option<(String, &'a syn::Path)>) -> Self {
+       pub fn new(self_ty: Option<String>) -> Self {
                Self { self_ty, parent: None, typed_generics: HashMap::new(), default_generics: HashMap::new(), }
        }
 
@@ -192,6 +192,7 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
 
        /// Learn the generics in generics in the current context, given a TypeResolver.
        pub fn learn_generics<'b, 'c>(&mut self, generics: &'a syn::Generics, types: &'b TypeResolver<'a, 'c>) -> bool {
+               let mut new_typed_generics = HashMap::new();
                // First learn simple generics...
                for generic in generics.params.iter() {
                        match generic {
@@ -205,14 +206,13 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                                                        if path_matches_nongeneric(&trait_bound.path, &["core", "clone", "Clone"]) { continue; }
 
                                                        assert_simple_bound(&trait_bound);
-                                                       if let Some(mut path) = types.maybe_resolve_path(&trait_bound.path, None) {
+                                                       if let Some(path) = types.maybe_resolve_path(&trait_bound.path, None) {
                                                                if types.skip_path(&path) { continue; }
                                                                if path == "Sized" { continue; }
                                                                if non_lifetimes_processed { return false; }
                                                                non_lifetimes_processed = true;
-                                                               let new_ident = if path != "std::ops::Deref" && path != "core::ops::Deref" {
-                                                                       path = "crate::".to_string() + &path;
-                                                                       Some(&trait_bound.path)
+                                                               if path != "std::ops::Deref" && path != "core::ops::Deref" {
+                                                                       new_typed_generics.insert(&type_param.ident, Some(path));
                                                                } else if trait_bound.path.segments.len() == 1 {
                                                                        // If we're templated on Deref<Target = ConcreteThing>, store
                                                                        // the reference type in `default_generics` which handles full
@@ -231,11 +231,11 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                                                                                                _ => unimplemented!(),
                                                                                        }
                                                                                }
-                                                                               None
-                                                                       } else { None }
-                                                               } else { None };
-                                                               self.typed_generics.insert(&type_param.ident, (path, new_ident));
-                                                       } else { return false; }
+                                                                       } else {
+                                                                               new_typed_generics.insert(&type_param.ident, None);
+                                                                       }
+                                                               }
+                                                       }
                                                }
                                        }
                                        if let Some(default) = type_param.default.as_ref() {
@@ -254,9 +254,9 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                                                if p.qself.is_some() { return false; }
                                                if p.path.leading_colon.is_some() { return false; }
                                                let mut p_iter = p.path.segments.iter();
-                                               if let Some(gen) = self.typed_generics.get_mut(&p_iter.next().unwrap().ident) {
-                                                       if gen.0 != "std::ops::Deref" && gen.0 != "core::ops::Deref" { return false; }
-                                                       if &format!("{}", p_iter.next().unwrap().ident) != "Target" { return false; }
+                                               if let Some(gen) = new_typed_generics.get_mut(&p_iter.next().unwrap().ident) {
+                                                       if gen.is_some() { return false; }
+                                                       if &format!("{}", p_iter.next().unwrap().ident) != "Target" {return false; }
 
                                                        let mut non_lifetimes_processed = false;
                                                        for bound in t.bounds.iter() {
@@ -267,8 +267,7 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                                                                        if non_lifetimes_processed { return false; }
                                                                        non_lifetimes_processed = true;
                                                                        assert_simple_bound(&trait_bound);
-                                                                       *gen = ("crate::".to_string() + &types.resolve_path(&trait_bound.path, None),
-                                                                               Some(&trait_bound.path));
+                                                                       *gen = Some(types.resolve_path(&trait_bound.path, None));
                                                                }
                                                        }
                                                } else { return false; }
@@ -276,8 +275,10 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                                }
                        }
                }
-               for (_, (_, ident)) in self.typed_generics.iter() {
-                       if ident.is_none() { return false; }
+               for (key, value) in new_typed_generics.drain() {
+                       if let Some(v) = value {
+                               assert!(self.typed_generics.insert(key, v).is_none());
+                       } else { return false; }
                }
                true
        }
@@ -292,17 +293,15 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                                        match bounds_iter.next().unwrap() {
                                                syn::TypeParamBound::Trait(tr) => {
                                                        assert_simple_bound(&tr);
-                                                       if let Some(mut path) = types.maybe_resolve_path(&tr.path, None) {
+                                                       if let Some(path) = types.maybe_resolve_path(&tr.path, None) {
                                                                if types.skip_path(&path) { continue; }
                                                                // In general we handle Deref<Target=X> as if it were just X (and
                                                                // implement Deref<Target=Self> for relevant types). We don't
                                                                // bother to implement it for associated types, however, so we just
                                                                // ignore such bounds.
-                                                               let new_ident = if path != "std::ops::Deref" && path != "core::ops::Deref" {
-                                                                       path = "crate::".to_string() + &path;
-                                                                       Some(&tr.path)
-                                                               } else { None };
-                                                               self.typed_generics.insert(&t.ident, (path, new_ident));
+                                                               if path != "std::ops::Deref" && path != "core::ops::Deref" {
+                                                                       self.typed_generics.insert(&t.ident, path);
+                                                               }
                                                        } else { unimplemented!(); }
                                                },
                                                _ => unimplemented!(),
@@ -318,10 +317,10 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
        pub fn maybe_resolve_ident<'b>(&'b self, ident: &syn::Ident) -> Option<&'b String> {
                if let Some(ty) = &self.self_ty {
                        if format!("{}", ident) == "Self" {
-                               return Some(&ty.0);
+                               return Some(&ty);
                        }
                }
-               if let Some(res) = self.typed_generics.get(ident).map(|(a, _)| a) {
+               if let Some(res) = self.typed_generics.get(ident) {
                        return Some(res);
                }
                if let Some(parent) = self.parent {
@@ -333,14 +332,14 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
 
        /// Attempt to resolve a Path as a generic parameter and return the full path. as both a string
        /// and syn::Path.
-       pub fn maybe_resolve_path<'b>(&'b self, path: &syn::Path) -> Option<(&'b String, &'a syn::Path)> {
+       pub fn maybe_resolve_path<'b>(&'b self, path: &syn::Path) -> Option<&'b String> {
                if let Some(ident) = path.get_ident() {
                        if let Some(ty) = &self.self_ty {
                                if format!("{}", ident) == "Self" {
-                                       return Some((&ty.0, ty.1));
+                                       return Some(&ty);
                                }
                        }
-                       if let Some(res) = self.typed_generics.get(ident).map(|(a, b)| (a, b.unwrap())) {
+                       if let Some(res) = self.typed_generics.get(ident) {
                                return Some(res);
                        }
                } else {
@@ -349,7 +348,7 @@ impl<'a, 'p: 'a> GenericTypes<'a, 'p> {
                        let mut it = path.segments.iter();
                        if path.segments.len() == 2 && format!("{}", it.next().unwrap().ident) == "Self" {
                                let ident = &it.next().unwrap().ident;
-                               if let Some(res) = self.typed_generics.get(ident).map(|(a, b)| (a, b.unwrap())) {
+                               if let Some(res) = self.typed_generics.get(ident) {
                                        return Some(res);
                                }
                        }
@@ -581,12 +580,12 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr
                } else { None }
        }
 
-       pub fn maybe_resolve_path(&self, p_arg: &syn::Path, generics: Option<&GenericTypes>) -> Option<String> {
-               let p = if let Some(gen_types) = generics {
-                       if let Some((_, synpath)) = gen_types.maybe_resolve_path(p_arg) {
-                               synpath
-                       } else { p_arg }
-               } else { p_arg };
+       pub fn maybe_resolve_path(&self, p: &syn::Path, generics: Option<&GenericTypes>) -> Option<String> {
+               if let Some(gen_types) = generics {
+                       if let Some(resp) = gen_types.maybe_resolve_path(p) {
+                               return Some(resp.clone());
+                       }
+               }
 
                if p.leading_colon.is_some() {
                        let mut res: String = p.segments.iter().enumerate().map(|(idx, seg)| {
@@ -798,8 +797,8 @@ pub struct TypeResolver<'mod_lifetime, 'crate_lft: 'mod_lifetime> {
 enum EmptyValExpectedTy {
        /// A type which has a flag for being empty (eg an array where we treat all-0s as empty).
        NonPointer,
-       /// A pointer that we want to dereference and move out of.
-       OwnedPointer,
+       /// A Option mapped as a COption_*Z
+       OptionType,
        /// A pointer which we want to convert to a reference.
        ReferenceAsPointer,
 }
@@ -889,6 +888,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "std::time::SystemTime" => Some("u64"),
                        "std::io::Error" => Some("crate::c_types::IOError"),
 
+                       "core::convert::Infallible" => Some("crate::c_types::NotConstructable"),
+
                        "bech32::u5" => Some("crate::c_types::u5"),
                        "core::num::NonZeroU8" => Some("u8"),
 
@@ -931,6 +932,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        // Override the default since Records contain an fmt with a lifetime:
                        "lightning::util::logger::Record" => Some("*const std::os::raw::c_char"),
 
+                       "lightning::io::Read" => Some("crate::c_types::u8slice"),
+
                        _ => None,
                }
        }
@@ -965,6 +968,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        // Note that we'll panic for String if is_ref, as we only have non-owned memory, we
                        // cannot create a &String.
 
+                       "core::convert::Infallible" => Some("panic!(\"You must never construct a NotConstructable! : "),
+
                        "std::time::Duration"|"core::time::Duration" => Some("std::time::Duration::from_secs("),
                        "std::time::SystemTime" => Some("(::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs("),
 
@@ -986,6 +991,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "bitcoin::blockdata::script::Script" if !is_ref => Some("::bitcoin::blockdata::script::Script::from("),
                        "bitcoin::blockdata::transaction::Transaction" if is_ref => Some("&"),
                        "bitcoin::blockdata::transaction::Transaction" => Some(""),
+                       "bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::C_to_bitcoin_outpoint("),
                        "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(""),
                        "bitcoin::network::constants::Network" => Some(""),
                        "bitcoin::blockdata::block::BlockHeader" => Some("&::bitcoin::consensus::encode::deserialize(unsafe { &*"),
@@ -1013,6 +1019,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        // List of traits we map (possibly during processing of other files):
                        "crate::util::logger::Logger" => Some(""),
 
+                       "lightning::io::Read" => Some("&mut "),
+
                        _ => None,
                }.map(|s| s.to_owned())
        }
@@ -1040,6 +1048,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "alloc::string::String"|"String" => Some(".into_string()"),
                        "std::io::Error" if !is_ref => Some(".to_rust()"),
 
+                       "core::convert::Infallible" => Some("\")"),
+
                        "std::time::Duration"|"core::time::Duration" => Some(")"),
                        "std::time::SystemTime" => Some("))"),
 
@@ -1057,6 +1067,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "bitcoin::blockdata::script::Script" if is_ref => Some(".to_slice()))"),
                        "bitcoin::blockdata::script::Script" if !is_ref => Some(".into_rust())"),
                        "bitcoin::blockdata::transaction::Transaction" => Some(".into_bitcoin()"),
+                       "bitcoin::blockdata::transaction::OutPoint" => Some(")"),
                        "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(".into_rust()"),
                        "bitcoin::network::constants::Network" => Some(".into_bitcoin()"),
                        "bitcoin::blockdata::block::BlockHeader" => Some(" }).unwrap()"),
@@ -1079,6 +1090,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        // List of traits we map (possibly during processing of other files):
                        "crate::util::logger::Logger" => Some(""),
 
+                       "lightning::io::Read" => Some(".to_reader()"),
+
                        _ => None,
                }.map(|s| s.to_owned())
        }
@@ -1128,6 +1141,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "std::time::SystemTime" => Some(""),
                        "std::io::Error" if !is_ref => Some("crate::c_types::IOError::from_rust("),
 
+                       "core::convert::Infallible" => Some("panic!(\"Cannot construct an Infallible: "),
+
                        "bech32::u5" => Some(""),
 
                        "bitcoin::secp256k1::key::PublicKey"|"bitcoin::secp256k1::PublicKey"|"secp256k1::key::PublicKey"
@@ -1167,6 +1182,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        // Override the default since Records contain an fmt with a lifetime:
                        "lightning::util::logger::Record" => Some("local_"),
 
+                       "lightning::io::Read" => Some("crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec("),
+
                        _ => None,
                }.map(|s| s.to_owned())
        }
@@ -1198,6 +1215,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "std::time::SystemTime" => Some(".duration_since(::std::time::SystemTime::UNIX_EPOCH).expect(\"Times must be post-1970\").as_secs()"),
                        "std::io::Error" if !is_ref => Some(")"),
 
+                       "core::convert::Infallible" => Some("\")"),
+
                        "bech32::u5" => Some(".into()"),
 
                        "bitcoin::secp256k1::key::PublicKey"|"bitcoin::secp256k1::PublicKey"|"secp256k1::key::PublicKey"
@@ -1236,6 +1255,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        // Override the default since Records contain an fmt with a lifetime:
                        "lightning::util::logger::Record" => Some(".as_ptr()"),
 
+                       "lightning::io::Read" => Some("))"),
+
                        _ => None,
                }.map(|s| s.to_owned())
        }
@@ -1249,6 +1270,18 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                }
        }
 
+       /// When printing a reference to the source crate's rust type, if we need to map it to a
+       /// different "real" type, it can be done so here.
+       /// This is useful to work around limitations in the binding type resolver, where we reference
+       /// a non-public `use` alias.
+       /// TODO: We should never need to use this!
+       fn real_rust_type_mapping<'equiv>(&self, thing: &'equiv str) -> &'equiv str {
+               match thing {
+                       "lightning::io::Read" => "std::io::Read",
+                       _ => thing,
+               }
+       }
+
        // ****************************
        // *** Container Processing ***
        // ****************************
@@ -1266,15 +1299,17 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
 
        /// Returns true if the path containing the given args is a "transparent" container, ie an
        /// Option or a container which does not require a generated continer class.
-       fn is_transparent_container<'i, I: Iterator<Item=&'i syn::Type>>(&self, full_path: &str, _is_ref: bool, mut args: I) -> bool {
+       fn is_transparent_container<'i, I: Iterator<Item=&'i syn::Type>>(&self, full_path: &str, _is_ref: bool, mut args: I, generics: Option<&GenericTypes>) -> bool {
                if full_path == "Option" {
                        let inner = args.next().unwrap();
                        assert!(args.next().is_none());
                        match inner {
                                syn::Type::Reference(_) => true,
                                syn::Type::Path(p) => {
-                                       if let Some(resolved) = self.maybe_resolve_path(&p.path, None) {
-                                               if self.is_primitive(&resolved) { false } else { true }
+                                       if let Some(resolved) = self.maybe_resolve_path(&p.path, generics) {
+                                               if self.c_type_has_inner_from_path(&resolved) { return true; }
+                                               if self.is_primitive(&resolved) { return false; }
+                                               if self.c_type_from_path(&resolved, false, false).is_some() { true } else { false }
                                        } else { true }
                                },
                                syn::Type::Tuple(_) => false,
@@ -1294,7 +1329,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        }),
                        syn::PathArguments::Parenthesized(_) => unimplemented!(),
                };
-               self.is_transparent_container(&self.resolve_path(full_path, generics), is_ref, inner_iter)
+               self.is_transparent_container(&self.resolve_path(full_path, generics), is_ref, inner_iter, generics)
        }
        /// Returns true if this is a known, supported, non-transparent container.
        fn is_known_container(&self, full_path: &str, is_ref: bool) -> bool {
@@ -1330,12 +1365,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        } else { None }
                                } else { None };
                                if let Some(inner_path) = contained_struct {
-                                       if self.is_primitive(&inner_path) {
-                                               return Some(("if ", vec![
-                                                       (format!(".is_none() {{ {}::COption_{}Z::None }} else {{ ", Self::generated_container_path(), inner_path),
-                                                        format!("{}::COption_{}Z::Some({}.unwrap())", Self::generated_container_path(), inner_path, var_access))
-                                                       ], " }", ContainerPrefixLocation::NoPrefix));
-                                       } else if self.c_type_has_inner_from_path(&inner_path) {
+                                       if self.c_type_has_inner_from_path(&inner_path) {
                                                let is_inner_ref = if let Some(syn::Type::Reference(_)) = single_contained { true } else { false };
                                                if is_ref {
                                                        return Some(("if ", vec![
@@ -1347,6 +1377,16 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                                (".is_none() { std::ptr::null_mut() } else { ".to_owned(), format!("({}.unwrap())", var_access))
                                                                ], " }", ContainerPrefixLocation::OutsideConv));
                                                }
+                                       } else if self.is_primitive(&inner_path) || self.c_type_from_path(&inner_path, false, false).is_none() {
+                                               let inner_name = inner_path.rsplit("::").next().unwrap();
+                                               return Some(("if ", vec![
+                                                       (format!(".is_none() {{ {}::COption_{}Z::None }} else {{ {}::COption_{}Z::Some(",
+                                                               Self::generated_container_path(), inner_name, Self::generated_container_path(), inner_name),
+                                                        format!("{}.unwrap()", var_access))
+                                                       ], ") }", ContainerPrefixLocation::PerConv));
+                                       } else {
+                                               // If c_type_from_path is some (ie there's a manual mapping for the inner
+                                               // type), lean on write_empty_rust_val, below.
                                        }
                                }
                                if let Some(t) = single_contained {
@@ -1406,14 +1446,11 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                                        return Some(("if ", vec![
                                                                                (format!("{} {{ None }} else {{ Some(", s), format!("unsafe {{ &mut *{} }}", var_access))
                                                                        ], ") }", ContainerPrefixLocation::NoPrefix)),
-                                                               EmptyValExpectedTy::OwnedPointer => {
-                                                                       if let syn::Type::Slice(_) = t {
-                                                                                       panic!();
-                                                                       }
-                                                                       return Some(("if ", vec![
-                                                                               (format!("{} {{ None }} else {{ Some(", s), format!("unsafe {{ *Box::from_raw({}) }}", var_access))
-                                                                       ], ") }", ContainerPrefixLocation::NoPrefix));
-                                                               }
+                                                               EmptyValExpectedTy::OptionType =>
+                                                                       return Some(("{ /* ", vec![
+                                                                               (format!("*/ let {}_opt = {};", var_name, var_access),
+                                                                               format!("}} if {}_opt{} {{ None }} else {{ Some({{ {}_opt.take()", var_name, s, var_name))
+                                                                       ], ") } }", ContainerPrefixLocation::PerConv)),
                                                                EmptyValExpectedTy::NonPointer =>
                                                                        return Some(("if ", vec![
                                                                                (format!("{} {{ None }} else {{ Some(", s), format!("{}", var_access))
@@ -1431,6 +1468,49 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                }
        }
 
+       /// Constructs a reference to the given type, possibly tweaking the type if relevant to make it
+       /// convertable to C.
+       pub fn create_ownable_reference(&self, t: &syn::Type, generics: Option<&GenericTypes>) -> Option<syn::Type> {
+               let default_value = Some(syn::Type::Reference(syn::TypeReference {
+                       and_token: syn::Token!(&)(Span::call_site()), lifetime: None, mutability: None,
+                       elem: Box::new(t.clone()) }));
+               match generics.resolve_type(t) {
+                       syn::Type::Path(p) => {
+                               if let Some(resolved_path) = self.maybe_resolve_path(&p.path, generics) {
+                                       if resolved_path != "Vec" { return default_value; }
+                                       if p.path.segments.len() != 1 { unimplemented!(); }
+                                       let only_seg = p.path.segments.iter().next().unwrap();
+                                       if let syn::PathArguments::AngleBracketed(args) = &only_seg.arguments {
+                                               if args.args.len() != 1 { unimplemented!(); }
+                                               let inner_arg = args.args.iter().next().unwrap();
+                                               if let syn::GenericArgument::Type(ty) = &inner_arg {
+                                                       let mut can_create = self.c_type_has_inner(&ty);
+                                                       if let syn::Type::Path(inner) = ty {
+                                                               if inner.path.segments.len() == 1 &&
+                                                                               format!("{}", inner.path.segments[0].ident) == "Vec" {
+                                                                       can_create = true;
+                                                               }
+                                                       }
+                                                       if !can_create { return default_value; }
+                                                       if let Some(inner_ty) = self.create_ownable_reference(&ty, generics) {
+                                                               return Some(syn::Type::Reference(syn::TypeReference {
+                                                                       and_token: syn::Token![&](Span::call_site()),
+                                                                       lifetime: None,
+                                                                       mutability: None,
+                                                                       elem: Box::new(syn::Type::Slice(syn::TypeSlice {
+                                                                               bracket_token: syn::token::Bracket { span: Span::call_site() },
+                                                                               elem: Box::new(inner_ty)
+                                                                       }))
+                                                               }));
+                                                       } else { return default_value; }
+                                               } else { unimplemented!(); }
+                                       } else { unimplemented!(); }
+                               } else { return None; }
+                       },
+                       _ => default_value,
+               }
+       }
+
        // *************************************************
        // *** Type definition during main.rs processing ***
        // *************************************************
@@ -1442,12 +1522,14 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        pub fn c_type_has_inner_from_path(&self, full_path: &str) -> bool {
                self.crate_types.opaques.get(full_path).is_some()
        }
+
        /// Returns true if the object at the given path is mapped as X { inner: *mut origX, .. }.
        pub fn c_type_has_inner(&self, ty: &syn::Type) -> bool {
                match ty {
                        syn::Type::Path(p) => {
-                               let full_path = self.resolve_path(&p.path, None);
-                               self.c_type_has_inner_from_path(&full_path)
+                               if let Some(full_path) = self.maybe_resolve_path(&p.path, None) {
+                                       self.c_type_has_inner_from_path(&full_path)
+                               } else { false }
                        },
                        syn::Type::Reference(r) => {
                                self.c_type_has_inner(&*r.elem)
@@ -1496,7 +1578,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                // If we're printing a generic argument, it needs to reference the crate, otherwise
                                // the original crate:
                                } else if self.maybe_resolve_path(&path, None).as_ref() == Some(&resolved) {
-                                       write!(w, "{}", resolved).unwrap();
+                                       write!(w, "{}", self.real_rust_type_mapping(&resolved)).unwrap();
                                } else {
                                        write!(w, "crate::{}", resolved).unwrap();
                                }
@@ -1670,8 +1752,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                // We may eventually need to allow empty_val_check_suffix_from_path to specify if we need a deref or not
                                                EmptyValExpectedTy::NonPointer
                                        } else {
-                                               write!(w, " == std::ptr::null_mut()").unwrap();
-                                               EmptyValExpectedTy::OwnedPointer
+                                               write!(w, ".is_none()").unwrap();
+                                               EmptyValExpectedTy::OptionType
                                        }
                                }
                        },
@@ -1809,6 +1891,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                } else if let syn::Type::Reference(r) = &*s.elem {
                                        if let syn::Type::Path(p) = &*r.elem {
                                                write!(w, "{}", sliceconv(self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)), None)).unwrap();
+                                       } else if let syn::Type::Slice(_) = &*r.elem {
+                                               write!(w, "{}", sliceconv(false, None)).unwrap();
                                        } else { unimplemented!(); }
                                } else if let syn::Type::Tuple(t) = &*s.elem {
                                        assert!(!t.elems.is_empty());
@@ -1875,7 +1959,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                DeclType::EnumIgnored|DeclType::StructImported if !is_ref =>
                                                        write!(w, "crate::{} {{ inner: ObjOps::heap_alloc(", decl_path).unwrap(),
                                                DeclType::Trait(_) if is_ref => write!(w, "").unwrap(),
-                                               DeclType::Trait(_) if !is_ref => {},
+                                               DeclType::Trait(_) if !is_ref => write!(w, "Into::into(").unwrap(),
                                                _ => panic!("{:?}", decl_path),
                                        }
                                });
@@ -1901,7 +1985,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                // for use when a Rust trait method returns an associated type.
                                                // Because all of our C traits implement From<RustTypesImplementingTraits>
                                                // we can just call .into() here and be done.
-                                               write!(w, ".into()").unwrap()
+                                               write!(w, ")").unwrap()
                                        },
                                        _ => unimplemented!(),
                                });
@@ -2109,7 +2193,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        if let syn::PathArguments::AngleBracketed(args) = &p.path.segments.iter().next().unwrap().arguments {
                                                convert_container!(resolved_path, args.args.len(), || args.args.iter().map(|arg| {
                                                        if let syn::GenericArgument::Type(ty) = arg {
-                                                               ty
+                                                               generics.resolve_type(ty)
                                                        } else { unimplemented!(); }
                                                }));
                                        } else { unimplemented!(); }
@@ -2142,7 +2226,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                } else if let syn::Type::Reference(ty) = &*s.elem {
                                        let tyref = [&*ty.elem];
                                        is_ref = true;
-                                       convert_container!("Slice", 1, || tyref.iter().map(|t| *t));
+                                       convert_container!("Slice", 1, || tyref.iter().map(|t| generics.resolve_type(*t)));
                                        unimplemented!("convert_container should return true as container_lookup should succeed for slices");
                                } else if let syn::Type::Tuple(t) = &*s.elem {
                                        // When mapping into a temporary new var, we need to own all the underlying objects.
@@ -2372,7 +2456,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        fn write_c_mangled_container_path_intern<W: std::io::Write>
                        (&self, w: &mut W, args: Vec<&syn::Type>, generics: Option<&GenericTypes>, ident: &str, is_ref: bool, is_mut: bool, ptr_for_ref: bool, in_type: bool) -> bool {
                let mut mangled_type: Vec<u8> = Vec::new();
-               if !self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a)) {
+               if !self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a), generics) {
                        write!(w, "C{}_", ident).unwrap();
                        write!(mangled_type, "C{}_", ident).unwrap();
                } else { assert_eq!(args.len(), 1); }
@@ -2380,7 +2464,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        macro_rules! write_path {
                                ($p_arg: expr, $extra_write: expr) => {
                                        if let Some(subtype) = self.maybe_resolve_path(&$p_arg.path, generics) {
-                                               if self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a)) {
+                                               if self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a), generics) {
                                                        if !in_type {
                                                                if self.c_type_has_inner_from_path(&subtype) {
                                                                        if !self.write_c_path_intern(w, &$p_arg.path, generics, is_ref, is_mut, ptr_for_ref) { return false; }
@@ -2417,64 +2501,70 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        } else { return false; }
                                }
                        }
-                       if let syn::Type::Tuple(tuple) = arg {
-                               if tuple.elems.len() == 0 {
-                                       write!(w, "None").unwrap();
-                                       write!(mangled_type, "None").unwrap();
-                               } else {
-                                       let mut mangled_tuple_type: Vec<u8> = Vec::new();
-
-                                       // Figure out what the mangled type should look like. To disambiguate
-                                       // ((A, B), C) and (A, B, C) we prefix the generic args with a _ and suffix
-                                       // them with a Z. Ideally we wouldn't use Z, but not many special chars are
-                                       // available for use in type names.
-                                       write!(w, "C{}Tuple_", tuple.elems.len()).unwrap();
-                                       write!(mangled_type, "C{}Tuple_", tuple.elems.len()).unwrap();
-                                       write!(mangled_tuple_type, "C{}Tuple_", tuple.elems.len()).unwrap();
-                                       for elem in tuple.elems.iter() {
-                                               if let syn::Type::Path(p) = elem {
-                                                       write_path!(p, Some(&mut mangled_tuple_type));
-                                               } else if let syn::Type::Reference(refelem) = elem {
-                                                       if let syn::Type::Path(p) = &*refelem.elem {
+                       match generics.resolve_type(arg) {
+                               syn::Type::Tuple(tuple) => {
+                                       if tuple.elems.len() == 0 {
+                                               write!(w, "None").unwrap();
+                                               write!(mangled_type, "None").unwrap();
+                                       } else {
+                                               let mut mangled_tuple_type: Vec<u8> = Vec::new();
+
+                                               // Figure out what the mangled type should look like. To disambiguate
+                                               // ((A, B), C) and (A, B, C) we prefix the generic args with a _ and suffix
+                                               // them with a Z. Ideally we wouldn't use Z, but not many special chars are
+                                               // available for use in type names.
+                                               write!(w, "C{}Tuple_", tuple.elems.len()).unwrap();
+                                               write!(mangled_type, "C{}Tuple_", tuple.elems.len()).unwrap();
+                                               write!(mangled_tuple_type, "C{}Tuple_", tuple.elems.len()).unwrap();
+                                               for elem in tuple.elems.iter() {
+                                                       if let syn::Type::Path(p) = elem {
                                                                write_path!(p, Some(&mut mangled_tuple_type));
+                                                       } else if let syn::Type::Reference(refelem) = elem {
+                                                               if let syn::Type::Path(p) = &*refelem.elem {
+                                                                       write_path!(p, Some(&mut mangled_tuple_type));
+                                                               } else { return false; }
                                                        } else { return false; }
-                                               } else { return false; }
-                                       }
-                                       write!(w, "Z").unwrap();
-                                       write!(mangled_type, "Z").unwrap();
-                                       write!(mangled_tuple_type, "Z").unwrap();
-                                       if !self.check_create_container(String::from_utf8(mangled_tuple_type).unwrap(),
-                                                       &format!("{}Tuple", tuple.elems.len()), tuple.elems.iter().collect(), generics, is_ref) {
-                                               return false;
+                                               }
+                                               write!(w, "Z").unwrap();
+                                               write!(mangled_type, "Z").unwrap();
+                                               write!(mangled_tuple_type, "Z").unwrap();
+                                               if !self.check_create_container(String::from_utf8(mangled_tuple_type).unwrap(),
+                                                               &format!("{}Tuple", tuple.elems.len()), tuple.elems.iter().collect(), generics, is_ref) {
+                                                       return false;
+                                               }
                                        }
-                               }
-                       } else if let syn::Type::Path(p_arg) = arg {
-                               write_path!(p_arg, None);
-                       } else if let syn::Type::Reference(refty) = arg {
-                               if let syn::Type::Path(p_arg) = &*refty.elem {
+                               },
+                               syn::Type::Path(p_arg) => {
                                        write_path!(p_arg, None);
-                               } else if let syn::Type::Slice(_) = &*refty.elem {
-                                       // write_c_type will actually do exactly what we want here, we just need to
-                                       // make it a pointer so that its an option. Note that we cannot always convert
-                                       // the Vec-as-slice (ie non-ref types) containers, so sometimes need to be able
-                                       // to edit it, hence we use *mut here instead of *const.
-                                       if args.len() != 1 { return false; }
-                                       write!(w, "*mut ").unwrap();
-                                       self.write_c_type(w, arg, None, true);
-                               } else { return false; }
-                       } else if let syn::Type::Array(a) = arg {
-                               if let syn::Type::Path(p_arg) = &*a.elem {
-                                       let resolved = self.resolve_path(&p_arg.path, generics);
-                                       if !self.is_primitive(&resolved) { return false; }
-                                       if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(len), .. }) = &a.len {
-                                               if self.c_type_from_path(&format!("[{}; {}]", resolved, len.base10_digits()), is_ref, ptr_for_ref).is_none() { return false; }
-                                               write!(w, "_{}{}", resolved, len.base10_digits()).unwrap();
-                                               write!(mangled_type, "_{}{}", resolved, len.base10_digits()).unwrap();
+                               },
+                               syn::Type::Reference(refty) => {
+                                       if let syn::Type::Path(p_arg) = &*refty.elem {
+                                               write_path!(p_arg, None);
+                                       } else if let syn::Type::Slice(_) = &*refty.elem {
+                                               // write_c_type will actually do exactly what we want here, we just need to
+                                               // make it a pointer so that its an option. Note that we cannot always convert
+                                               // the Vec-as-slice (ie non-ref types) containers, so sometimes need to be able
+                                               // to edit it, hence we use *mut here instead of *const.
+                                               if args.len() != 1 { return false; }
+                                               write!(w, "*mut ").unwrap();
+                                               self.write_c_type(w, arg, None, true);
                                        } else { return false; }
-                               } else { return false; }
-                       } else { return false; }
+                               },
+                               syn::Type::Array(a) => {
+                                       if let syn::Type::Path(p_arg) = &*a.elem {
+                                               let resolved = self.resolve_path(&p_arg.path, generics);
+                                               if !self.is_primitive(&resolved) { return false; }
+                                               if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(len), .. }) = &a.len {
+                                                       if self.c_type_from_path(&format!("[{}; {}]", resolved, len.base10_digits()), is_ref, ptr_for_ref).is_none() { return false; }
+                                                       write!(w, "_{}{}", resolved, len.base10_digits()).unwrap();
+                                                       write!(mangled_type, "_{}{}", resolved, len.base10_digits()).unwrap();
+                                               } else { return false; }
+                                       } else { return false; }
+                               },
+                               _ => { return false; },
+                       }
                }
-               if self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a)) { return true; }
+               if self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a), generics) { return true; }
                // Push the "end of type" Z
                write!(w, "Z").unwrap();
                write!(mangled_type, "Z").unwrap();
@@ -2483,7 +2573,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                self.check_create_container(String::from_utf8(mangled_type).unwrap(), ident, args, generics, is_ref)
        }
        fn write_c_mangled_container_path<W: std::io::Write>(&self, w: &mut W, args: Vec<&syn::Type>, generics: Option<&GenericTypes>, ident: &str, is_ref: bool, is_mut: bool, ptr_for_ref: bool) -> bool {
-               if !self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a)) {
+               if !self.is_transparent_container(ident, is_ref, args.iter().map(|a| *a), generics) {
                        write!(w, "{}::", Self::generated_container_path()).unwrap();
                }
                self.write_c_mangled_container_path_intern(w, args, generics, ident, is_ref, is_mut, ptr_for_ref, false)
@@ -2598,6 +2688,20 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                } else { return false; };
                                                write!(w, "{}::{}", Self::generated_container_path(), mangled_container).unwrap();
                                                self.check_create_container(mangled_container, "Vec", vec![&*r.elem], generics, false)
+                                       } else if let syn::Type::Slice(sl2) = &*r.elem {
+                                               if let syn::Type::Reference(r2) = &*sl2.elem {
+                                                       if let syn::Type::Path(p) = &*r2.elem {
+                                                               // Slices with slices with opaque types (with is_owned flags) are mapped as non-ref Vecs
+                                                               let resolved = self.resolve_path(&p.path, generics);
+                                                               let mangled_container = if let Some(ident) = self.crate_types.opaques.get(&resolved) {
+                                                                       format!("CVec_CVec_{}ZZ", ident)
+                                                               } else { return false; };
+                                                               write!(w, "{}::{}", Self::generated_container_path(), mangled_container).unwrap();
+                                                               let inner = &r2.elem;
+                                                               let vec_ty: syn::Type = syn::parse_quote!(Vec<#inner>);
+                                                               self.check_create_container(mangled_container, "Vec", vec![&vec_ty], generics, false)
+                                                       } else { false }
+                                               } else { false }
                                        } else { false }
                                } else if let syn::Type::Tuple(_) = &*s.elem {
                                        let mut args = syn::punctuated::Punctuated::<_, syn::token::Comma>::new();
index 19edb0aef009f3180bd2c8ca39b14494dd1e6dc3..f0f820533d9417210811ac03a78d7b5d7cbf1ff0 100644 (file)
@@ -18,10 +18,10 @@ crate-type = ["staticlib"
 bitcoin = "0.27"
 secp256k1 = { version = "0.20.3", features = ["global-context-less-secure"] }
 # Note that the following line is matched by genbindings to update the path
-lightning = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "479ff9018c1a1d49fa8e9036b81bcdcff210a7e5", features = ["allow_wallclock_use"] }
-lightning-persister = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "479ff9018c1a1d49fa8e9036b81bcdcff210a7e5" }
-lightning-invoice = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "479ff9018c1a1d49fa8e9036b81bcdcff210a7e5" }
-lightning-background-processor = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "479ff9018c1a1d49fa8e9036b81bcdcff210a7e5" }
+lightning = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "367a2ccf2c1856bba67f12c82a4ab80d7941616f", features = ["allow_wallclock_use"] }
+lightning-persister = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "367a2ccf2c1856bba67f12c82a4ab80d7941616f" }
+lightning-invoice = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "367a2ccf2c1856bba67f12c82a4ab80d7941616f" }
+lightning-background-processor = { git = "https://github.com/rust-bitcoin/rust-lightning", rev = "367a2ccf2c1856bba67f12c82a4ab80d7941616f" }
 
 # Always force panic=abort, further options are set in the genbindings.sh build script
 [profile.dev]
index a9556303fa3d1a0e826fbcff69625a38f8124b03..e8a0997363b9291cfce627339c6dba1116950b5a 100644 (file)
@@ -35,7 +35,7 @@ LDKCVec_MonitorEventZ monitors_pending_monitor_events(const void *this_arg) {
        return empty_htlc_vec;
 }
 
-void never_handle_event(const void *this_arg, struct LDKEvent event) {
+void never_handle_event(const void *this_arg, const struct LDKEvent* event) {
        // Note that we never actually generate any events to handle in the code below.
        assert(false);
 }
index 7c6dfda2e0f1c93ffbe83ba0a7dfbc9c0943ff53..e7b596b0199a6e72a36f50c37ddcf9b45192c25d 100644 (file)
@@ -194,9 +194,9 @@ LDKCVec_MonitorEventZ monitors_pending_monitor_events(const void *this_arg) {
 struct EventQueue {
        std::vector<LDK::Event> events;
 };
-void handle_event(const void *this_arg, LDKEvent event) {
+void handle_event(const void *this_arg, const LDKEvent *event) {
        EventQueue* arg = (EventQueue*) this_arg;
-       arg->events.push_back(std::move(event));
+       arg->events.push_back(Event_clone(event));
 }
 
 #ifdef REAL_NET
@@ -354,6 +354,68 @@ public:
 };
 #endif // !REAL_NET
 
+struct CustomMsgQueue {
+       std::vector<LDK::Type> msgs;
+};
+
+uint16_t custom_msg_type_id(const void *this_arg) {
+       return 8888;
+}
+LDKCVec_u8Z custom_msg_bytes(const void *this_arg) {
+       uint8_t *bytes = (uint8_t *) malloc(1024);
+       memset(bytes, 42, 1024);
+       return LDKCVec_u8Z {
+               .data = bytes, .datalen = 1024
+       };
+}
+LDKStr custom_msg_debug(const void *this_arg) {
+       return LDKStr {
+               .chars = NULL, .len = 0, .chars_is_owned = false
+       };
+}
+
+LDKCResult_COption_TypeZDecodeErrorZ read_custom_message(const void* this_arg, uint16_t type_id, LDKu8slice buf) {
+       assert(type_id == 8888);
+       assert(buf.datalen == 1024);
+       uint8_t cmp[1024];
+       memset(cmp, 42, 1024);
+       assert(!memcmp(cmp, buf.data, 1024));
+       return CResult_COption_TypeZDecodeErrorZ_ok(COption_TypeZ_some(LDKType {
+               .this_arg = NULL,
+               .type_id = custom_msg_type_id,
+               .debug_str = custom_msg_debug,
+               .free = NULL,
+       }));
+}
+
+LDKCResult_NoneLightningErrorZ handle_custom_message(const void* this_arg, struct LDKType msg, struct LDKPublicKey _sender_node_id) {
+       CustomMsgQueue* arg = (CustomMsgQueue*) this_arg;
+       arg->msgs.push_back(std::move(msg));
+       return CResult_NoneLightningErrorZ_ok();
+}
+LDKCVec_C2Tuple_PublicKeyTypeZZ never_send_custom_msgs(const void* this_arg) {
+       return LDKCVec_C2Tuple_PublicKeyTypeZZ {
+               .data = NULL, .datalen = 0
+       };
+}
+
+LDKCVec_C2Tuple_PublicKeyTypeZZ create_custom_msg(const void* this_arg) {
+       const LDKPublicKey *counterparty_node_id = (const LDKPublicKey *)this_arg;
+       LDKCVec_C2Tuple_PublicKeyTypeZZ ret = {
+               .data = ((LDKC2Tuple_PublicKeyTypeZ*)malloc(sizeof(LDKC2Tuple_PublicKeyTypeZ))),
+               .datalen = 1
+       };
+       ret.data[0].a = *counterparty_node_id;
+       ret.data[0].b = LDKType {
+               .this_arg = NULL,
+               .type_id = custom_msg_type_id,
+               .debug_str = custom_msg_debug,
+               .write = custom_msg_bytes,
+               .free = NULL,
+       };
+       return ret;
+}
+
 int main() {
        uint8_t channel_open_header[80];
        uint8_t header_1[80];
@@ -395,7 +457,7 @@ int main() {
                .free = NULL,
        };
 
-       LDK::NetGraphMsgHandler net_graph1 = NetGraphMsgHandler_new(genesis_hash, NULL, logger1);
+       LDK::NetGraphMsgHandler net_graph1 = NetGraphMsgHandler_new(NetworkGraph_new(genesis_hash), COption_AccessZ_none(), logger1);
        LDKSecretKey node_secret1;
 
        LDKLogger logger2 {
@@ -414,7 +476,7 @@ int main() {
                .free = NULL,
        };
 
-       LDK::NetGraphMsgHandler net_graph2 = NetGraphMsgHandler_new(genesis_hash, NULL, logger2);
+       LDK::NetGraphMsgHandler net_graph2 = NetGraphMsgHandler_new(NetworkGraph_new(genesis_hash), COption_AccessZ_none(), logger2);
        LDKSecretKey node_secret2;
 
        LDK::CVec_u8Z cm1_ser = LDKCVec_u8Z {}; // ChannelManager 1 serialization at the end of the ser-des scope
@@ -435,8 +497,11 @@ int main() {
 
                LDK::MessageHandler msg_handler1 = MessageHandler_new(ChannelManager_as_ChannelMessageHandler(&cm1), NetGraphMsgHandler_as_RoutingMessageHandler(&net_graph1));
 
+               LDK::IgnoringMessageHandler ignoring_handler1 = IgnoringMessageHandler_new();
+               LDK::CustomMessageHandler custom_msg_handler1 = IgnoringMessageHandler_as_CustomMessageHandler(&ignoring_handler1);
+
                random_bytes = keys_source1->get_secure_random_bytes(keys_source1->this_arg);
-               LDK::PeerManager net1 = PeerManager_new(std::move(msg_handler1), node_secret1, &random_bytes.data, logger1);
+               LDK::PeerManager net1 = PeerManager_new(std::move(msg_handler1), node_secret1, &random_bytes.data, logger1, std::move(custom_msg_handler1));
 
                // Demo getting a channel key and check that its returning real pubkeys:
                LDK::Sign chan_signer1 = keys_source1->get_channel_signer(keys_source1->this_arg, false, 42);
@@ -468,8 +533,11 @@ int main() {
 
                LDK::MessageHandler msg_handler2 = MessageHandler_new(ChannelManager_as_ChannelMessageHandler(&cm2), std::move(net_msgs2));
 
+               LDK::IgnoringMessageHandler ignoring_handler2 = IgnoringMessageHandler_new();
+               LDK::CustomMessageHandler custom_msg_handler2 = IgnoringMessageHandler_as_CustomMessageHandler(&ignoring_handler2);
+
                random_bytes = keys_source2->get_secure_random_bytes(keys_source2->this_arg);
-               LDK::PeerManager net2 = PeerManager_new(std::move(msg_handler2), node_secret2, &random_bytes.data, logger2);
+               LDK::PeerManager net2 = PeerManager_new(std::move(msg_handler2), node_secret2, &random_bytes.data, logger2, std::move(custom_msg_handler2));
 
                // Open a connection!
                PeersConnection conn(cm1, cm2, net1, net2);
@@ -553,6 +621,7 @@ int main() {
                PeerManager_process_events(&net2);
 
                // Now send funds from 1 to 2!
+               uint64_t channel_scid;
                while (true) {
                        LDK::CVec_ChannelDetailsZ outbound_channels = ChannelManager_list_usable_channels(&cm1);
                        if (outbound_channels->datalen == 1) {
@@ -573,6 +642,9 @@ int main() {
                                if (inbound_capacity < 0) inbound_capacity = 0;
                                assert(ChannelDetails_get_inbound_capacity_msat(channel) == (uint64_t)inbound_capacity);
                                assert(ChannelDetails_get_is_usable(channel));
+                               LDK::COption_u64Z scid_opt = ChannelDetails_get_short_channel_id(channel);
+                               assert(scid_opt->some);
+                               channel_scid = scid_opt->some;
                                break;
                        }
                        std::this_thread::yield();
@@ -596,13 +668,18 @@ int main() {
 
                {
                        LDK::CVec_ChannelDetailsZ outbound_channels = ChannelManager_list_usable_channels(&cm1);
-                       LDK::LockedNetworkGraph graph_2_locked = NetGraphMsgHandler_read_locked_graph(&net_graph2);
-                       LDK::NetworkGraph graph_2_ref = LockedNetworkGraph_graph(&graph_2_locked);
+                       LDK::NetworkGraph graph_2_ref = NetGraphMsgHandler_get_network_graph(&net_graph2);
                        LDK::CResult_RouteLightningErrorZ route = get_route(ChannelManager_get_our_node_id(&cm1), &graph_2_ref, ChannelManager_get_our_node_id(&cm2), LDKInvoiceFeatures {
                                        .inner = NULL, .is_owned = false
                                }, &outbound_channels, Invoice_route_hints(invoice->contents.result),
                                5000, Invoice_min_final_cltv_expiry(invoice->contents.result), logger1);
                        assert(route->result_ok);
+                       LDK::CVec_CVec_RouteHopZZ paths = Route_get_paths(route->contents.result);
+                       assert(paths->datalen == 1);
+                       assert(paths->data[0].datalen == 1);
+                       assert(!memcmp(RouteHop_get_pubkey(&paths->data[0].data[0]).compressed_form,
+                               ChannelManager_get_our_node_id(&cm2).compressed_form, 33));
+                       assert(RouteHop_get_short_channel_id(&paths->data[0].data[0]) == channel_scid);
                        LDK::CResult_NonePaymentSendFailureZ send_res = ChannelManager_send_payment(&cm1, route->contents.result, payment_hash, Invoice_payment_secret(invoice->contents.result));
                        assert(send_res->result_ok);
                }
@@ -701,11 +778,36 @@ int main() {
        // Open a connection!
        LDK::MessageHandler msg_handler1 = MessageHandler_new(ChannelManager_as_ChannelMessageHandler(&cm1), NetGraphMsgHandler_as_RoutingMessageHandler(&net_graph1));
        random_bytes = keys_source1->get_secure_random_bytes(keys_source1->this_arg);
-       LDK::PeerManager net1 = PeerManager_new(std::move(msg_handler1), node_secret1, &random_bytes.data, logger1);
+
+       LDKPublicKey chan_2_node_id = ChannelManager_get_our_node_id(&cm2);
+       LDKCustomMessageHandler custom_msg_handler1 = {
+               .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,
+               .CustomMessageReader = LDKCustomMessageReader {
+                       .this_arg = NULL,
+                       .read = read_custom_message,
+                       .free = NULL,
+               },
+               .free = NULL,
+       };
+       LDK::PeerManager net1 = PeerManager_new(std::move(msg_handler1), node_secret1, &random_bytes.data, logger1, std::move(custom_msg_handler1));
 
        LDK::MessageHandler msg_handler2 = MessageHandler_new(ChannelManager_as_ChannelMessageHandler(&cm2), NetGraphMsgHandler_as_RoutingMessageHandler(&net_graph2));
+       CustomMsgQueue peer_2_custom_messages;
+       LDKCustomMessageHandler custom_msg_handler2 = {
+               .this_arg = &peer_2_custom_messages,
+               .handle_custom_message = handle_custom_message,
+               .get_and_clear_pending_msg = never_send_custom_msgs,
+               .CustomMessageReader = LDKCustomMessageReader {
+                       .this_arg = NULL,
+                       .read = read_custom_message,
+                       .free = NULL,
+               },
+               .free = NULL,
+       };
        random_bytes = keys_source1->get_secure_random_bytes(keys_source1->this_arg);
-       LDK::PeerManager net2 = PeerManager_new(std::move(msg_handler2), node_secret2, &random_bytes.data, logger2);
+       LDK::PeerManager net2 = PeerManager_new(std::move(msg_handler2), node_secret2, &random_bytes.data, logger2, std::move(custom_msg_handler2));
 
        PeersConnection conn(cm1, cm2, net1, net2);
 
@@ -732,6 +834,8 @@ int main() {
 
        conn.stop();
 
+       assert(peer_2_custom_messages.msgs.size() != 0);
+
        // Few extra random tests:
        LDKSecretKey sk;
        memset(&sk, 42, 32);
index 08a46b01214260fd42f4b5817f789eb0db365067..9c2fc19c8055f63d700b0995abc300c3ede918e8 100644 (file)
@@ -26,6 +26,10 @@ struct nativeHolderCommitmentTransactionOpaque;
 typedef struct nativeHolderCommitmentTransactionOpaque LDKnativeHolderCommitmentTransaction;
 struct nativeBuiltCommitmentTransactionOpaque;
 typedef struct nativeBuiltCommitmentTransactionOpaque LDKnativeBuiltCommitmentTransaction;
+struct nativeClosingTransactionOpaque;
+typedef struct nativeClosingTransactionOpaque LDKnativeClosingTransaction;
+struct nativeTrustedClosingTransactionOpaque;
+typedef struct nativeTrustedClosingTransactionOpaque LDKnativeTrustedClosingTransaction;
 struct nativeCommitmentTransactionOpaque;
 typedef struct nativeCommitmentTransactionOpaque LDKnativeCommitmentTransaction;
 struct nativeTrustedCommitmentTransactionOpaque;
@@ -71,6 +75,8 @@ 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;
@@ -131,8 +137,8 @@ struct nativePeerManagerOpaque;
 typedef struct nativePeerManagerOpaque LDKnativePeerManager;
 struct nativeNetworkGraphOpaque;
 typedef struct nativeNetworkGraphOpaque LDKnativeNetworkGraph;
-struct nativeLockedNetworkGraphOpaque;
-typedef struct nativeLockedNetworkGraphOpaque LDKnativeLockedNetworkGraph;
+struct nativeReadOnlyNetworkGraphOpaque;
+typedef struct nativeReadOnlyNetworkGraphOpaque LDKnativeReadOnlyNetworkGraph;
 struct nativeNetGraphMsgHandlerOpaque;
 typedef struct nativeNetGraphMsgHandlerOpaque LDKnativeNetGraphMsgHandler;
 struct nativeDirectionalChannelInfoOpaque;
index 9529ff757c0d6da158cb10c1619fa62a6130bcbb..06bd643b756dddbbc5acd7a149dff15d4e02014a 100644 (file)
@@ -328,6 +328,11 @@ typedef enum LDKSemanticError {
     * The invoice contains multiple descriptions and/or description hashes which isn't allowed
     */
    LDKSemanticError_MultipleDescriptions,
+   /**
+    * The invoice is missing the mandatory payment secret, which all modern lightning nodes
+    * should provide.
+    */
+   LDKSemanticError_NoPaymentSecret,
    /**
     * The invoice contains multiple payment secrets
     */
@@ -344,6 +349,10 @@ typedef enum LDKSemanticError {
     * The invoice's signature is invalid
     */
    LDKSemanticError_InvalidSignature,
+   /**
+    * The invoice's amount was not a whole number of millisatoshis
+    */
+   LDKSemanticError_ImpreciseAmount,
    /**
     * Must be last for serialization purposes
     */
@@ -1040,7 +1049,64 @@ typedef struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ {
 
 
 /**
- * This class tracks the per-transaction information needed to build a commitment transaction and to
+ * A wrapper on ClosingTransaction indicating that the built bitcoin
+ * transaction is trusted.
+ *
+ * See trust() and verify() functions on CommitmentTransaction.
+ *
+ * This structure implements Deref.
+ */
+typedef struct MUST_USE_STRUCT LDKTrustedClosingTransaction {
+   /**
+    * 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.
+    */
+   LDKnativeTrustedClosingTransaction *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;
+} LDKTrustedClosingTransaction;
+
+/**
+ * The contents of CResult_TrustedClosingTransactionNoneZ
+ */
+typedef union LDKCResult_TrustedClosingTransactionNoneZPtr {
+   /**
+    * A pointer to the contents in the success state.
+    * Reading from this pointer when `result_ok` is not set is undefined.
+    */
+   struct LDKTrustedClosingTransaction *result;
+   /**
+    * Note that this value is always NULL, as there are no contents in the Err variant
+    */
+   void *err;
+} LDKCResult_TrustedClosingTransactionNoneZPtr;
+
+/**
+ * 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`.
+ */
+typedef struct LDKCResult_TrustedClosingTransactionNoneZ {
+   /**
+    * The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either
+    * `err` or `result` depending on the state of `result_ok`.
+    */
+   union LDKCResult_TrustedClosingTransactionNoneZPtr contents;
+   /**
+    * Whether this CResult_TrustedClosingTransactionNoneZ represents a success state.
+    */
+   bool result_ok;
+} LDKCResult_TrustedClosingTransactionNoneZ;
+
+
+
+/**
+ * This class tracks the per-transaction information needed to build a commitment transaction and will
  * actually build it and sign.  It is used for holder transactions that we sign only when needed
  * and for transactions we sign for the counterparty.
  *
@@ -1791,9 +1857,9 @@ typedef enum LDKMonitorEvent_Tag {
     */
    LDKMonitorEvent_HTLCEvent,
    /**
-    * A monitor event that the Channel's commitment transaction was broadcasted.
+    * A monitor event that the Channel's commitment transaction was confirmed.
     */
-   LDKMonitorEvent_CommitmentTxBroadcasted,
+   LDKMonitorEvent_CommitmentTxConfirmed,
    /**
     * Must be last for serialization purposes
     */
@@ -1807,7 +1873,7 @@ typedef struct MUST_USE_STRUCT LDKMonitorEvent {
          struct LDKHTLCUpdate htlc_event;
       };
       struct {
-         struct LDKOutPoint commitment_tx_broadcasted;
+         struct LDKOutPoint commitment_tx_confirmed;
       };
    };
 } LDKMonitorEvent;
@@ -1857,6 +1923,121 @@ typedef struct LDKCOption_C2Tuple_usizeTransactionZZ {
 
 
 
+/**
+ * A channel_update message to be sent or received from a peer
+ */
+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;
+
+/**
+ * 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.
+ *
+ * [BOLT #4]: https://github.com/lightningnetwork/lightning-rfc/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 only that a channel has been closed, which should be applied via
+    * [`NetworkGraph::close_channel_from_update`].
+    */
+   LDKNetworkUpdate_ChannelClosed,
+   /**
+    * An error indicating only that a node has failed, which should be applied via
+    * [`NetworkGraph::fail_node`].
+    */
+   LDKNetworkUpdate_NodeFailure,
+   /**
+    * Must be last for serialization purposes
+    */
+   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_LDKChannelClosed_Body {
+   /**
+    * The short channel id of the closed channel.
+    */
+   uint64_t short_channel_id;
+   /**
+    * Whether the channel should be permanently removed or temporarily disabled until a new
+    * `channel_update` message is received.
+    */
+   bool is_permanent;
+} LDKNetworkUpdate_LDKChannelClosed_Body;
+
+typedef struct LDKNetworkUpdate_LDKNodeFailure_Body {
+   /**
+    * The node id of the failed node.
+    */
+   struct LDKPublicKey node_id;
+   /**
+    * Whether the node should be permanently removed from consideration or can be restored
+    * when a new `channel_update` message is received.
+    */
+   bool is_permanent;
+} LDKNetworkUpdate_LDKNodeFailure_Body;
+
+typedef struct MUST_USE_STRUCT LDKNetworkUpdate {
+   LDKNetworkUpdate_Tag tag;
+   union {
+      LDKNetworkUpdate_LDKChannelUpdateMessage_Body channel_update_message;
+      LDKNetworkUpdate_LDKChannelClosed_Body channel_closed;
+      LDKNetworkUpdate_LDKNodeFailure_Body node_failure;
+   };
+} LDKNetworkUpdate;
+
+/**
+ * An enum which can either contain a crate::lightning::routing::network_graph::NetworkUpdate or not
+ */
+typedef enum LDKCOption_NetworkUpdateZ_Tag {
+   /**
+    * When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::network_graph::NetworkUpdate
+    */
+   LDKCOption_NetworkUpdateZ_Some,
+   /**
+    * When we're in this state, this COption_NetworkUpdateZ contains nothing
+    */
+   LDKCOption_NetworkUpdateZ_None,
+   /**
+    * Must be last for serialization purposes
+    */
+   LDKCOption_NetworkUpdateZ_Sentinel,
+} LDKCOption_NetworkUpdateZ_Tag;
+
+typedef struct LDKCOption_NetworkUpdateZ {
+   LDKCOption_NetworkUpdateZ_Tag tag;
+   union {
+      struct {
+         struct LDKNetworkUpdate some;
+      };
+   };
+} LDKCOption_NetworkUpdateZ;
+
+
+
 /**
  * Information about a spendable output to a P2WSH script. See
  * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
@@ -2243,26 +2424,6 @@ typedef struct MUST_USE_STRUCT LDKChannelAnnouncement {
 
 
 
-/**
- * A channel_update message to be sent or received from a peer
- */
-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 node_announcement message to be sent or received from a peer
  */
@@ -2355,71 +2516,6 @@ typedef struct MUST_USE_STRUCT LDKErrorAction {
    };
 } LDKErrorAction;
 
-/**
- * The information we received from a peer along the route of a payment we originated. This is
- * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
- * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
- */
-typedef enum LDKHTLCFailChannelUpdate_Tag {
-   /**
-    * We received an error which included a full ChannelUpdate message.
-    */
-   LDKHTLCFailChannelUpdate_ChannelUpdateMessage,
-   /**
-    * We received an error which indicated only that a channel has been closed
-    */
-   LDKHTLCFailChannelUpdate_ChannelClosed,
-   /**
-    * We received an error which indicated only that a node has failed
-    */
-   LDKHTLCFailChannelUpdate_NodeFailure,
-   /**
-    * Must be last for serialization purposes
-    */
-   LDKHTLCFailChannelUpdate_Sentinel,
-} LDKHTLCFailChannelUpdate_Tag;
-
-typedef struct LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body {
-   /**
-    * The unwrapped message we received
-    */
-   struct LDKChannelUpdate msg;
-} LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body;
-
-typedef struct LDKHTLCFailChannelUpdate_LDKChannelClosed_Body {
-   /**
-    * The short_channel_id which has now closed.
-    */
-   uint64_t short_channel_id;
-   /**
-    * when this true, this channel should be permanently removed from the
-    * consideration. Otherwise, this channel can be restored as new channel_update is received
-    */
-   bool is_permanent;
-} LDKHTLCFailChannelUpdate_LDKChannelClosed_Body;
-
-typedef struct LDKHTLCFailChannelUpdate_LDKNodeFailure_Body {
-   /**
-    * The node_id that has failed.
-    */
-   struct LDKPublicKey node_id;
-   /**
-    * when this true, node should be permanently removed from the
-    * consideration. Otherwise, the channels connected to this node can be
-    * restored as new channel_update is received
-    */
-   bool is_permanent;
-} LDKHTLCFailChannelUpdate_LDKNodeFailure_Body;
-
-typedef struct MUST_USE_STRUCT LDKHTLCFailChannelUpdate {
-   LDKHTLCFailChannelUpdate_Tag tag;
-   union {
-      LDKHTLCFailChannelUpdate_LDKChannelUpdateMessage_Body channel_update_message;
-      LDKHTLCFailChannelUpdate_LDKChannelClosed_Body channel_closed;
-      LDKHTLCFailChannelUpdate_LDKNodeFailure_Body node_failure;
-   };
-} LDKHTLCFailChannelUpdate;
-
 
 
 /**
@@ -2578,11 +2674,6 @@ typedef enum LDKMessageSendEvent_Tag {
     * Broadcast an error downstream to be handled
     */
    LDKMessageSendEvent_HandleError,
-   /**
-    * When a payment fails we may receive updates back from the hop where it failed. In such
-    * cases this event is generated so that we can inform the network graph of this information.
-    */
-   LDKMessageSendEvent_PaymentFailureNetworkUpdate,
    /**
     * Query a peer for channels with funding transaction UTXOs in a block range.
     */
@@ -2771,13 +2862,6 @@ typedef struct LDKMessageSendEvent_LDKHandleError_Body {
    struct LDKErrorAction action;
 } LDKMessageSendEvent_LDKHandleError_Body;
 
-typedef struct LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body {
-   /**
-    * The channel/node update which should be sent to NetGraphMsgHandler
-    */
-   struct LDKHTLCFailChannelUpdate update;
-} LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body;
-
 typedef struct LDKMessageSendEvent_LDKSendChannelRangeQuery_Body {
    /**
     * The node_id of this message recipient
@@ -2830,7 +2914,6 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent {
       LDKMessageSendEvent_LDKBroadcastChannelUpdate_Body broadcast_channel_update;
       LDKMessageSendEvent_LDKSendChannelUpdate_Body send_channel_update;
       LDKMessageSendEvent_LDKHandleError_Body handle_error;
-      LDKMessageSendEvent_LDKPaymentFailureNetworkUpdate_Body payment_failure_network_update;
       LDKMessageSendEvent_LDKSendChannelRangeQuery_Body send_channel_range_query;
       LDKMessageSendEvent_LDKSendShortIdsQuery_Body send_short_ids_query;
       LDKMessageSendEvent_LDKSendReplyChannelRange_Body send_reply_channel_range;
@@ -3164,6 +3247,37 @@ typedef struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ {
    bool result_ok;
 } LDKCResult_SpendableOutputDescriptorDecodeErrorZ;
 
+/**
+ * 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_NoneNoneZPtr;
+
+/**
+ * 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_NoneNoneZ {
+   /**
+    * The contents of this CResult_NoneNoneZ, accessible via either
+    * `err` or `result` depending on the state of `result_ok`.
+    */
+   union LDKCResult_NoneNoneZPtr contents;
+   /**
+    * Whether this CResult_NoneNoneZ represents a success state.
+    */
+   bool result_ok;
+} LDKCResult_NoneNoneZ;
+
 /**
  * A tuple of 2 elements. See the individual fields for the types contained.
  */
@@ -3244,6 +3358,30 @@ typedef struct LDKCResult_SignatureNoneZ {
 
 
 
+/**
+ * This class tracks the per-transaction information needed to build a closing transaction and will
+ * actually build it and sign.
+ *
+ * This class can be used inside a signer implementation to generate a signature given the relevant
+ * secret key.
+ */
+typedef struct MUST_USE_STRUCT LDKClosingTransaction {
+   /**
+    * 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.
+    */
+   LDKnativeClosingTransaction *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;
+} LDKClosingTransaction;
+
+
+
 /**
  * The unsigned part of a channel_announcement
  */
@@ -3304,6 +3442,15 @@ typedef struct LDKBaseSign {
     * 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);
+   /**
+    * 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
+    * secret won't leave us without a broadcastable holder transaction.
+    * Policy checks should be implemented in this function, including checking the amount
+    * sent to us and checking the HTLCs.
+    */
+   struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx);
    /**
     * Gets the holder's channel public keys and basepoints
     */
@@ -3324,8 +3471,18 @@ typedef struct LDKBaseSign {
     * Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
     *
     * Note that if signing fails or is rejected, the channel will be force-closed.
+    *
+    * Policy checks should be implemented in this function, including checking the amount
+    * sent to us and checking the HTLCs.
     */
    struct LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ (*sign_counterparty_commitment)(const void *this_arg, const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx);
+   /**
+    * Validate the counterparty's revocation.
+    *
+    * This is required in order for the signer to make sure that the state has moved
+    * forward and it is safe to sign the next counterparty commitment.
+    */
+   struct LDKCResult_NoneNoneZ (*validate_counterparty_revocation)(const void *this_arg, uint64_t idx, const uint8_t (*secret)[32]);
    /**
     * Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
     * This will only ever be called with a non-revoked commitment_tx.  This will be called with the
@@ -3403,7 +3560,7 @@ typedef struct LDKBaseSign {
     * Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
     * chosen to forgo their output as dust.
     */
-   struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, struct LDKTransaction closing_tx);
+   struct LDKCResult_SignatureNoneZ (*sign_closing_transaction)(const void *this_arg, const struct LDKClosingTransaction *NONNULL_PTR closing_tx);
    /**
     * Signs a channel announcement message with our funding key, proving it comes from one
     * of the channel participants.
@@ -4742,37 +4899,127 @@ typedef struct LDKCResult_OutPointDecodeErrorZ {
 } LDKCResult_OutPointDecodeErrorZ;
 
 /**
- * The contents of CResult_SiPrefixNoneZ
+ * Defines a type identifier for sending messages over the wire.
+ *
+ * Messages implementing this trait specify a type and must be [`Writeable`].
  */
-typedef union LDKCResult_SiPrefixNoneZPtr {
+typedef struct LDKType {
    /**
-    * A pointer to the contents in the success state.
-    * Reading from this pointer when `result_ok` is not set is undefined.
+    * 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.
     */
-   enum LDKSiPrefix *result;
+   void *this_arg;
    /**
-    * Note that this value is always NULL, as there are no contents in the Err variant
+    * Returns the type identifying the message payload.
     */
-   void *err;
-} LDKCResult_SiPrefixNoneZPtr;
+   uint16_t (*type_id)(const void *this_arg);
+   /**
+    * Return a human-readable "debug" string describing this object
+    */
+   struct LDKStr (*debug_str)(const void *this_arg);
+   /**
+    * Serialize the object into a byte array
+    */
+   struct LDKCVec_u8Z (*write)(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);
+} LDKType;
 
 /**
- * A CResult_SiPrefixNoneZ represents the result of a fallible operation,
- * containing a crate::lightning_invoice::SiPrefix on success and a () on failure.
- * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ * An enum which can either contain a crate::lightning::ln::wire::Type or not
  */
-typedef struct LDKCResult_SiPrefixNoneZ {
+typedef enum LDKCOption_TypeZ_Tag {
    /**
-    * The contents of this CResult_SiPrefixNoneZ, accessible via either
-    * `err` or `result` depending on the state of `result_ok`.
+    * When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type
     */
-   union LDKCResult_SiPrefixNoneZPtr contents;
+   LDKCOption_TypeZ_Some,
    /**
-    * Whether this CResult_SiPrefixNoneZ represents a success state.
+    * When we're in this state, this COption_TypeZ contains nothing
     */
-   bool result_ok;
-} LDKCResult_SiPrefixNoneZ;
-
+   LDKCOption_TypeZ_None,
+   /**
+    * Must be last for serialization purposes
+    */
+   LDKCOption_TypeZ_Sentinel,
+} LDKCOption_TypeZ_Tag;
+
+typedef struct LDKCOption_TypeZ {
+   LDKCOption_TypeZ_Tag tag;
+   union {
+      struct {
+         struct LDKType some;
+      };
+   };
+} LDKCOption_TypeZ;
+
+/**
+ * The contents of CResult_COption_TypeZDecodeErrorZ
+ */
+typedef union LDKCResult_COption_TypeZDecodeErrorZPtr {
+   /**
+    * A pointer to the contents in the success state.
+    * Reading from this pointer when `result_ok` is not set is undefined.
+    */
+   struct LDKCOption_TypeZ *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_TypeZDecodeErrorZPtr;
+
+/**
+ * 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`.
+ */
+typedef struct LDKCResult_COption_TypeZDecodeErrorZ {
+   /**
+    * The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either
+    * `err` or `result` depending on the state of `result_ok`.
+    */
+   union LDKCResult_COption_TypeZDecodeErrorZPtr contents;
+   /**
+    * Whether this CResult_COption_TypeZDecodeErrorZ represents a success state.
+    */
+   bool result_ok;
+} LDKCResult_COption_TypeZDecodeErrorZ;
+
+/**
+ * The contents of CResult_SiPrefixNoneZ
+ */
+typedef union LDKCResult_SiPrefixNoneZPtr {
+   /**
+    * A pointer to the contents in the success state.
+    * Reading from this pointer when `result_ok` is not set is undefined.
+    */
+   enum LDKSiPrefix *result;
+   /**
+    * Note that this value is always NULL, as there are no contents in the Err variant
+    */
+   void *err;
+} LDKCResult_SiPrefixNoneZPtr;
+
+/**
+ * A CResult_SiPrefixNoneZ represents the result of a fallible operation,
+ * containing a crate::lightning_invoice::SiPrefix on success and a () on failure.
+ * `result_ok` indicates the overall state, and the contents are provided via `contents`.
+ */
+typedef struct LDKCResult_SiPrefixNoneZ {
+   /**
+    * The contents of this CResult_SiPrefixNoneZ, accessible via either
+    * `err` or `result` depending on the state of `result_ok`.
+    */
+   union LDKCResult_SiPrefixNoneZPtr contents;
+   /**
+    * Whether this CResult_SiPrefixNoneZ represents a success state.
+    */
+   bool result_ok;
+} LDKCResult_SiPrefixNoneZ;
+
 
 
 /**
@@ -5609,6 +5856,83 @@ typedef struct MUST_USE_STRUCT LDKPaymentPurpose {
    };
 } LDKPaymentPurpose;
 
+/**
+ * The reason the channel was closed. See individual variants 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,
+   /**
+    * Closure generated from processing an event, likely a HTLC forward/relay/reception.
+    */
+   LDKClosureReason_ProcessingError,
+   /**
+    * The `PeerManager` informed us that we've disconnected from the peer. We close channels
+    * if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
+    * peer again in the future or if the peer disconnected before we finished negotiating
+    * the channel open. The first case may be caused by incompatible features which our
+    * counterparty, or we, require.
+    */
+   LDKClosureReason_DisconnectedPeer,
+   /**
+    * Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
+    * the ChannelManager deserialized.
+    */
+   LDKClosureReason_OutdatedChannelManager,
+   /**
+    * Must be last for serialization purposes
+    */
+   LDKClosureReason_Sentinel,
+} LDKClosureReason_Tag;
+
+typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body {
+   /**
+    * The error which the peer sent us.
+    *
+    * 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 exploit
+    * a security vulnerability in the terminal emulator or the logging subsystem.
+    */
+   struct LDKStr 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 Event which you should probably take some action in response to.
  *
@@ -5639,15 +5963,18 @@ typedef enum LDKEvent_Tag {
     */
    LDKEvent_PaymentReceived,
    /**
-    * Indicates an outbound payment we made succeeded (ie it made it all the way to its target
+    * 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.
     */
    LDKEvent_PaymentSent,
    /**
     * Indicates an outbound payment we made failed. Probably some intermediary node dropped
     * something. You may wish to retry with a different route.
     */
-   LDKEvent_PaymentFailed,
+   LDKEvent_PaymentPathFailed,
    /**
     * Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
     * time in the future.
@@ -5666,6 +5993,10 @@ typedef enum LDKEvent_Tag {
     * forwarding fee earned.
     */
    LDKEvent_PaymentForwarded,
+   /**
+    * Used to indicate that a channel with the given `channel_id` is in the process of closure.
+    */
+   LDKEvent_ChannelClosed,
    /**
     * Must be last for serialization purposes
     */
@@ -5719,7 +6050,7 @@ typedef struct LDKEvent_LDKPaymentSent_Body {
    struct LDKThirtyTwoBytes payment_preimage;
 } LDKEvent_LDKPaymentSent_Body;
 
-typedef struct LDKEvent_LDKPaymentFailed_Body {
+typedef struct LDKEvent_LDKPaymentPathFailed_Body {
    /**
     * The hash which was given to ChannelManager::send_payment.
     */
@@ -5730,7 +6061,28 @@ typedef struct LDKEvent_LDKPaymentFailed_Body {
     * retry the payment via a different route.
     */
    bool rejected_by_dest;
-} LDKEvent_LDKPaymentFailed_Body;
+   /**
+    * Any failure information conveyed via the Onion return packet by a node along the failed
+    * payment route.
+    *
+    * Should be applied to the [`NetworkGraph`] so that routing decisions can take into
+    * account the update. [`NetGraphMsgHandler`] is capable of doing this.
+    *
+    * [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
+    * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
+    */
+   struct LDKCOption_NetworkUpdateZ network_update;
+   /**
+    * For both single-path and multi-path payments, this is set if all paths of the payment have
+    * failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
+    * larger MPP payment were still in flight when this event was generated.
+    */
+   bool all_paths_failed;
+   /**
+    * The payment path that failed.
+    */
+   struct LDKCVec_RouteHopZ path;
+} LDKEvent_LDKPaymentPathFailed_Body;
 
 typedef struct LDKEvent_LDKPendingHTLCsForwardable_Body {
    /**
@@ -5773,16 +6125,29 @@ typedef struct LDKEvent_LDKPaymentForwarded_Body {
    bool claim_from_onchain_tx;
 } LDKEvent_LDKPaymentForwarded_Body;
 
+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;
+   /**
+    * The reason the channel was closed.
+    */
+   struct LDKClosureReason reason;
+} LDKEvent_LDKChannelClosed_Body;
+
 typedef struct MUST_USE_STRUCT LDKEvent {
    LDKEvent_Tag tag;
    union {
       LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready;
       LDKEvent_LDKPaymentReceived_Body payment_received;
       LDKEvent_LDKPaymentSent_Body payment_sent;
-      LDKEvent_LDKPaymentFailed_Body payment_failed;
+      LDKEvent_LDKPaymentPathFailed_Body payment_path_failed;
       LDKEvent_LDKPendingHTLCsForwardable_Body pending_htl_cs_forwardable;
       LDKEvent_LDKSpendableOutputs_Body spendable_outputs;
       LDKEvent_LDKPaymentForwarded_Body payment_forwarded;
+      LDKEvent_LDKChannelClosed_Body channel_closed;
    };
 } LDKEvent;
 
@@ -5878,6 +6243,119 @@ typedef struct LDKCVec_TransactionOutputsZ {
    uintptr_t datalen;
 } LDKCVec_TransactionOutputsZ;
 
+/**
+ * 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
+ * be provided.
+ */
+typedef enum LDKBalance_Tag {
+   /**
+    * The channel is not yet closed (or the commitment or closing transaction has not yet
+    * appeared in a block). The given balance is claimable (less on-chain fees) if the channel is
+    * force-closed now.
+    */
+   LDKBalance_ClaimableOnChannelClose,
+   /**
+    * The channel has been closed, and the given balance is ours but awaiting confirmations until
+    * we consider it spendable.
+    */
+   LDKBalance_ClaimableAwaitingConfirmations,
+   /**
+    * 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
+    * possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain.
+    *
+    * Once the spending transaction confirms, before it has reached enough confirmations to be
+    * considered safe from chain reorganizations, the balance will instead be provided via
+    * [`Balance::ClaimableAwaitingConfirmations`].
+    */
+   LDKBalance_ContentiousClaimable,
+   /**
+    * HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
+    * fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
+    * likely to be claimed by our counterparty before we do.
+    */
+   LDKBalance_MaybeClaimableHTLCAwaitingTimeout,
+   /**
+    * Must be last for serialization purposes
+    */
+   LDKBalance_Sentinel,
+} LDKBalance_Tag;
+
+typedef struct LDKBalance_LDKClaimableOnChannelClose_Body {
+   /**
+    * The amount available to claim, in satoshis, excluding the on-chain fees which will be
+    * required to do so.
+    */
+   uint64_t claimable_amount_satoshis;
+} LDKBalance_LDKClaimableOnChannelClose_Body;
+
+typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body {
+   /**
+    * The amount available to claim, in satoshis, possibly excluding the on-chain fees which
+    * were spent in broadcasting the transaction.
+    */
+   uint64_t claimable_amount_satoshis;
+   /**
+    * The height at which an [`Event::SpendableOutputs`] event will be generated for this
+    * amount.
+    */
+   uint32_t confirmation_height;
+} LDKBalance_LDKClaimableAwaitingConfirmations_Body;
+
+typedef struct LDKBalance_LDKContentiousClaimable_Body {
+   /**
+    * The amount available to claim, in satoshis, excluding the on-chain fees which will be
+    * required to do so.
+    */
+   uint64_t claimable_amount_satoshis;
+   /**
+    * The height at which the counterparty may be able to claim the balance if we have not
+    * done so.
+    */
+   uint32_t timeout_height;
+} LDKBalance_LDKContentiousClaimable_Body;
+
+typedef struct LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body {
+   /**
+    * The amount available to claim, in satoshis, excluding the on-chain fees which will be
+    * required to do so.
+    */
+   uint64_t claimable_amount_satoshis;
+   /**
+    * The height at which we will be able to claim the balance if our counterparty has not
+    * done so.
+    */
+   uint32_t claimable_height;
+} LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body;
+
+typedef struct MUST_USE_STRUCT LDKBalance {
+   LDKBalance_Tag tag;
+   union {
+      LDKBalance_LDKClaimableOnChannelClose_Body claimable_on_channel_close;
+      LDKBalance_LDKClaimableAwaitingConfirmations_Body claimable_awaiting_confirmations;
+      LDKBalance_LDKContentiousClaimable_Body contentious_claimable;
+      LDKBalance_LDKMaybeClaimableHTLCAwaitingTimeout_Body maybe_claimable_htlc_awaiting_timeout;
+   };
+} LDKBalance;
+
+/**
+ * A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_BalanceZ {
+   /**
+    * The elements in the array.
+    * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+    */
+   struct LDKBalance *data;
+   /**
+    * The number of elements pointed to by `data`.
+    */
+   uintptr_t datalen;
+} LDKCVec_BalanceZ;
+
 /**
  * The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ
  */
@@ -5911,6 +6389,68 @@ typedef struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ {
    bool result_ok;
 } LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ;
 
+/**
+ * The contents of CResult_NoneLightningErrorZ
+ */
+typedef union LDKCResult_NoneLightningErrorZPtr {
+   /**
+    * 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 LDKLightningError *err;
+} LDKCResult_NoneLightningErrorZPtr;
+
+/**
+ * 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`.
+ */
+typedef struct LDKCResult_NoneLightningErrorZ {
+   /**
+    * The contents of this CResult_NoneLightningErrorZ, accessible via either
+    * `err` or `result` depending on the state of `result_ok`.
+    */
+   union LDKCResult_NoneLightningErrorZPtr contents;
+   /**
+    * Whether this CResult_NoneLightningErrorZ represents a success state.
+    */
+   bool result_ok;
+} LDKCResult_NoneLightningErrorZ;
+
+/**
+ * A tuple of 2 elements. See the individual fields for the types contained.
+ */
+typedef struct LDKC2Tuple_PublicKeyTypeZ {
+   /**
+    * The element at position 0
+    */
+   struct LDKPublicKey a;
+   /**
+    * The element at position 1
+    */
+   struct LDKType b;
+} LDKC2Tuple_PublicKeyTypeZ;
+
+/**
+ * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size.
+ * This corresponds to std::vector in C++
+ */
+typedef struct LDKCVec_C2Tuple_PublicKeyTypeZZ {
+   /**
+    * The elements in the array.
+    * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc().
+    */
+   struct LDKC2Tuple_PublicKeyTypeZ *data;
+   /**
+    * The number of elements pointed to by `data`.
+    */
+   uintptr_t datalen;
+} LDKCVec_C2Tuple_PublicKeyTypeZZ;
+
 /**
  * The contents of CResult_boolLightningErrorZ
  */
@@ -5994,38 +6534,6 @@ typedef struct LDKCVec_NodeAnnouncementZ {
    uintptr_t datalen;
 } LDKCVec_NodeAnnouncementZ;
 
-/**
- * The contents of CResult_NoneLightningErrorZ
- */
-typedef union LDKCResult_NoneLightningErrorZPtr {
-   /**
-    * 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 LDKLightningError *err;
-} LDKCResult_NoneLightningErrorZPtr;
-
-/**
- * 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`.
- */
-typedef struct LDKCResult_NoneLightningErrorZ {
-   /**
-    * The contents of this CResult_NoneLightningErrorZ, accessible via either
-    * `err` or `result` depending on the state of `result_ok`.
-    */
-   union LDKCResult_NoneLightningErrorZPtr contents;
-   /**
-    * Whether this CResult_NoneLightningErrorZ represents a success state.
-    */
-   bool result_ok;
-} LDKCResult_NoneLightningErrorZ;
-
 /**
  * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size.
  * This corresponds to std::vector in C++
@@ -6162,6 +6670,58 @@ typedef struct LDKCResult_boolPeerHandleErrorZ {
    bool result_ok;
 } LDKCResult_boolPeerHandleErrorZ;
 
+/**
+ * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
+ * UTXOs.
+ */
+typedef struct LDKAccess {
+   /**
+    * 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 transaction output of a funding transaction encoded by [`short_channel_id`].
+    * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
+    * is unknown.
+    *
+    * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
+    */
+   struct LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], 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);
+} LDKAccess;
+
+/**
+ * An enum which can either contain a crate::lightning::chain::Access or not
+ */
+typedef enum LDKCOption_AccessZ_Tag {
+   /**
+    * When we're in this state, this COption_AccessZ contains a crate::lightning::chain::Access
+    */
+   LDKCOption_AccessZ_Some,
+   /**
+    * When we're in this state, this COption_AccessZ contains nothing
+    */
+   LDKCOption_AccessZ_None,
+   /**
+    * Must be last for serialization purposes
+    */
+   LDKCOption_AccessZ_Sentinel,
+} LDKCOption_AccessZ_Tag;
+
+typedef struct LDKCOption_AccessZ {
+   LDKCOption_AccessZ_Tag tag;
+   union {
+      struct {
+         struct LDKAccess some;
+      };
+   };
+} LDKCOption_AccessZ;
+
 
 
 /**
@@ -8065,6 +8625,115 @@ typedef struct LDKCResult_InvoiceSignOrCreationErrorZ {
    bool result_ok;
 } LDKCResult_InvoiceSignOrCreationErrorZ;
 
+
+
+/**
+ * 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
+ * the return value of [`Filter::register_output`].
+ *
+ * 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 [`TemporaryFailure`].
+ *
+ * [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure
+ * [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.
+    *
+    * Optionally, when `output.block_hash` is set, should return any transaction spending the
+    * output that is found in the corresponding block along with its index.
+    *
+    * This return value is useful for Electrum clients in order to supply in-block descendant
+    * transactions which otherwise were not included. This is not necessary for other clients if
+    * such descendant transactions were already included (e.g., when a BIP 157 client provides the
+    * full block).
+    */
+   struct LDKCOption_C2Tuple_usizeTransactionZZ (*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 trait indicating an object may generate message send events
  */
@@ -8100,7 +8769,7 @@ typedef struct LDKEventHandler {
     *
     * See [`EventsProvider`] for details that must be considered when implementing this method.
     */
-   void (*handle_event)(const void *this_arg, struct LDKEvent event);
+   void (*handle_event)(const void *this_arg, const struct LDKEvent *NONNULL_PTR 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.
@@ -8242,38 +8911,13 @@ typedef struct MUST_USE_STRUCT LDKBestBlock {
     * 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 `Access` trait defines behavior for accessing chain data and state, such as blocks and
- * UTXOs.
- */
-typedef struct LDKAccess {
-   /**
-    * 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 transaction output of a funding transaction encoded by [`short_channel_id`].
-    * Returns an error if `genesis_hash` is for a different chain or if such a transaction output
-    * is unknown.
-    *
-    * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
-    */
-   struct LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], 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.
+   /**
+    * 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.
     */
-   void (*free)(void *this_arg);
-} LDKAccess;
+   bool is_owned;
+} LDKBestBlock;
 
 /**
  * The `Listen` trait is used to notify when blocks have been connected or disconnected from the
@@ -8402,88 +9046,6 @@ typedef struct LDKConfirm {
    void (*free)(void *this_arg);
 } LDKConfirm;
 
-
-
-/**
- * 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
- * the return value of [`Filter::register_output`].
- *
- * 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 [`TemporaryFailure`].
- *
- * [`TemporaryFailure`]: channelmonitor::ChannelMonitorUpdateErr::TemporaryFailure
- * [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.
-    *
-    * Optionally, when `output.block_hash` is set, should return any transaction spending the
-    * output that is found in the corresponding block along with its index.
-    *
-    * This return value is useful for Electrum clients in order to supply in-block descendant
-    * transactions which otherwise were not included. This is not necessary for other clients if
-    * such descendant transactions were already included (e.g., when a BIP 157 client provides the
-    * full block).
-    */
-   struct LDKCOption_C2Tuple_usizeTransactionZZ (*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;
-
 /**
  * `Persist` defines behavior for persisting channel monitors: this could mean
  * writing once to disk, and/or uploading to one or more backup services.
@@ -8626,6 +9188,26 @@ typedef struct MUST_USE_STRUCT LDKChainParameters {
 
 
 
+/**
+ * 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;
+
+
+
 /**
  * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`]
  * to better separate parameters.
@@ -8858,10 +9440,6 @@ typedef struct LDKRoutingMessageHandler {
     * false or returning an Err otherwise.
     */
    struct LDKCResult_boolLightningErrorZ (*handle_channel_update)(const void *this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg);
-   /**
-    * Handle some updates to the route graph that we learned due to an outbound failed payment.
-    */
-   void (*handle_htlc_fail_channel_update)(const void *this_arg, const struct LDKHTLCFailChannelUpdate *NONNULL_PTR update);
    /**
     * Gets a subset of the channel announcements and updates required to dump our routing table
     * to a remote node, starting at the short_channel_id indicated by starting_point and
@@ -8917,6 +9495,62 @@ typedef struct LDKRoutingMessageHandler {
    void (*free)(void *this_arg);
 } LDKRoutingMessageHandler;
 
+/**
+ * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers)
+ * decoders.
+ */
+typedef struct LDKCustomMessageReader {
+   /**
+    * 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;
+   /**
+    * Decodes a custom message to `CustomMessageType`. If the given message type is known to the
+    * implementation and the message could be decoded, must return `Ok(Some(message))`. If the
+    * message type is unknown to the implementation, must return `Ok(None)`. If a decoding error
+    * occur, must return `Err(DecodeError::X)` where `X` details the encountered error.
+    */
+   struct LDKCResult_COption_TypeZDecodeErrorZ (*read)(const void *this_arg, uint16_t message_type, struct LDKu8slice buffer);
+   /**
+    * 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);
+} LDKCustomMessageReader;
+
+/**
+ * Handler for BOLT1-compliant messages.
+ */
+typedef struct LDKCustomMessageHandler {
+   /**
+    * 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;
+   /**
+    * Called with the message type that was received and the buffer to be read.
+    * Can return a `MessageHandlingError` if the message could not be handled.
+    */
+   struct LDKCResult_NoneLightningErrorZ (*handle_custom_message)(const void *this_arg, struct LDKType msg, struct LDKPublicKey sender_node_id);
+   /**
+    * Gets the list of pending messages which were generated by the custom message
+    * handler, clearing the list in the process. The first tuple element must
+    * correspond to the intended recipients node ids. If no connection to one of the
+    * specified node does not exist, the message is simply not sent to it.
+    */
+   struct LDKCVec_C2Tuple_PublicKeyTypeZZ (*get_and_clear_pending_msg)(const void *this_arg);
+   /**
+    * Implementation of CustomMessageReader for this object.
+    */
+   struct LDKCustomMessageReader CustomMessageReader;
+   /**
+    * 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);
+} LDKCustomMessageHandler;
+
 
 
 /**
@@ -9133,24 +9767,22 @@ typedef struct MUST_USE_STRUCT LDKRouteHintHop {
 
 
 /**
- * A simple newtype for RwLockReadGuard<'a, NetworkGraph>.
- * This exists only to make accessing a RwLock<NetworkGraph> possible from
- * the C bindings, as it can be done directly in Rust code.
+ * A read-only view of [`NetworkGraph`].
  */
-typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph {
+typedef struct MUST_USE_STRUCT LDKReadOnlyNetworkGraph {
    /**
     * 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.
     */
-   LDKnativeLockedNetworkGraph *inner;
+   LDKnativeReadOnlyNetworkGraph *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;
-} LDKLockedNetworkGraph;
+} LDKReadOnlyNetworkGraph;
 
 
 
@@ -9160,6 +9792,9 @@ typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph {
  * This network graph is then used for routing payments.
  * Provides interface to help with initial routing sync by
  * serving historical announcements.
+ *
+ * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
+ * [`NetworkGraph`].
  */
 typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler {
    /**
@@ -9210,20 +9845,28 @@ typedef struct MUST_USE_STRUCT LDKFilesystemPersister {
 
 
 /**
- * BackgroundProcessor takes care of tasks that (1) need to happen periodically to keep
+ * `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep
  * Rust-Lightning running properly, and (2) either can or should be run in the background. Its
  * responsibilities are:
- * * Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so,
+ * * Processing [`Event`]s with a user-provided [`EventHandler`].
+ * * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so,
  *   writing it to disk/backups by invoking the callback given to it at startup.
- *   ChannelManager persistence should be done in the background.
- * * Calling `ChannelManager::timer_tick_occurred()` and
- *   `PeerManager::timer_tick_occurred()` every minute (can be done in the
- *   background).
- *
- * Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date,
- * then there is a risk of channels force-closing on startup when the manager realizes it's
- * outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used
- * for unilateral chain closure fees are at risk.
+ *   [`ChannelManager`] persistence should be done in the background.
+ * * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
+ *   at the appropriate intervals.
+ *
+ * It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied
+ * upon as doing so may result in high latency.
+ *
+ * # Note
+ *
+ * If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then
+ * there is a risk of channels force-closing on startup when the manager realizes it's outdated.
+ * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for
+ * unilateral chain closure fees are at risk.
+ *
+ * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor
+ * [`Event`]: lightning::util::events::Event
  *BackgroundProcessor will immediately stop on drop. It should be stored until shutdown.
  */
 typedef struct MUST_USE_STRUCT LDKBackgroundProcessor {
@@ -9673,6 +10316,21 @@ void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_Built
  */
 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);
+
+/**
+ * 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.
  */
@@ -9985,6 +10643,27 @@ void COption_C2Tuple_usizeTransactionZZ_free(struct LDKCOption_C2Tuple_usizeTran
  */
 struct LDKCOption_C2Tuple_usizeTransactionZZ COption_C2Tuple_usizeTransactionZZ_clone(const struct LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR orig);
 
+/**
+ * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::network_graph::NetworkUpdate
+ */
+struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_some(struct LDKNetworkUpdate o);
+
+/**
+ * Constructs a new COption_NetworkUpdateZ containing nothing
+ */
+struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::routing::network_graph::NetworkUpdate, if we are in the Some state
+ */
+void COption_NetworkUpdateZ_free(struct LDKCOption_NetworkUpdateZ _res);
+
+/**
+ * Creates a new COption_NetworkUpdateZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCOption_NetworkUpdateZ COption_NetworkUpdateZ_clone(const struct LDKCOption_NetworkUpdateZ *NONNULL_PTR orig);
+
 /**
  * Frees the buffer pointed to by `data` if `datalen` is non-0.
  */
@@ -10118,6 +10797,27 @@ void CResult_SpendableOutputDescriptorDecodeErrorZ_free(struct LDKCResult_Spenda
  */
 struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ CResult_SpendableOutputDescriptorDecodeErrorZ_clone(const struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ *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);
+
+/**
+ * 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);
+
 /**
  * Creates a new tuple which has the same data as `orig`
  * but with all dynamically-allocated buffers duplicated in new buffers.
@@ -10534,6 +11234,36 @@ void CResult_OutPointDecodeErrorZ_free(struct LDKCResult_OutPointDecodeErrorZ _r
  */
 struct LDKCResult_OutPointDecodeErrorZ CResult_OutPointDecodeErrorZ_clone(const struct LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR orig);
 
+/**
+ * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type
+ */
+struct LDKCOption_TypeZ COption_TypeZ_some(struct LDKType o);
+
+/**
+ * Constructs a new COption_TypeZ containing nothing
+ */
+struct LDKCOption_TypeZ COption_TypeZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::ln::wire::Type, if we are in the Some state
+ */
+void COption_TypeZ_free(struct LDKCOption_TypeZ _res);
+
+/**
+ * Creates a new CResult_COption_TypeZDecodeErrorZ in the success state.
+ */
+struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_ok(struct LDKCOption_TypeZ o);
+
+/**
+ * Creates a new CResult_COption_TypeZDecodeErrorZ in the error state.
+ */
+struct LDKCResult_COption_TypeZDecodeErrorZ CResult_COption_TypeZDecodeErrorZ_err(struct LDKDecodeError e);
+
+/**
+ * Frees any resources used by the CResult_COption_TypeZDecodeErrorZ.
+ */
+void CResult_COption_TypeZDecodeErrorZ_free(struct LDKCResult_COption_TypeZDecodeErrorZ _res);
+
 /**
  * Creates a new CResult_SiPrefixNoneZ in the success state.
  */
@@ -10953,6 +11683,11 @@ void C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(struct LDKC2Tuple_TxidCVec_C2Tupl
  */
 void CVec_TransactionOutputsZ_free(struct LDKCVec_TransactionOutputsZ _res);
 
+/**
+ * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ */
+void CVec_BalanceZ_free(struct LDKCVec_BalanceZ _res);
+
 /**
  * Creates a new CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ in the success state.
  */
@@ -10968,6 +11703,42 @@ struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ CResult_C2Tuple_B
  */
 void CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res);
 
+/**
+ * Creates a new CResult_NoneLightningErrorZ in the success state.
+ */
+struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void);
+
+/**
+ * Creates a new CResult_NoneLightningErrorZ in the error state.
+ */
+struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e);
+
+/**
+ * Frees any resources used by the CResult_NoneLightningErrorZ.
+ */
+void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res);
+
+/**
+ * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig`
+ * but with all dynamically-allocated buffers duplicated in new buffers.
+ */
+struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig);
+
+/**
+ * Creates a new C2Tuple_PublicKeyTypeZ from the contained elements.
+ */
+struct LDKC2Tuple_PublicKeyTypeZ C2Tuple_PublicKeyTypeZ_new(struct LDKPublicKey a, struct LDKType b);
+
+/**
+ * Frees any resources used by the C2Tuple_PublicKeyTypeZ.
+ */
+void C2Tuple_PublicKeyTypeZ_free(struct LDKC2Tuple_PublicKeyTypeZ _res);
+
+/**
+ * Frees the buffer pointed to by `data` if `datalen` is non-0.
+ */
+void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _res);
+
 /**
  * Creates a new CResult_boolLightningErrorZ in the success state.
  */
@@ -11015,27 +11786,6 @@ void CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(struct LD
  */
 void CVec_NodeAnnouncementZ_free(struct LDKCVec_NodeAnnouncementZ _res);
 
-/**
- * Creates a new CResult_NoneLightningErrorZ in the success state.
- */
-struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_ok(void);
-
-/**
- * Creates a new CResult_NoneLightningErrorZ in the error state.
- */
-struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_err(struct LDKLightningError e);
-
-/**
- * Frees any resources used by the CResult_NoneLightningErrorZ.
- */
-void CResult_NoneLightningErrorZ_free(struct LDKCResult_NoneLightningErrorZ _res);
-
-/**
- * Creates a new CResult_NoneLightningErrorZ which has the same data as `orig`
- * but with all dynamically-allocated buffers duplicated in new buffers.
- */
-struct LDKCResult_NoneLightningErrorZ CResult_NoneLightningErrorZ_clone(const struct LDKCResult_NoneLightningErrorZ *NONNULL_PTR orig);
-
 /**
  * Frees the buffer pointed to by `data` if `datalen` is non-0.
  */
@@ -11104,6 +11854,21 @@ void CResult_boolPeerHandleErrorZ_free(struct LDKCResult_boolPeerHandleErrorZ _r
  */
 struct LDKCResult_boolPeerHandleErrorZ CResult_boolPeerHandleErrorZ_clone(const struct LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR orig);
 
+/**
+ * Constructs a new COption_AccessZ containing a crate::lightning::chain::Access
+ */
+struct LDKCOption_AccessZ COption_AccessZ_some(struct LDKAccess o);
+
+/**
+ * Constructs a new COption_AccessZ containing nothing
+ */
+struct LDKCOption_AccessZ COption_AccessZ_none(void);
+
+/**
+ * Frees any resources associated with the crate::lightning::chain::Access, if we are in the Some state
+ */
+void COption_AccessZ_free(struct LDKCOption_AccessZ _res);
+
 /**
  * Creates a new CResult_DirectionalChannelInfoDecodeErrorZ in the success state.
  */
@@ -11229,12 +11994,6 @@ struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_err(
  */
 void CResult_NetworkGraphDecodeErrorZ_free(struct LDKCResult_NetworkGraphDecodeErrorZ _res);
 
-/**
- * Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig`
- * but with all dynamically-allocated buffers duplicated in new buffers.
- */
-struct LDKCResult_NetworkGraphDecodeErrorZ CResult_NetworkGraphDecodeErrorZ_clone(const struct LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR orig);
-
 /**
  * Creates a new CResult_NetAddressu8Z in the success state.
  */
@@ -12011,6 +12770,21 @@ void CResult_InvoiceSignOrCreationErrorZ_free(struct LDKCResult_InvoiceSignOrCre
  */
 struct LDKCResult_InvoiceSignOrCreationErrorZ CResult_InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_InvoiceSignOrCreationErrorZ *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 any resources used by the PaymentPurpose
  */
@@ -12031,6 +12805,56 @@ struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKThirtyTwoBytes
  */
 struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a);
 
+/**
+ * Frees any resources used by the ClosureReason
+ */
+void ClosureReason_free(struct LDKClosureReason this_ptr);
+
+/**
+ * Creates a copy of the ClosureReason
+ */
+struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig);
+
+/**
+ * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
+ */
+struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKStr peer_msg);
+
+/**
+ * Utility method to constructs a new HolderForceClosed-variant ClosureReason
+ */
+struct LDKClosureReason ClosureReason_holder_force_closed(void);
+
+/**
+ * Utility method to constructs a new CooperativeClosure-variant ClosureReason
+ */
+struct LDKClosureReason ClosureReason_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 ProcessingError-variant ClosureReason
+ */
+struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err);
+
+/**
+ * Utility method to constructs a new DisconnectedPeer-variant ClosureReason
+ */
+struct LDKClosureReason ClosureReason_disconnected_peer(void);
+
+/**
+ * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
+ */
+struct LDKClosureReason ClosureReason_outdated_channel_manager(void);
+
+/**
+ * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
+ */
+struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj);
+
 /**
  * Frees any resources used by the Event
  */
@@ -12057,9 +12881,9 @@ struct LDKEvent Event_payment_received(struct LDKThirtyTwoBytes payment_hash, ui
 struct LDKEvent Event_payment_sent(struct LDKThirtyTwoBytes payment_preimage);
 
 /**
- * Utility method to constructs a new PaymentFailed-variant Event
+ * Utility method to constructs a new PaymentPathFailed-variant Event
  */
-struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest);
+struct LDKEvent Event_payment_path_failed(struct LDKThirtyTwoBytes payment_hash, bool rejected_by_dest, struct LDKCOption_NetworkUpdateZ network_update, bool all_paths_failed, struct LDKCVec_RouteHopZ path);
 
 /**
  * Utility method to constructs a new PendingHTLCsForwardable-variant Event
@@ -12076,6 +12900,11 @@ struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptor
  */
 struct LDKEvent Event_payment_forwarded(struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx);
 
+/**
+ * Utility method to constructs a new ChannelClosed-variant Event
+ */
+struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, struct LDKClosureReason reason);
+
 /**
  * Serialize the Event object into a byte array which can be read by Event_read
  */
@@ -12171,11 +13000,6 @@ struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublic
  */
 struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action);
 
-/**
- * Utility method to constructs a new PaymentFailureNetworkUpdate-variant MessageSendEvent
- */
-struct LDKMessageSendEvent MessageSendEvent_payment_failure_network_update(struct LDKHTLCFailChannelUpdate update);
-
 /**
  * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
  */
@@ -13123,10 +13947,21 @@ void ChainMonitor_free(struct LDKChainMonitor this_obj);
  * pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may
  * always need to fetch full blocks absent another means for determining which blocks contain
  * transactions relevant to the watched channels.
+ */
+MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister);
+
+/**
+ * Gets the balances in the contained [`ChannelMonitor`]s which are claimable on-chain or
+ * 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`]).
  *
- * Note that chain_source (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for
+ * inclusion in the return value.
  */
-MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKFilter *chain_source, struct LDKBroadcasterInterface broadcaster, struct LDKLogger logger, struct LDKFeeEstimator feeest, struct LDKPersist persister);
+MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKCVec_ChannelDetailsZ ignored_channels);
 
 /**
  * Constructs a new Listen which calls the relevant methods on this_arg.
@@ -13243,9 +14078,9 @@ struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_
 struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a);
 
 /**
- * Utility method to constructs a new CommitmentTxBroadcasted-variant MonitorEvent
+ * Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent
  */
-struct LDKMonitorEvent MonitorEvent_commitment_tx_broadcasted(struct LDKOutPoint a);
+struct LDKMonitorEvent MonitorEvent_commitment_tx_confirmed(struct LDKOutPoint a);
 
 /**
  * Frees any resources used by the HTLCUpdate, if is_owned is set and inner is non-NULL.
@@ -13267,6 +14102,42 @@ struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj)
  */
 struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser);
 
+/**
+ * Frees any resources used by the Balance
+ */
+void Balance_free(struct LDKBalance this_ptr);
+
+/**
+ * Creates a copy of the Balance
+ */
+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 claimable_amount_satoshis);
+
+/**
+ * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance
+ */
+struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t claimable_amount_satoshis, uint32_t confirmation_height);
+
+/**
+ * Utility method to constructs a new ContentiousClaimable-variant Balance
+ */
+struct LDKBalance Balance_contentious_claimable(uint64_t claimable_amount_satoshis, uint32_t timeout_height);
+
+/**
+ * Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance
+ */
+struct LDKBalance Balance_maybe_claimable_htlcawaiting_timeout(uint64_t claimable_amount_satoshis, uint32_t claimable_height);
+
+/**
+ * Checks if two Balances contain equal inner contents.
+ * This ignores pointers and is_owned flags and looks at the values in fields.
+ */
+bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b);
+
 /**
  * Frees any resources used by the ChannelMonitor, if is_owned is set and inner is non-NULL.
  */
@@ -13402,6 +14273,24 @@ MUST_USE_RES struct LDKCVec_TxidZ ChannelMonitor_get_relevant_txids(const struct
  */
 MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg);
 
+/**
+ * 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).
+ *
+ * Any balances in the channel which are available on-chain (excluding on-chain fees) are
+ * included here until an [`Event::SpendableOutputs`] event has been generated for the
+ * balance, or until our counterparty has claimed the balance and accrued several
+ * confirmations on the claim transaction.
+ *
+ * Note that the balances available when you or your counterparty have broadcasted revoked
+ * state(s) may not be fully captured here.
+ *
+ * See [`Balance`] for additional details on the types of claimable balances which
+ * may be returned here and their meanings.
+ */
+MUST_USE_RES struct LDKCVec_BalanceZ ChannelMonitor_get_claimable_balances(const struct LDKChannelMonitor *NONNULL_PTR this_arg);
+
 /**
  * Calls the free function if one is set
  */
@@ -13951,6 +14840,55 @@ 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.
+ */
+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);
+
 /**
  * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL.
  */
@@ -14002,6 +14940,27 @@ uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDK
  */
 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);
+
+/**
+ * Constructs a new ChannelCounterparty given each field
+ */
+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);
+
 /**
  * Creates a copy of the ChannelCounterparty
  */
@@ -15365,12 +16324,12 @@ uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated
 void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val);
 
 /**
- * The signature of the channel initiator (funder) on the funding transaction
+ * The signature of the channel initiator (funder) on the initial commitment transaction
  */
 struct LDKSignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr);
 
 /**
- * The signature of the channel initiator (funder) on the funding transaction
+ * The signature of the channel initiator (funder) on the initial commitment transaction
  */
 void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKSignature val);
 
@@ -15400,12 +16359,12 @@ const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONN
 void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
 
 /**
- * The signature of the channel acceptor (fundee) on the funding transaction
+ * The signature of the channel acceptor (fundee) on the initial commitment transaction
  */
 struct LDKSignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr);
 
 /**
- * The signature of the channel acceptor (fundee) on the funding transaction
+ * The signature of the channel acceptor (fundee) on the initial commitment transaction
  */
 void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKSignature val);
 
@@ -16738,21 +17697,41 @@ struct LDKLightningError LightningError_clone(const struct LDKLightningError *NO
  */
 void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj);
 
+/**
+ * update_add_htlc messages which should be sent
+ */
+struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr);
+
 /**
  * update_add_htlc messages which should be sent
  */
 void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val);
 
+/**
+ * update_fulfill_htlc messages which should be sent
+ */
+struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr);
+
 /**
  * update_fulfill_htlc messages which should be sent
  */
 void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val);
 
+/**
+ * update_fail_htlc messages which should be sent
+ */
+struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr);
+
 /**
  * update_fail_htlc messages which should be sent
  */
 void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val);
 
+/**
+ * update_fail_malformed_htlc messages which should be sent
+ */
+struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr);
+
 /**
  * update_fail_malformed_htlc messages which should be sent
  */
@@ -16792,31 +17771,6 @@ MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_Upda
  */
 struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig);
 
-/**
- * Frees any resources used by the HTLCFailChannelUpdate
- */
-void HTLCFailChannelUpdate_free(struct LDKHTLCFailChannelUpdate this_ptr);
-
-/**
- * Creates a copy of the HTLCFailChannelUpdate
- */
-struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_clone(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR orig);
-
-/**
- * Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate
- */
-struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_update_message(struct LDKChannelUpdate msg);
-
-/**
- * Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate
- */
-struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent);
-
-/**
- * Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate
- */
-struct LDKHTLCFailChannelUpdate HTLCFailChannelUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent);
-
 /**
  * Calls the free function if one is set
  */
@@ -17108,14 +18062,14 @@ struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(str
 struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj);
 
 /**
- * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
+ * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
  */
-struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser);
+struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj);
 
 /**
- * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
+ * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
  */
-struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj);
+struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser);
 
 /**
  *\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t
@@ -17123,14 +18077,14 @@ struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChann
 MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg);
 
 /**
- * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
+ * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
  */
-struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser);
+struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj);
 
 /**
- * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
+ * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
  */
-struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj);
+struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser);
 
 /**
  * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
@@ -17142,15 +18096,20 @@ struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LD
  */
 struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj);
 
+/**
+ * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
+ */
+struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj);
+
 /**
  * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
  */
 struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser);
 
 /**
- * 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 CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr);
 
 /**
  * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL.
@@ -17174,6 +18133,18 @@ struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsP
  */
 struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *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
+ */
+struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *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
+ */
+struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg);
+
 /**
  * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL.
  */
@@ -17287,7 +18258,7 @@ void PeerManager_free(struct LDKPeerManager this_obj);
  * ephemeral_random_data is used to derive per-connection ephemeral keys and must be
  * cryptographically secure random bytes.
  */
-MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger);
+MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, struct LDKSecretKey our_node_secret, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKCustomMessageHandler custom_message_handler);
 
 /**
  * Get the list of node ids for peers which have completed the initial handshake.
@@ -17369,6 +18340,9 @@ MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const
  * 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.
+ *
  * [`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
@@ -17413,6 +18387,11 @@ void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR th
  */
 struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx);
 
+/**
+ * Build a closing transaction
+ */
+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);
+
 /**
  * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
  * from the base secret and the per_commitment_point.
@@ -18010,48 +18989,121 @@ void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransac
  * This is provided as a performance optimization, instead of calling transaction.txid()
  * multiple times.
  */
-const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32];
+const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32];
+
+/**
+ * The txid for the commitment transaction.
+ *
+ * This is provided as a performance optimization, instead of calling transaction.txid()
+ * multiple times.
+ */
+void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
+
+/**
+ * Constructs a new BuiltCommitmentTransaction given each field
+ */
+MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg);
+
+/**
+ * Creates a copy of the BuiltCommitmentTransaction
+ */
+struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig);
+
+/**
+ * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
+ */
+struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj);
+
+/**
+ * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
+ */
+struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser);
+
+/**
+ * Get the SIGHASH_ALL sighash value of the transaction.
+ *
+ * This can be used to verify a signature.
+ */
+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);
+
+/**
+ * Sign a transaction, either because we are counter-signing the counterparty's transaction or
+ * because we are about to broadcast a holder transaction.
+ */
+MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis);
+
+/**
+ * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL.
+ */
+void ClosingTransaction_free(struct LDKClosingTransaction this_obj);
+
+/**
+ * Construct an object of the class
+ */
+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);
+
+/**
+ * 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.
+ */
+MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg);
+
+/**
+ * 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.
+ */
+MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint);
+
+/**
+ * The value to be sent to the holder, or zero if the output will be omitted
+ */
+MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg);
 
 /**
- * The txid for the commitment transaction.
- *
- * This is provided as a performance optimization, instead of calling transaction.txid()
- * multiple times.
+ * The value to be sent to the counterparty, or zero if the output will be omitted
  */
-void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val);
+MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg);
 
 /**
- * Constructs a new BuiltCommitmentTransaction given each field
+ * The destination of the holder's output
  */
-MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg);
+MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg);
 
 /**
- * Creates a copy of the BuiltCommitmentTransaction
+ * The destination of the counterparty's output
  */
-struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig);
+MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg);
 
 /**
- * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
+ * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL.
  */
-struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj);
+void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj);
 
 /**
- * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
+ * The pre-built Bitcoin commitment transaction
  */
-struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser);
+MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg);
 
 /**
  * Get the SIGHASH_ALL sighash value of the transaction.
  *
  * This can be used to verify a signature.
  */
-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);
+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);
 
 /**
  * Sign a transaction, either because we are counter-signing the counterparty's transaction or
  * because we are about to broadcast a holder transaction.
  */
-MUST_USE_RES struct LDKSignature BuiltCommitmentTransaction_sign(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis);
+MUST_USE_RES struct LDKSignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis);
 
 /**
  * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL.
@@ -18099,7 +19151,7 @@ MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommi
  * 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
- *\tbe used by an external signer - instead use the verify function.
+ * be used by an external signer - instead use the verify function.
  */
 MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg);
 
@@ -18229,6 +19281,12 @@ MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void);
  */
 MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void);
 
+/**
+ * Returns true if this `Features` object contains unknown feature flags which are set as
+ * \"required\".
+ */
+MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg);
+
 /**
  * Create a blank Features with no features set
  */
@@ -18239,6 +19297,12 @@ MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void);
  */
 MUST_USE_RES struct LDKNodeFeatures NodeFeatures_known(void);
 
+/**
+ * Returns true if this `Features` object contains unknown feature flags which are set as
+ * \"required\".
+ */
+MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg);
+
 /**
  * Create a blank Features with no features set
  */
@@ -18249,6 +19313,12 @@ MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void);
  */
 MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void);
 
+/**
+ * Returns true if this `Features` object contains unknown feature flags which are set as
+ * \"required\".
+ */
+MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg);
+
 /**
  * Create a blank Features with no features set
  */
@@ -18259,6 +19329,12 @@ MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void);
  */
 MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void);
 
+/**
+ * Returns true if this `Features` object contains unknown feature flags which are set as
+ * \"required\".
+ */
+MUST_USE_RES bool InvoiceFeatures_requires_unknown_bits(const struct LDKInvoiceFeatures *NONNULL_PTR this_arg);
+
 /**
  * Returns whether the `payment_secret` feature is supported.
  */
@@ -18409,6 +19485,16 @@ MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LD
  */
 MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features);
 
+/**
+ * Calls the free function if one is set
+ */
+void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void Type_free(struct LDKType this_ptr);
+
 /**
  * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL.
  */
@@ -18494,6 +19580,18 @@ MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, str
  */
 struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig);
 
+/**
+ * Checks if two RouteHops contain equal inner contents.
+ */
+uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o);
+
+/**
+ * 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.
+ */
+bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b);
+
 /**
  * Serialize the RouteHop object into a byte array which can be read by RouteHop_read
  */
@@ -18509,6 +19607,16 @@ struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser);
  */
 void Route_free(struct LDKRoute this_obj);
 
+/**
+ * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
+ * last RouteHop in each path must be the same.
+ * Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the
+ * destination. Thus, this must always be at least length one. While the maximum length of any
+ * given path is variable, keeping the length of any path to less than 20 should currently
+ * ensure it is viable.
+ */
+struct LDKCVec_CVec_RouteHopZZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr);
+
 /**
  * The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
  * last RouteHop in each path must be the same.
@@ -18529,6 +19637,31 @@ MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_CVec_RouteHopZZ paths_arg)
  */
 struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig);
 
+/**
+ * Checks if two Routes contain equal inner contents.
+ */
+uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o);
+
+/**
+ * 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.
+ */
+bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b);
+
+/**
+ * Returns the total amount of fees paid on this [`Route`].
+ *
+ * This doesn't include any extra payment made to the recipient, which can happen in excess of
+ * the amount passed to [`get_route`]'s `final_value_msat`.
+ */
+MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg);
+
+/**
+ * Returns the total amount paid on this [`Route`], excluding the fees.
+ */
+MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg);
+
 /**
  * Serialize the Route object into a byte array which can be read by Route_read
  */
@@ -18544,17 +19677,22 @@ struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser);
  */
 void RouteHint_free(struct LDKRouteHint this_obj);
 
+/**
+ * Creates a copy of the RouteHint
+ */
+struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig);
+
 /**
  * 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 RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b);
+uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o);
 
 /**
- * Creates a copy of the RouteHint
+ * 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.
  */
-struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig);
+bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b);
 
 /**
  * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL.
@@ -18626,17 +19764,22 @@ void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this
  */
 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);
 
+/**
+ * Creates a copy of the RouteHintHop
+ */
+struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig);
+
 /**
  * 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.
  */
-bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b);
+uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o);
 
 /**
- * Creates a copy of the RouteHintHop
+ * 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.
  */
-struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig);
+bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b);
 
 /**
  * Gets a keysend route from us (payer) to the given target node (payee). This is needed because
@@ -18679,14 +19822,45 @@ struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id
 void NetworkGraph_free(struct LDKNetworkGraph this_obj);
 
 /**
- * Creates a copy of the NetworkGraph
+ * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL.
+ */
+void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj);
+
+/**
+ * Frees any resources used by the NetworkUpdate
+ */
+void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr);
+
+/**
+ * Creates a copy of the NetworkUpdate
+ */
+struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig);
+
+/**
+ * Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate
+ */
+struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg);
+
+/**
+ * Utility method to constructs a new ChannelClosed-variant NetworkUpdate
+ */
+struct LDKNetworkUpdate NetworkUpdate_channel_closed(uint64_t short_channel_id, bool is_permanent);
+
+/**
+ * Utility method to constructs a new NodeFailure-variant NetworkUpdate
+ */
+struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent);
+
+/**
+ * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read
  */
-struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig);
+struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj);
 
 /**
- * Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL.
+ * Constructs a new EventHandler which calls the relevant methods on this_arg.
+ * This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
  */
-void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_obj);
+struct LDKEventHandler NetGraphMsgHandler_as_EventHandler(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg);
 
 /**
  * Frees any resources used by the NetGraphMsgHandler, if is_owned is set and inner is non-NULL.
@@ -18694,45 +19868,30 @@ void LockedNetworkGraph_free(struct LDKLockedNetworkGraph this_obj);
 void NetGraphMsgHandler_free(struct LDKNetGraphMsgHandler this_obj);
 
 /**
- * Creates a new tracker of the actual state of the network of channels and nodes,
- * assuming a fresh network graph.
- * Chain monitor is used to make sure announced channels exist on-chain,
- * channel data is correct, and that the announcement is signed with
- * channel owners' keys.
- *
- * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * Representation of the payment channel network
+ */
+struct LDKNetworkGraph NetGraphMsgHandler_get_network_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_ptr);
+
+/**
+ * Representation of the payment channel network
  */
-MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKThirtyTwoBytes genesis_hash, struct LDKAccess *chain_access, struct LDKLogger logger);
+void NetGraphMsgHandler_set_network_graph(struct LDKNetGraphMsgHandler *NONNULL_PTR this_ptr, struct LDKNetworkGraph val);
 
 /**
  * Creates a new tracker of the actual state of the network of channels and nodes,
  * assuming an existing Network Graph.
- *
- * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
+ * Chain monitor is used to make sure announced channels exist on-chain,
+ * channel data is correct, and that the announcement is signed with
+ * channel owners' keys.
  */
-MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(struct LDKAccess *chain_access, struct LDKLogger logger, struct LDKNetworkGraph network_graph);
+MUST_USE_RES struct LDKNetGraphMsgHandler NetGraphMsgHandler_new(struct LDKNetworkGraph network_graph, struct LDKCOption_AccessZ chain_access, struct LDKLogger logger);
 
 /**
  * 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.
- *
- * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
- */
-void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKAccess *chain_access);
-
-/**
- * Take a read lock on the network_graph and return it in the C-bindings
- * newtype helper. This is likely only useful when called via the C
- * bindings as you can call `self.network_graph.read().unwrap()` in Rust
- * yourself.
- */
-MUST_USE_RES struct LDKLockedNetworkGraph NetGraphMsgHandler_read_locked_graph(const struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg);
-
-/**
- * Get a reference to the NetworkGraph which this read-lock contains.
  */
-MUST_USE_RES struct LDKNetworkGraph LockedNetworkGraph_graph(const struct LDKLockedNetworkGraph *NONNULL_PTR this_arg);
+void NetGraphMsgHandler_add_chain_access(struct LDKNetGraphMsgHandler *NONNULL_PTR this_arg, struct LDKCOption_AccessZ chain_access);
 
 /**
  * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
@@ -19010,6 +20169,11 @@ bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDK
  */
 struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig);
 
+/**
+ * Checks if two RoutingFeess contain equal inner contents.
+ */
+uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o);
+
 /**
  * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
  */
@@ -19197,6 +20361,11 @@ struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice s
  */
 MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes genesis_hash);
 
+/**
+ * Returns a read-only view of the network graph.
+ */
+MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg);
+
 /**
  * For an already known node (from channel announcements), update its stored properties from a
  * given node announcement.
@@ -19205,7 +20374,7 @@ MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(struct LDKThirtyTwoBytes ge
  * 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 struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg);
+MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg);
 
 /**
  * For an already known node (from channel announcements), update its stored properties from a
@@ -19213,7 +20382,7 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from
  * given the associated signatures here we cannot relay the node announcement to any of our
  * peers.
  */
-MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg);
+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);
 
 /**
  * Store or update channel info from a channel announcement.
@@ -19224,10 +20393,8 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from
  *
  * If a `chain::Access` object is provided via `chain_access`, it will be called to verify
  * the corresponding UTXO exists on chain and is correctly-formatted.
- *
- * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
  */
-MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access);
+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_AccessZ chain_access);
 
 /**
  * Store or update channel info from a channel announcement without verifying the associated
@@ -19236,10 +20403,8 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_f
  *
  * If a `chain::Access` object is provided via `chain_access`, it will be called to verify
  * the corresponding UTXO exists on chain and is correctly-formatted.
- *
- * Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
  */
-MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKAccess *chain_access);
+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_AccessZ chain_access);
 
 /**
  * Close a channel if a corresponding HTLC fail was sent.
@@ -19247,7 +20412,12 @@ MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_f
  * May cause the removal of nodes too, if this was their last channel.
  * If not permanent, makes channels unavailable for routing.
  */
-void NetworkGraph_close_channel_from_update(struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent);
+void NetworkGraph_close_channel_from_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, bool is_permanent);
+
+/**
+ * Marks a node in the graph as failed.
+ */
+void NetworkGraph_fail_node(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey _node_id, bool is_permanent);
 
 /**
  * For an already known (from announcement) channel, update info about one of the directions
@@ -19257,14 +20427,14 @@ void NetworkGraph_close_channel_from_update(struct LDKNetworkGraph *NONNULL_PTR
  * 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 struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg);
+MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg);
 
 /**
  * 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.
  */
-MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg);
+MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg);
 
 /**
  * Frees any resources used by the FilesystemPersister, if is_owned is set and inner is non-NULL.
@@ -19317,23 +20487,35 @@ void ChannelManagerPersister_free(struct LDKChannelManagerPersister this_ptr);
  * `persist_manager` returns an error. In case of an error, the error is retrieved by calling
  * either [`join`] or [`stop`].
  *
- * Typically, users should either implement [`ChannelManagerPersister`] to never return an
- * error or call [`join`] and handle any error that may arise. For the latter case, the
- * `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
+ * # Data Persistence
  *
  * `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
  * uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
  * [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
  * provided implementation.
  *
+ * Typically, users should either implement [`ChannelManagerPersister`] to never return an
+ * error or call [`join`] and handle any error that may arise. For the latter case,
+ * `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
+ *
+ * # Event Handling
+ *
+ * `event_handler` is responsible for handling events that users should be notified of (e.g.,
+ * payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common
+ * functionality implemented by other handlers.
+ * * [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures.
+ *
  * [top-level documentation]: Self
  * [`join`]: Self::join
  * [`stop`]: Self::stop
  * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
  * [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
  * [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager
+ * [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph
+ *
+ * Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None
  */
-MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger);
+MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKChannelManagerPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKNetGraphMsgHandler net_graph_msg_handler, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger);
 
 /**
  * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting
@@ -19550,6 +20732,11 @@ enum LDKCurrency Currency_simnet(void);
  */
 enum LDKCurrency Currency_signet(void);
 
+/**
+ * Checks if two Currencys contain equal inner contents.
+ */
+uint64_t Currency_hash(const enum LDKCurrency *NONNULL_PTR o);
+
 /**
  * Checks if two Currencys contain equal inner contents.
  * This ignores pointers and is_owned flags and looks at the values in fields.
@@ -19561,6 +20748,16 @@ bool Currency_eq(const enum LDKCurrency *NONNULL_PTR a, const enum LDKCurrency *
  */
 void Sha256_free(struct LDKSha256 this_obj);
 
+/**
+ * Creates a copy of the Sha256
+ */
+struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig);
+
+/**
+ * Checks if two Sha256s contain equal inner contents.
+ */
+uint64_t Sha256_hash(const struct LDKSha256 *NONNULL_PTR o);
+
 /**
  * Checks if two Sha256s contain equal inner contents.
  * This ignores pointers and is_owned flags and looks at the values in fields.
@@ -19569,14 +20766,19 @@ void Sha256_free(struct LDKSha256 this_obj);
 bool Sha256_eq(const struct LDKSha256 *NONNULL_PTR a, const struct LDKSha256 *NONNULL_PTR b);
 
 /**
- * Creates a copy of the Sha256
+ * Frees any resources used by the Description, if is_owned is set and inner is non-NULL.
  */
-struct LDKSha256 Sha256_clone(const struct LDKSha256 *NONNULL_PTR orig);
+void Description_free(struct LDKDescription this_obj);
 
 /**
- * Frees any resources used by the Description, if is_owned is set and inner is non-NULL.
+ * Creates a copy of the Description
  */
-void Description_free(struct LDKDescription this_obj);
+struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig);
+
+/**
+ * Checks if two Descriptions contain equal inner contents.
+ */
+uint64_t Description_hash(const struct LDKDescription *NONNULL_PTR o);
 
 /**
  * Checks if two Descriptions contain equal inner contents.
@@ -19586,14 +20788,19 @@ void Description_free(struct LDKDescription this_obj);
 bool Description_eq(const struct LDKDescription *NONNULL_PTR a, const struct LDKDescription *NONNULL_PTR b);
 
 /**
- * Creates a copy of the Description
+ * Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL.
  */
-struct LDKDescription Description_clone(const struct LDKDescription *NONNULL_PTR orig);
+void PayeePubKey_free(struct LDKPayeePubKey this_obj);
 
 /**
- * Frees any resources used by the PayeePubKey, if is_owned is set and inner is non-NULL.
+ * Creates a copy of the PayeePubKey
  */
-void PayeePubKey_free(struct LDKPayeePubKey this_obj);
+struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig);
+
+/**
+ * Checks if two PayeePubKeys contain equal inner contents.
+ */
+uint64_t PayeePubKey_hash(const struct LDKPayeePubKey *NONNULL_PTR o);
 
 /**
  * Checks if two PayeePubKeys contain equal inner contents.
@@ -19603,14 +20810,19 @@ void PayeePubKey_free(struct LDKPayeePubKey this_obj);
 bool PayeePubKey_eq(const struct LDKPayeePubKey *NONNULL_PTR a, const struct LDKPayeePubKey *NONNULL_PTR b);
 
 /**
- * Creates a copy of the PayeePubKey
+ * Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL.
  */
-struct LDKPayeePubKey PayeePubKey_clone(const struct LDKPayeePubKey *NONNULL_PTR orig);
+void ExpiryTime_free(struct LDKExpiryTime this_obj);
 
 /**
- * Frees any resources used by the ExpiryTime, if is_owned is set and inner is non-NULL.
+ * Creates a copy of the ExpiryTime
  */
-void ExpiryTime_free(struct LDKExpiryTime this_obj);
+struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig);
+
+/**
+ * Checks if two ExpiryTimes contain equal inner contents.
+ */
+uint64_t ExpiryTime_hash(const struct LDKExpiryTime *NONNULL_PTR o);
 
 /**
  * Checks if two ExpiryTimes contain equal inner contents.
@@ -19620,26 +20832,26 @@ void ExpiryTime_free(struct LDKExpiryTime this_obj);
 bool ExpiryTime_eq(const struct LDKExpiryTime *NONNULL_PTR a, const struct LDKExpiryTime *NONNULL_PTR b);
 
 /**
- * Creates a copy of the ExpiryTime
+ * Frees any resources used by the MinFinalCltvExpiry, if is_owned is set and inner is non-NULL.
  */
-struct LDKExpiryTime ExpiryTime_clone(const struct LDKExpiryTime *NONNULL_PTR orig);
+void MinFinalCltvExpiry_free(struct LDKMinFinalCltvExpiry this_obj);
 
 /**
- * Frees any resources used by the MinFinalCltvExpiry, if is_owned is set and inner is non-NULL.
+ * Creates a copy of the MinFinalCltvExpiry
  */
-void MinFinalCltvExpiry_free(struct LDKMinFinalCltvExpiry this_obj);
+struct LDKMinFinalCltvExpiry MinFinalCltvExpiry_clone(const struct LDKMinFinalCltvExpiry *NONNULL_PTR orig);
 
 /**
  * Checks if two MinFinalCltvExpirys contain equal inner contents.
- * This 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 MinFinalCltvExpiry_eq(const struct LDKMinFinalCltvExpiry *NONNULL_PTR a, const struct LDKMinFinalCltvExpiry *NONNULL_PTR b);
+uint64_t MinFinalCltvExpiry_hash(const struct LDKMinFinalCltvExpiry *NONNULL_PTR o);
 
 /**
- * Creates a copy of the MinFinalCltvExpiry
+ * Checks if two MinFinalCltvExpirys contain equal inner contents.
+ * This 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 LDKMinFinalCltvExpiry MinFinalCltvExpiry_clone(const struct LDKMinFinalCltvExpiry *NONNULL_PTR orig);
+bool MinFinalCltvExpiry_eq(const struct LDKMinFinalCltvExpiry *NONNULL_PTR a, const struct LDKMinFinalCltvExpiry *NONNULL_PTR b);
 
 /**
  * Frees any resources used by the Fallback
@@ -19666,6 +20878,11 @@ struct LDKFallback Fallback_pub_key_hash(struct LDKTwentyBytes a);
  */
 struct LDKFallback Fallback_script_hash(struct LDKTwentyBytes a);
 
+/**
+ * Checks if two Fallbacks contain equal inner contents.
+ */
+uint64_t Fallback_hash(const struct LDKFallback *NONNULL_PTR o);
+
 /**
  * Checks if two Fallbacks contain equal inner contents.
  * This ignores pointers and is_owned flags and looks at the values in fields.
@@ -19677,6 +20894,11 @@ bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallba
  */
 void InvoiceSignature_free(struct LDKInvoiceSignature this_obj);
 
+/**
+ * Creates a copy of the InvoiceSignature
+ */
+struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig);
+
 /**
  * Checks if two InvoiceSignatures contain equal inner contents.
  * This ignores pointers and is_owned flags and looks at the values in fields.
@@ -19685,26 +20907,26 @@ void InvoiceSignature_free(struct LDKInvoiceSignature this_obj);
 bool InvoiceSignature_eq(const struct LDKInvoiceSignature *NONNULL_PTR a, const struct LDKInvoiceSignature *NONNULL_PTR b);
 
 /**
- * Creates a copy of the InvoiceSignature
+ * Frees any resources used by the PrivateRoute, if is_owned is set and inner is non-NULL.
  */
-struct LDKInvoiceSignature InvoiceSignature_clone(const struct LDKInvoiceSignature *NONNULL_PTR orig);
+void PrivateRoute_free(struct LDKPrivateRoute this_obj);
 
 /**
- * Frees any resources used by the PrivateRoute, if is_owned is set and inner is non-NULL.
+ * Creates a copy of the PrivateRoute
  */
-void PrivateRoute_free(struct LDKPrivateRoute this_obj);
+struct LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig);
 
 /**
  * Checks if two PrivateRoutes contain equal inner contents.
- * This 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 PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b);
+uint64_t PrivateRoute_hash(const struct LDKPrivateRoute *NONNULL_PTR o);
 
 /**
- * Creates a copy of the PrivateRoute
+ * Checks if two PrivateRoutes contain equal inner contents.
+ * This 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 LDKPrivateRoute PrivateRoute_clone(const struct LDKPrivateRoute *NONNULL_PTR orig);
+bool PrivateRoute_eq(const struct LDKPrivateRoute *NONNULL_PTR a, const struct LDKPrivateRoute *NONNULL_PTR b);
 
 /**
  * Disassembles the `SignedRawInvoice` into its three parts:
@@ -19838,10 +21060,17 @@ MUST_USE_RES struct LDKCResult_NoneSemanticErrorZ Invoice_check_signature(const
  * ```
  * use lightning_invoice::*;
  *
- * let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\
- * \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\
- * \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\
- * \tky03ylcqca784w\";
+ * let invoice = \"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\\
+ * h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\\
+ * 5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\\
+ * h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\\
+ * j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\\
+ * ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\\
+ * guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\\
+ * ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\\
+ * p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\\
+ * 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\
+ * j5r6drg6k6zcqj0fcwg\";
  *
  * let signed = invoice.parse::<SignedRawInvoice>().unwrap();
  *
@@ -19869,8 +21098,6 @@ MUST_USE_RES struct LDKPublicKey Invoice_payee_pub_key(const struct LDKInvoice *
 
 /**
  * Get the payment secret if one was included in the invoice
- *
- * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
  */
 MUST_USE_RES struct LDKThirtyTwoBytes Invoice_payment_secret(const struct LDKInvoice *NONNULL_PTR this_arg);
 
@@ -20025,6 +21252,11 @@ enum LDKSemanticError SemanticError_no_description(void);
  */
 enum LDKSemanticError SemanticError_multiple_descriptions(void);
 
+/**
+ * Utility method to constructs a new NoPaymentSecret-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_no_payment_secret(void);
+
 /**
  * Utility method to constructs a new MultiplePaymentSecrets-variant SemanticError
  */
@@ -20045,6 +21277,11 @@ enum LDKSemanticError SemanticError_invalid_recovery_id(void);
  */
 enum LDKSemanticError SemanticError_invalid_signature(void);
 
+/**
+ * Utility method to constructs a new ImpreciseAmount-variant SemanticError
+ */
+enum LDKSemanticError SemanticError_imprecise_amount(void);
+
 /**
  * Checks if two SemanticErrors contain equal inner contents.
  * This ignores pointers and is_owned flags and looks at the values in fields.
index a5ee199f32d18d5cacd5a3d5e39abc462998b9bf..1301b65bd318f1b511f49c774930c43446c2f3cf 100644 (file)
@@ -1,6 +1,7 @@
 #include <string.h>
 namespace LDK {
 // Forward declarations
+class Str;
 class TxCreationKeys;
 class ChannelPublicKeys;
 class HTLCOutputInCommitment;
@@ -9,6 +10,8 @@ class CounterpartyChannelTransactionParameters;
 class DirectedChannelTransactionParameters;
 class HolderCommitmentTransaction;
 class BuiltCommitmentTransaction;
+class ClosingTransaction;
+class TrustedClosingTransaction;
 class CommitmentTransaction;
 class TrustedCommitmentTransaction;
 class ShutdownScript;
@@ -31,6 +34,7 @@ class Watch;
 class Filter;
 class WatchedOutput;
 class PaymentPurpose;
+class ClosureReason;
 class Event;
 class MessageSendEvent;
 class MessageSendEventsProvider;
@@ -51,6 +55,7 @@ class KeysManager;
 class FilesystemPersister;
 class ChannelManager;
 class ChainParameters;
+class CounterpartyForwardingInfo;
 class ChannelCounterparty;
 class ChannelDetails;
 class PaymentSendFailure;
@@ -61,6 +66,8 @@ class ChannelConfig;
 class UserConfig;
 class APIError;
 class OutPoint;
+class CustomMessageReader;
+class Type;
 class Invoice;
 class SignedRawInvoice;
 class RawInvoice;
@@ -84,8 +91,10 @@ class ChannelMonitorUpdateErr;
 class MonitorUpdateError;
 class MonitorEvent;
 class HTLCUpdate;
+class Balance;
 class ChannelMonitor;
 class Persist;
+class CustomMessageHandler;
 class IgnoringMessageHandler;
 class ErroringMessageHandler;
 class MessageHandler;
@@ -93,7 +102,8 @@ class SocketDescriptor;
 class PeerHandleError;
 class PeerManager;
 class NetworkGraph;
-class LockedNetworkGraph;
+class ReadOnlyNetworkGraph;
+class NetworkUpdate;
 class NetGraphMsgHandler;
 class DirectionalChannelInfo;
 class ChannelInfo;
@@ -138,7 +148,6 @@ class GossipTimestampFilter;
 class ErrorAction;
 class LightningError;
 class CommitmentUpdate;
-class HTLCFailChannelUpdate;
 class ChannelMessageHandler;
 class RoutingMessageHandler;
 class Level;
@@ -156,20 +165,24 @@ class CResult_ChannelAnnouncementDecodeErrorZ;
 class CResult_PositiveTimestampCreationErrorZ;
 class CResult_CVec_u8ZPeerHandleErrorZ;
 class CResult_InvoiceFeaturesDecodeErrorZ;
-class CResult_ChannelMonitorUpdateDecodeErrorZ;
+class COption_NetworkUpdateZ;
 class COption_u64Z;
 class CResult_TxOutAccessErrorZ;
+class CResult_TrustedClosingTransactionNoneZ;
+class CResult_ChannelMonitorUpdateDecodeErrorZ;
+class C2Tuple_PublicKeyTypeZ;
 class CResult_NetAddressDecodeErrorZ;
+class CResult_ChannelReestablishDecodeErrorZ;
 class CResult_UnsignedNodeAnnouncementDecodeErrorZ;
 class CResult_ReplyChannelRangeDecodeErrorZ;
-class CResult_ChannelReestablishDecodeErrorZ;
-class CResult_GossipTimestampFilterDecodeErrorZ;
-class CResult_InvoiceSignOrCreationErrorZ;
 class CResult_CommitmentSignedDecodeErrorZ;
 class CVec_UpdateAddHTLCZ;
+class CResult_GossipTimestampFilterDecodeErrorZ;
 class COption_u32Z;
 class CResult_InitFeaturesDecodeErrorZ;
 class CResult_StaticPaymentOutputDescriptorDecodeErrorZ;
+class CResult_InvoiceSignOrCreationErrorZ;
+class COption_FilterZ;
 class CResult_CommitmentTransactionDecodeErrorZ;
 class COption_C2Tuple_usizeTransactionZZ;
 class CResult_TransactionNoneZ;
@@ -185,14 +198,15 @@ class CResult_SecretKeyErrorZ;
 class CResult_ShutdownScriptDecodeErrorZ;
 class CResult_InvoiceNoneZ;
 class CResult_QueryChannelRangeDecodeErrorZ;
-class C2Tuple_usizeTransactionZ;
 class CResult_TxCreationKeysDecodeErrorZ;
+class C2Tuple_usizeTransactionZ;
 class CResult_ChannelFeaturesDecodeErrorZ;
 class CVec_ChannelMonitorZ;
 class CVec_TransactionZ;
 class CResult_UpdateFeeDecodeErrorZ;
 class CResult_RouteHopDecodeErrorZ;
 class CResult_NodeAnnouncementDecodeErrorZ;
+class CVec_BalanceZ;
 class CResult_HTLCOutputInCommitmentDecodeErrorZ;
 class CResult_boolLightningErrorZ;
 class CResult_TxCreationKeysErrorZ;
@@ -233,12 +247,13 @@ class CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ;
 class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ;
 class CResult_CVec_CVec_u8ZZNoneZ;
 class C2Tuple_PaymentHashPaymentSecretZ;
-class CResult_AcceptChannelDecodeErrorZ;
+class COption_AccessZ;
 class C2Tuple_BlockHashChannelManagerZ;
 class CResult_ChannelTransactionParametersDecodeErrorZ;
-class CResult_PongDecodeErrorZ;
+class CResult_AcceptChannelDecodeErrorZ;
 class CVec_SignatureZ;
 class CVec_u64Z;
+class CResult_PongDecodeErrorZ;
 class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ;
 class CResult_StringErrorZ;
 class CResult_NoneErrorZ;
@@ -251,6 +266,7 @@ class CResult_NoneLightningErrorZ;
 class CResult_NonePeerHandleErrorZ;
 class CResult_CVec_SignatureZNoneZ;
 class CResult_DescriptionCreationErrorZ;
+class CVec_C2Tuple_PublicKeyTypeZZ;
 class CResult_RoutingFeesDecodeErrorZ;
 class CResult_PayeePubKeyErrorZ;
 class CResult_QueryShortChannelIdsDecodeErrorZ;
@@ -261,6 +277,8 @@ class CResult_NoneAPIErrorZ;
 class CVec_NetAddressZ;
 class CVec_C2Tuple_usizeTransactionZZ;
 class CVec_PublicKeyZ;
+class COption_TypeZ;
+class CResult_COption_TypeZDecodeErrorZ;
 class CResult_DirectionalChannelInfoDecodeErrorZ;
 class C2Tuple_u32TxOutZ;
 class CResult_UpdateFailHTLCDecodeErrorZ;
@@ -279,10 +297,11 @@ class CResult_PaymentHashPaymentSendFailureZ;
 class CResult_SiPrefixNoneZ;
 class CResult_PublicKeyErrorZ;
 class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ;
+class CResult_NoneNoneZ;
 class CResult_PrivateRouteCreationErrorZ;
 class CResult_boolPeerHandleErrorZ;
-class CResult_ChannelUpdateDecodeErrorZ;
 class CVec_APIErrorZ;
+class CResult_ChannelUpdateDecodeErrorZ;
 class CVec_UpdateFulfillHTLCZ;
 class CResult_AnnouncementSignaturesDecodeErrorZ;
 class CResult_UpdateFulfillHTLCDecodeErrorZ;
@@ -299,6 +318,21 @@ class CVec_TxOutZ;
 class CVec_UpdateFailHTLCZ;
 class CResult_FundingLockedDecodeErrorZ;
 
+class Str {
+private:
+       LDKStr self;
+public:
+       Str(const Str&) = delete;
+       Str(Str&& o) : self(o.self) { memset(&o, 0, sizeof(Str)); }
+       Str(LDKStr&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKStr)); }
+       operator LDKStr() && { LDKStr res = self; memset(&self, 0, sizeof(LDKStr)); return res; }
+       ~Str() { Str_free(self); }
+       Str& operator=(Str&& o) { Str_free(self); self = o.self; memset(&o, 0, sizeof(Str)); return *this; }
+       LDKStr* operator &() { return &self; }
+       LDKStr* operator ->() { return &self; }
+       const LDKStr* operator &() const { return &self; }
+       const LDKStr* operator ->() const { return &self; }
+};
 class TxCreationKeys {
 private:
        LDKTxCreationKeys self;
@@ -419,6 +453,36 @@ public:
        const LDKBuiltCommitmentTransaction* operator &() const { return &self; }
        const LDKBuiltCommitmentTransaction* operator ->() const { return &self; }
 };
+class ClosingTransaction {
+private:
+       LDKClosingTransaction self;
+public:
+       ClosingTransaction(const ClosingTransaction&) = delete;
+       ClosingTransaction(ClosingTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(ClosingTransaction)); }
+       ClosingTransaction(LDKClosingTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosingTransaction)); }
+       operator LDKClosingTransaction() && { LDKClosingTransaction res = self; memset(&self, 0, sizeof(LDKClosingTransaction)); return res; }
+       ~ClosingTransaction() { ClosingTransaction_free(self); }
+       ClosingTransaction& operator=(ClosingTransaction&& o) { ClosingTransaction_free(self); self = o.self; memset(&o, 0, sizeof(ClosingTransaction)); return *this; }
+       LDKClosingTransaction* operator &() { return &self; }
+       LDKClosingTransaction* operator ->() { return &self; }
+       const LDKClosingTransaction* operator &() const { return &self; }
+       const LDKClosingTransaction* operator ->() const { return &self; }
+};
+class TrustedClosingTransaction {
+private:
+       LDKTrustedClosingTransaction self;
+public:
+       TrustedClosingTransaction(const TrustedClosingTransaction&) = delete;
+       TrustedClosingTransaction(TrustedClosingTransaction&& o) : self(o.self) { memset(&o, 0, sizeof(TrustedClosingTransaction)); }
+       TrustedClosingTransaction(LDKTrustedClosingTransaction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrustedClosingTransaction)); }
+       operator LDKTrustedClosingTransaction() && { LDKTrustedClosingTransaction res = self; memset(&self, 0, sizeof(LDKTrustedClosingTransaction)); return res; }
+       ~TrustedClosingTransaction() { TrustedClosingTransaction_free(self); }
+       TrustedClosingTransaction& operator=(TrustedClosingTransaction&& o) { TrustedClosingTransaction_free(self); self = o.self; memset(&o, 0, sizeof(TrustedClosingTransaction)); return *this; }
+       LDKTrustedClosingTransaction* operator &() { return &self; }
+       LDKTrustedClosingTransaction* operator ->() { return &self; }
+       const LDKTrustedClosingTransaction* operator &() const { return &self; }
+       const LDKTrustedClosingTransaction* operator ->() const { return &self; }
+};
 class CommitmentTransaction {
 private:
        LDKCommitmentTransaction self;
@@ -879,6 +943,21 @@ public:
        const LDKPaymentPurpose* operator &() const { return &self; }
        const LDKPaymentPurpose* operator ->() const { return &self; }
 };
+class ClosureReason {
+private:
+       LDKClosureReason self;
+public:
+       ClosureReason(const ClosureReason&) = delete;
+       ClosureReason(ClosureReason&& o) : self(o.self) { memset(&o, 0, sizeof(ClosureReason)); }
+       ClosureReason(LDKClosureReason&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKClosureReason)); }
+       operator LDKClosureReason() && { LDKClosureReason res = self; memset(&self, 0, sizeof(LDKClosureReason)); return res; }
+       ~ClosureReason() { ClosureReason_free(self); }
+       ClosureReason& operator=(ClosureReason&& o) { ClosureReason_free(self); self = o.self; memset(&o, 0, sizeof(ClosureReason)); return *this; }
+       LDKClosureReason* operator &() { return &self; }
+       LDKClosureReason* operator ->() { return &self; }
+       const LDKClosureReason* operator &() const { return &self; }
+       const LDKClosureReason* operator ->() const { return &self; }
+};
 class Event {
 private:
        LDKEvent self;
@@ -971,7 +1050,7 @@ public:
         * 
         *  See [`EventsProvider`] for details that must be considered when implementing this method.
         */
-       inline void handle_event(struct LDKEvent event);
+       inline void handle_event(const struct LDKEvent *NONNULL_PTR event);
 };
 class InitFeatures {
 private:
@@ -1109,6 +1188,15 @@ public:
         *  Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
         */
        inline LDKThirtyTwoBytes release_commitment_secret(uint64_t idx);
+       /**
+        *  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
+        *  secret won't leave us without a broadcastable holder transaction.
+        *  Policy checks should be implemented in this function, including checking the amount
+        *  sent to us and checking the HTLCs.
+        */
+       inline LDK::CResult_NoneNoneZ validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx);
        /**
         *  Gets an arbitrary identifier describing the set of keys which are provided back to you in
         *  some SpendableOutputDescriptor types. This should be sufficient to identify this
@@ -1119,8 +1207,18 @@ public:
         *  Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
         * 
         *  Note that if signing fails or is rejected, the channel will be force-closed.
+        * 
+        *  Policy checks should be implemented in this function, including checking the amount
+        *  sent to us and checking the HTLCs.
         */
        inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(const struct LDKCommitmentTransaction *NONNULL_PTR commitment_tx);
+       /**
+        *  Validate the counterparty's revocation.
+        * 
+        *  This is required in order for the signer to make sure that the state has moved
+        *  forward and it is safe to sign the next counterparty commitment.
+        */
+       inline LDK::CResult_NoneNoneZ validate_counterparty_revocation(uint64_t idx, const uint8_t (*secret)[32]);
        /**
         *  Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
         *  This will only ever be called with a non-revoked commitment_tx.  This will be called with the
@@ -1198,7 +1296,7 @@ public:
         *  Note that, due to rounding, there may be one "missing" satoshi, and either party may have
         *  chosen to forgo their output as dust.
         */
-       inline LDK::CResult_SignatureNoneZ sign_closing_transaction(struct LDKTransaction closing_tx);
+       inline LDK::CResult_SignatureNoneZ sign_closing_transaction(const struct LDKClosingTransaction *NONNULL_PTR closing_tx);
        /**
         *  Signs a channel announcement message with our funding key, proving it comes from one
         *  of the channel participants.
@@ -1378,6 +1476,21 @@ 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;
@@ -1528,6 +1641,51 @@ public:
        const LDKOutPoint* operator &() const { return &self; }
        const LDKOutPoint* operator ->() const { return &self; }
 };
+class CustomMessageReader {
+private:
+       LDKCustomMessageReader self;
+public:
+       CustomMessageReader(const CustomMessageReader&) = delete;
+       CustomMessageReader(CustomMessageReader&& o) : self(o.self) { memset(&o, 0, sizeof(CustomMessageReader)); }
+       CustomMessageReader(LDKCustomMessageReader&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomMessageReader)); }
+       operator LDKCustomMessageReader() && { LDKCustomMessageReader res = self; memset(&self, 0, sizeof(LDKCustomMessageReader)); return res; }
+       ~CustomMessageReader() { CustomMessageReader_free(self); }
+       CustomMessageReader& operator=(CustomMessageReader&& o) { CustomMessageReader_free(self); self = o.self; memset(&o, 0, sizeof(CustomMessageReader)); return *this; }
+       LDKCustomMessageReader* operator &() { return &self; }
+       LDKCustomMessageReader* operator ->() { return &self; }
+       const LDKCustomMessageReader* operator &() const { return &self; }
+       const LDKCustomMessageReader* operator ->() const { return &self; }
+       /**
+        *  Decodes a custom message to `CustomMessageType`. If the given message type is known to the
+        *  implementation and the message could be decoded, must return `Ok(Some(message))`. If the
+        *  message type is unknown to the implementation, must return `Ok(None)`. If a decoding error
+        *  occur, must return `Err(DecodeError::X)` where `X` details the encountered error.
+        */
+       inline LDK::CResult_COption_TypeZDecodeErrorZ read(uint16_t message_type, struct LDKu8slice buffer);
+};
+class Type {
+private:
+       LDKType self;
+public:
+       Type(const Type&) = delete;
+       Type(Type&& o) : self(o.self) { memset(&o, 0, sizeof(Type)); }
+       Type(LDKType&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKType)); }
+       operator LDKType() && { LDKType res = self; memset(&self, 0, sizeof(LDKType)); return res; }
+       ~Type() { Type_free(self); }
+       Type& operator=(Type&& o) { Type_free(self); self = o.self; memset(&o, 0, sizeof(Type)); return *this; }
+       LDKType* operator &() { return &self; }
+       LDKType* operator ->() { return &self; }
+       const LDKType* operator &() const { return &self; }
+       const LDKType* operator ->() const { return &self; }
+       /**
+        *  Returns the type identifying the message payload.
+        */
+       inline uint16_t type_id();
+       /**
+        * Return a human-readable "debug" string describing this object
+        */
+       inline LDK::Str debug_str();
+};
 class Invoice {
 private:
        LDKInvoice self;
@@ -1868,6 +2026,21 @@ public:
        const LDKHTLCUpdate* operator &() const { return &self; }
        const LDKHTLCUpdate* operator ->() const { return &self; }
 };
+class Balance {
+private:
+       LDKBalance self;
+public:
+       Balance(const Balance&) = delete;
+       Balance(Balance&& o) : self(o.self) { memset(&o, 0, sizeof(Balance)); }
+       Balance(LDKBalance&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBalance)); }
+       operator LDKBalance() && { LDKBalance res = self; memset(&self, 0, sizeof(LDKBalance)); return res; }
+       ~Balance() { Balance_free(self); }
+       Balance& operator=(Balance&& o) { Balance_free(self); self = o.self; memset(&o, 0, sizeof(Balance)); return *this; }
+       LDKBalance* operator &() { return &self; }
+       LDKBalance* operator ->() { return &self; }
+       const LDKBalance* operator &() const { return &self; }
+       const LDKBalance* operator ->() const { return &self; }
+};
 class ChannelMonitor {
 private:
        LDKChannelMonitor self;
@@ -1934,6 +2107,33 @@ public:
         */
        inline LDK::CResult_NoneChannelMonitorUpdateErrZ update_persisted_channel(struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data);
 };
+class CustomMessageHandler {
+private:
+       LDKCustomMessageHandler self;
+public:
+       CustomMessageHandler(const CustomMessageHandler&) = delete;
+       CustomMessageHandler(CustomMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(CustomMessageHandler)); }
+       CustomMessageHandler(LDKCustomMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCustomMessageHandler)); }
+       operator LDKCustomMessageHandler() && { LDKCustomMessageHandler res = self; memset(&self, 0, sizeof(LDKCustomMessageHandler)); return res; }
+       ~CustomMessageHandler() { CustomMessageHandler_free(self); }
+       CustomMessageHandler& operator=(CustomMessageHandler&& o) { CustomMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(CustomMessageHandler)); return *this; }
+       LDKCustomMessageHandler* operator &() { return &self; }
+       LDKCustomMessageHandler* operator ->() { return &self; }
+       const LDKCustomMessageHandler* operator &() const { return &self; }
+       const LDKCustomMessageHandler* operator ->() const { return &self; }
+       /**
+        *  Called with the message type that was received and the buffer to be read.
+        *  Can return a `MessageHandlingError` if the message could not be handled.
+        */
+       inline LDK::CResult_NoneLightningErrorZ handle_custom_message(struct LDKType msg, struct LDKPublicKey sender_node_id);
+       /**
+        *  Gets the list of pending messages which were generated by the custom message
+        *  handler, clearing the list in the process. The first tuple element must
+        *  correspond to the intended recipients node ids. If no connection to one of the
+        *  specified node does not exist, the message is simply not sent to it.
+        */
+       inline LDK::CVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg();
+};
 class IgnoringMessageHandler {
 private:
        LDKIgnoringMessageHandler self;
@@ -2073,20 +2273,35 @@ public:
        const LDKNetworkGraph* operator &() const { return &self; }
        const LDKNetworkGraph* operator ->() const { return &self; }
 };
-class LockedNetworkGraph {
+class ReadOnlyNetworkGraph {
+private:
+       LDKReadOnlyNetworkGraph self;
+public:
+       ReadOnlyNetworkGraph(const ReadOnlyNetworkGraph&) = delete;
+       ReadOnlyNetworkGraph(ReadOnlyNetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(ReadOnlyNetworkGraph)); }
+       ReadOnlyNetworkGraph(LDKReadOnlyNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReadOnlyNetworkGraph)); }
+       operator LDKReadOnlyNetworkGraph() && { LDKReadOnlyNetworkGraph res = self; memset(&self, 0, sizeof(LDKReadOnlyNetworkGraph)); return res; }
+       ~ReadOnlyNetworkGraph() { ReadOnlyNetworkGraph_free(self); }
+       ReadOnlyNetworkGraph& operator=(ReadOnlyNetworkGraph&& o) { ReadOnlyNetworkGraph_free(self); self = o.self; memset(&o, 0, sizeof(ReadOnlyNetworkGraph)); return *this; }
+       LDKReadOnlyNetworkGraph* operator &() { return &self; }
+       LDKReadOnlyNetworkGraph* operator ->() { return &self; }
+       const LDKReadOnlyNetworkGraph* operator &() const { return &self; }
+       const LDKReadOnlyNetworkGraph* operator ->() const { return &self; }
+};
+class NetworkUpdate {
 private:
-       LDKLockedNetworkGraph self;
+       LDKNetworkUpdate self;
 public:
-       LockedNetworkGraph(const LockedNetworkGraph&) = delete;
-       LockedNetworkGraph(LockedNetworkGraph&& o) : self(o.self) { memset(&o, 0, sizeof(LockedNetworkGraph)); }
-       LockedNetworkGraph(LDKLockedNetworkGraph&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKLockedNetworkGraph)); }
-       operator LDKLockedNetworkGraph() && { LDKLockedNetworkGraph res = self; memset(&self, 0, sizeof(LDKLockedNetworkGraph)); return res; }
-       ~LockedNetworkGraph() { LockedNetworkGraph_free(self); }
-       LockedNetworkGraph& operator=(LockedNetworkGraph&& o) { LockedNetworkGraph_free(self); self = o.self; memset(&o, 0, sizeof(LockedNetworkGraph)); return *this; }
-       LDKLockedNetworkGraph* operator &() { return &self; }
-       LDKLockedNetworkGraph* operator ->() { return &self; }
-       const LDKLockedNetworkGraph* operator &() const { return &self; }
-       const LDKLockedNetworkGraph* operator ->() const { return &self; }
+       NetworkUpdate(const NetworkUpdate&) = delete;
+       NetworkUpdate(NetworkUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(NetworkUpdate)); }
+       NetworkUpdate(LDKNetworkUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNetworkUpdate)); }
+       operator LDKNetworkUpdate() && { LDKNetworkUpdate res = self; memset(&self, 0, sizeof(LDKNetworkUpdate)); return res; }
+       ~NetworkUpdate() { NetworkUpdate_free(self); }
+       NetworkUpdate& operator=(NetworkUpdate&& o) { NetworkUpdate_free(self); self = o.self; memset(&o, 0, sizeof(NetworkUpdate)); return *this; }
+       LDKNetworkUpdate* operator &() { return &self; }
+       LDKNetworkUpdate* operator ->() { return &self; }
+       const LDKNetworkUpdate* operator &() const { return &self; }
+       const LDKNetworkUpdate* operator ->() const { return &self; }
 };
 class NetGraphMsgHandler {
 private:
@@ -2748,21 +2963,6 @@ public:
        const LDKCommitmentUpdate* operator &() const { return &self; }
        const LDKCommitmentUpdate* operator ->() const { return &self; }
 };
-class HTLCFailChannelUpdate {
-private:
-       LDKHTLCFailChannelUpdate self;
-public:
-       HTLCFailChannelUpdate(const HTLCFailChannelUpdate&) = delete;
-       HTLCFailChannelUpdate(HTLCFailChannelUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCFailChannelUpdate)); }
-       HTLCFailChannelUpdate(LDKHTLCFailChannelUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCFailChannelUpdate)); }
-       operator LDKHTLCFailChannelUpdate() && { LDKHTLCFailChannelUpdate res = self; memset(&self, 0, sizeof(LDKHTLCFailChannelUpdate)); return res; }
-       ~HTLCFailChannelUpdate() { HTLCFailChannelUpdate_free(self); }
-       HTLCFailChannelUpdate& operator=(HTLCFailChannelUpdate&& o) { HTLCFailChannelUpdate_free(self); self = o.self; memset(&o, 0, sizeof(HTLCFailChannelUpdate)); return *this; }
-       LDKHTLCFailChannelUpdate* operator &() { return &self; }
-       LDKHTLCFailChannelUpdate* operator ->() { return &self; }
-       const LDKHTLCFailChannelUpdate* operator &() const { return &self; }
-       const LDKHTLCFailChannelUpdate* operator ->() const { return &self; }
-};
 class ChannelMessageHandler {
 private:
        LDKChannelMessageHandler self;
@@ -2890,10 +3090,6 @@ public:
         *  false or returning an Err otherwise.
         */
        inline LDK::CResult_boolLightningErrorZ handle_channel_update(const struct LDKChannelUpdate *NONNULL_PTR msg);
-       /**
-        *  Handle some updates to the route graph that we learned due to an outbound failed payment.
-        */
-       inline void handle_htlc_fail_channel_update(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR update);
        /**
         *  Gets a subset of the channel announcements and updates required to dump our routing table
         *  to a remote node, starting at the short_channel_id indicated by starting_point and
@@ -3167,20 +3363,20 @@ public:
        const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_InvoiceFeaturesDecodeErrorZ* operator ->() const { return &self; }
 };
-class CResult_ChannelMonitorUpdateDecodeErrorZ {
+class COption_NetworkUpdateZ {
 private:
-       LDKCResult_ChannelMonitorUpdateDecodeErrorZ self;
+       LDKCOption_NetworkUpdateZ self;
 public:
-       CResult_ChannelMonitorUpdateDecodeErrorZ(const CResult_ChannelMonitorUpdateDecodeErrorZ&) = delete;
-       CResult_ChannelMonitorUpdateDecodeErrorZ(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); }
-       CResult_ChannelMonitorUpdateDecodeErrorZ(LDKCResult_ChannelMonitorUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); }
-       operator LDKCResult_ChannelMonitorUpdateDecodeErrorZ() && { LDKCResult_ChannelMonitorUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); return res; }
-       ~CResult_ChannelMonitorUpdateDecodeErrorZ() { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); }
-       CResult_ChannelMonitorUpdateDecodeErrorZ& operator=(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); return *this; }
-       LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() { return &self; }
-       LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() { return &self; }
-       const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() const { return &self; }
-       const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() const { return &self; }
+       COption_NetworkUpdateZ(const COption_NetworkUpdateZ&) = delete;
+       COption_NetworkUpdateZ(COption_NetworkUpdateZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_NetworkUpdateZ)); }
+       COption_NetworkUpdateZ(LDKCOption_NetworkUpdateZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_NetworkUpdateZ)); }
+       operator LDKCOption_NetworkUpdateZ() && { LDKCOption_NetworkUpdateZ res = self; memset(&self, 0, sizeof(LDKCOption_NetworkUpdateZ)); return res; }
+       ~COption_NetworkUpdateZ() { COption_NetworkUpdateZ_free(self); }
+       COption_NetworkUpdateZ& operator=(COption_NetworkUpdateZ&& o) { COption_NetworkUpdateZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_NetworkUpdateZ)); return *this; }
+       LDKCOption_NetworkUpdateZ* operator &() { return &self; }
+       LDKCOption_NetworkUpdateZ* operator ->() { return &self; }
+       const LDKCOption_NetworkUpdateZ* operator &() const { return &self; }
+       const LDKCOption_NetworkUpdateZ* operator ->() const { return &self; }
 };
 class COption_u64Z {
 private:
@@ -3212,6 +3408,51 @@ public:
        const LDKCResult_TxOutAccessErrorZ* operator &() const { return &self; }
        const LDKCResult_TxOutAccessErrorZ* operator ->() const { return &self; }
 };
+class CResult_TrustedClosingTransactionNoneZ {
+private:
+       LDKCResult_TrustedClosingTransactionNoneZ self;
+public:
+       CResult_TrustedClosingTransactionNoneZ(const CResult_TrustedClosingTransactionNoneZ&) = delete;
+       CResult_TrustedClosingTransactionNoneZ(CResult_TrustedClosingTransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrustedClosingTransactionNoneZ)); }
+       CResult_TrustedClosingTransactionNoneZ(LDKCResult_TrustedClosingTransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrustedClosingTransactionNoneZ)); }
+       operator LDKCResult_TrustedClosingTransactionNoneZ() && { LDKCResult_TrustedClosingTransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TrustedClosingTransactionNoneZ)); return res; }
+       ~CResult_TrustedClosingTransactionNoneZ() { CResult_TrustedClosingTransactionNoneZ_free(self); }
+       CResult_TrustedClosingTransactionNoneZ& operator=(CResult_TrustedClosingTransactionNoneZ&& o) { CResult_TrustedClosingTransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrustedClosingTransactionNoneZ)); return *this; }
+       LDKCResult_TrustedClosingTransactionNoneZ* operator &() { return &self; }
+       LDKCResult_TrustedClosingTransactionNoneZ* operator ->() { return &self; }
+       const LDKCResult_TrustedClosingTransactionNoneZ* operator &() const { return &self; }
+       const LDKCResult_TrustedClosingTransactionNoneZ* operator ->() const { return &self; }
+};
+class CResult_ChannelMonitorUpdateDecodeErrorZ {
+private:
+       LDKCResult_ChannelMonitorUpdateDecodeErrorZ self;
+public:
+       CResult_ChannelMonitorUpdateDecodeErrorZ(const CResult_ChannelMonitorUpdateDecodeErrorZ&) = delete;
+       CResult_ChannelMonitorUpdateDecodeErrorZ(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); }
+       CResult_ChannelMonitorUpdateDecodeErrorZ(LDKCResult_ChannelMonitorUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); }
+       operator LDKCResult_ChannelMonitorUpdateDecodeErrorZ() && { LDKCResult_ChannelMonitorUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ)); return res; }
+       ~CResult_ChannelMonitorUpdateDecodeErrorZ() { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); }
+       CResult_ChannelMonitorUpdateDecodeErrorZ& operator=(CResult_ChannelMonitorUpdateDecodeErrorZ&& o) { CResult_ChannelMonitorUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelMonitorUpdateDecodeErrorZ)); return *this; }
+       LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() { return &self; }
+       LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() { return &self; }
+       const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() const { return &self; }
+       const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() const { return &self; }
+};
+class C2Tuple_PublicKeyTypeZ {
+private:
+       LDKC2Tuple_PublicKeyTypeZ self;
+public:
+       C2Tuple_PublicKeyTypeZ(const C2Tuple_PublicKeyTypeZ&) = delete;
+       C2Tuple_PublicKeyTypeZ(C2Tuple_PublicKeyTypeZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyTypeZ)); }
+       C2Tuple_PublicKeyTypeZ(LDKC2Tuple_PublicKeyTypeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyTypeZ)); }
+       operator LDKC2Tuple_PublicKeyTypeZ() && { LDKC2Tuple_PublicKeyTypeZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyTypeZ)); return res; }
+       ~C2Tuple_PublicKeyTypeZ() { C2Tuple_PublicKeyTypeZ_free(self); }
+       C2Tuple_PublicKeyTypeZ& operator=(C2Tuple_PublicKeyTypeZ&& o) { C2Tuple_PublicKeyTypeZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyTypeZ)); return *this; }
+       LDKC2Tuple_PublicKeyTypeZ* operator &() { return &self; }
+       LDKC2Tuple_PublicKeyTypeZ* operator ->() { return &self; }
+       const LDKC2Tuple_PublicKeyTypeZ* operator &() const { return &self; }
+       const LDKC2Tuple_PublicKeyTypeZ* operator ->() const { return &self; }
+};
 class CResult_NetAddressDecodeErrorZ {
 private:
        LDKCResult_NetAddressDecodeErrorZ self;
@@ -3227,6 +3468,21 @@ public:
        const LDKCResult_NetAddressDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_NetAddressDecodeErrorZ* operator ->() const { return &self; }
 };
+class CResult_ChannelReestablishDecodeErrorZ {
+private:
+       LDKCResult_ChannelReestablishDecodeErrorZ self;
+public:
+       CResult_ChannelReestablishDecodeErrorZ(const CResult_ChannelReestablishDecodeErrorZ&) = delete;
+       CResult_ChannelReestablishDecodeErrorZ(CResult_ChannelReestablishDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelReestablishDecodeErrorZ)); }
+       CResult_ChannelReestablishDecodeErrorZ(LDKCResult_ChannelReestablishDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelReestablishDecodeErrorZ)); }
+       operator LDKCResult_ChannelReestablishDecodeErrorZ() && { LDKCResult_ChannelReestablishDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelReestablishDecodeErrorZ)); return res; }
+       ~CResult_ChannelReestablishDecodeErrorZ() { CResult_ChannelReestablishDecodeErrorZ_free(self); }
+       CResult_ChannelReestablishDecodeErrorZ& operator=(CResult_ChannelReestablishDecodeErrorZ&& o) { CResult_ChannelReestablishDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelReestablishDecodeErrorZ)); return *this; }
+       LDKCResult_ChannelReestablishDecodeErrorZ* operator &() { return &self; }
+       LDKCResult_ChannelReestablishDecodeErrorZ* operator ->() { return &self; }
+       const LDKCResult_ChannelReestablishDecodeErrorZ* operator &() const { return &self; }
+       const LDKCResult_ChannelReestablishDecodeErrorZ* operator ->() const { return &self; }
+};
 class CResult_UnsignedNodeAnnouncementDecodeErrorZ {
 private:
        LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ self;
@@ -3257,51 +3513,6 @@ public:
        const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_ReplyChannelRangeDecodeErrorZ* operator ->() const { return &self; }
 };
-class CResult_ChannelReestablishDecodeErrorZ {
-private:
-       LDKCResult_ChannelReestablishDecodeErrorZ self;
-public:
-       CResult_ChannelReestablishDecodeErrorZ(const CResult_ChannelReestablishDecodeErrorZ&) = delete;
-       CResult_ChannelReestablishDecodeErrorZ(CResult_ChannelReestablishDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelReestablishDecodeErrorZ)); }
-       CResult_ChannelReestablishDecodeErrorZ(LDKCResult_ChannelReestablishDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelReestablishDecodeErrorZ)); }
-       operator LDKCResult_ChannelReestablishDecodeErrorZ() && { LDKCResult_ChannelReestablishDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelReestablishDecodeErrorZ)); return res; }
-       ~CResult_ChannelReestablishDecodeErrorZ() { CResult_ChannelReestablishDecodeErrorZ_free(self); }
-       CResult_ChannelReestablishDecodeErrorZ& operator=(CResult_ChannelReestablishDecodeErrorZ&& o) { CResult_ChannelReestablishDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelReestablishDecodeErrorZ)); return *this; }
-       LDKCResult_ChannelReestablishDecodeErrorZ* operator &() { return &self; }
-       LDKCResult_ChannelReestablishDecodeErrorZ* operator ->() { return &self; }
-       const LDKCResult_ChannelReestablishDecodeErrorZ* operator &() const { return &self; }
-       const LDKCResult_ChannelReestablishDecodeErrorZ* operator ->() const { return &self; }
-};
-class CResult_GossipTimestampFilterDecodeErrorZ {
-private:
-       LDKCResult_GossipTimestampFilterDecodeErrorZ self;
-public:
-       CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete;
-       CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); }
-       CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); }
-       operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; }
-       ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); }
-       CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; }
-       LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; }
-       LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; }
-       const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; }
-       const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; }
-};
-class CResult_InvoiceSignOrCreationErrorZ {
-private:
-       LDKCResult_InvoiceSignOrCreationErrorZ self;
-public:
-       CResult_InvoiceSignOrCreationErrorZ(const CResult_InvoiceSignOrCreationErrorZ&) = delete;
-       CResult_InvoiceSignOrCreationErrorZ(CResult_InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); }
-       CResult_InvoiceSignOrCreationErrorZ(LDKCResult_InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); }
-       operator LDKCResult_InvoiceSignOrCreationErrorZ() && { LDKCResult_InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); return res; }
-       ~CResult_InvoiceSignOrCreationErrorZ() { CResult_InvoiceSignOrCreationErrorZ_free(self); }
-       CResult_InvoiceSignOrCreationErrorZ& operator=(CResult_InvoiceSignOrCreationErrorZ&& o) { CResult_InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); return *this; }
-       LDKCResult_InvoiceSignOrCreationErrorZ* operator &() { return &self; }
-       LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() { return &self; }
-       const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; }
-       const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; }
-};
 class CResult_CommitmentSignedDecodeErrorZ {
 private:
        LDKCResult_CommitmentSignedDecodeErrorZ self;
@@ -3332,6 +3543,21 @@ public:
        const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; }
        const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; }
 };
+class CResult_GossipTimestampFilterDecodeErrorZ {
+private:
+       LDKCResult_GossipTimestampFilterDecodeErrorZ self;
+public:
+       CResult_GossipTimestampFilterDecodeErrorZ(const CResult_GossipTimestampFilterDecodeErrorZ&) = delete;
+       CResult_GossipTimestampFilterDecodeErrorZ(CResult_GossipTimestampFilterDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); }
+       CResult_GossipTimestampFilterDecodeErrorZ(LDKCResult_GossipTimestampFilterDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); }
+       operator LDKCResult_GossipTimestampFilterDecodeErrorZ() && { LDKCResult_GossipTimestampFilterDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ)); return res; }
+       ~CResult_GossipTimestampFilterDecodeErrorZ() { CResult_GossipTimestampFilterDecodeErrorZ_free(self); }
+       CResult_GossipTimestampFilterDecodeErrorZ& operator=(CResult_GossipTimestampFilterDecodeErrorZ&& o) { CResult_GossipTimestampFilterDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_GossipTimestampFilterDecodeErrorZ)); return *this; }
+       LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() { return &self; }
+       LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() { return &self; }
+       const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; }
+       const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; }
+};
 class COption_u32Z {
 private:
        LDKCOption_u32Z self;
@@ -3377,6 +3603,36 @@ public:
        const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* operator ->() const { return &self; }
 };
+class CResult_InvoiceSignOrCreationErrorZ {
+private:
+       LDKCResult_InvoiceSignOrCreationErrorZ self;
+public:
+       CResult_InvoiceSignOrCreationErrorZ(const CResult_InvoiceSignOrCreationErrorZ&) = delete;
+       CResult_InvoiceSignOrCreationErrorZ(CResult_InvoiceSignOrCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); }
+       CResult_InvoiceSignOrCreationErrorZ(LDKCResult_InvoiceSignOrCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); }
+       operator LDKCResult_InvoiceSignOrCreationErrorZ() && { LDKCResult_InvoiceSignOrCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceSignOrCreationErrorZ)); return res; }
+       ~CResult_InvoiceSignOrCreationErrorZ() { CResult_InvoiceSignOrCreationErrorZ_free(self); }
+       CResult_InvoiceSignOrCreationErrorZ& operator=(CResult_InvoiceSignOrCreationErrorZ&& o) { CResult_InvoiceSignOrCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceSignOrCreationErrorZ)); return *this; }
+       LDKCResult_InvoiceSignOrCreationErrorZ* operator &() { return &self; }
+       LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() { return &self; }
+       const LDKCResult_InvoiceSignOrCreationErrorZ* operator &() const { return &self; }
+       const LDKCResult_InvoiceSignOrCreationErrorZ* operator ->() const { return &self; }
+};
+class COption_FilterZ {
+private:
+       LDKCOption_FilterZ self;
+public:
+       COption_FilterZ(const COption_FilterZ&) = delete;
+       COption_FilterZ(COption_FilterZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_FilterZ)); }
+       COption_FilterZ(LDKCOption_FilterZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_FilterZ)); }
+       operator LDKCOption_FilterZ() && { LDKCOption_FilterZ res = self; memset(&self, 0, sizeof(LDKCOption_FilterZ)); return res; }
+       ~COption_FilterZ() { COption_FilterZ_free(self); }
+       COption_FilterZ& operator=(COption_FilterZ&& o) { COption_FilterZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_FilterZ)); return *this; }
+       LDKCOption_FilterZ* operator &() { return &self; }
+       LDKCOption_FilterZ* operator ->() { return &self; }
+       const LDKCOption_FilterZ* operator &() const { return &self; }
+       const LDKCOption_FilterZ* operator ->() const { return &self; }
+};
 class CResult_CommitmentTransactionDecodeErrorZ {
 private:
        LDKCResult_CommitmentTransactionDecodeErrorZ self;
@@ -3602,21 +3858,6 @@ public:
        const LDKCResult_QueryChannelRangeDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_QueryChannelRangeDecodeErrorZ* operator ->() const { return &self; }
 };
-class C2Tuple_usizeTransactionZ {
-private:
-       LDKC2Tuple_usizeTransactionZ self;
-public:
-       C2Tuple_usizeTransactionZ(const C2Tuple_usizeTransactionZ&) = delete;
-       C2Tuple_usizeTransactionZ(C2Tuple_usizeTransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_usizeTransactionZ)); }
-       C2Tuple_usizeTransactionZ(LDKC2Tuple_usizeTransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_usizeTransactionZ)); }
-       operator LDKC2Tuple_usizeTransactionZ() && { LDKC2Tuple_usizeTransactionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_usizeTransactionZ)); return res; }
-       ~C2Tuple_usizeTransactionZ() { C2Tuple_usizeTransactionZ_free(self); }
-       C2Tuple_usizeTransactionZ& operator=(C2Tuple_usizeTransactionZ&& o) { C2Tuple_usizeTransactionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_usizeTransactionZ)); return *this; }
-       LDKC2Tuple_usizeTransactionZ* operator &() { return &self; }
-       LDKC2Tuple_usizeTransactionZ* operator ->() { return &self; }
-       const LDKC2Tuple_usizeTransactionZ* operator &() const { return &self; }
-       const LDKC2Tuple_usizeTransactionZ* operator ->() const { return &self; }
-};
 class CResult_TxCreationKeysDecodeErrorZ {
 private:
        LDKCResult_TxCreationKeysDecodeErrorZ self;
@@ -3632,6 +3873,21 @@ public:
        const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; }
 };
+class C2Tuple_usizeTransactionZ {
+private:
+       LDKC2Tuple_usizeTransactionZ self;
+public:
+       C2Tuple_usizeTransactionZ(const C2Tuple_usizeTransactionZ&) = delete;
+       C2Tuple_usizeTransactionZ(C2Tuple_usizeTransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_usizeTransactionZ)); }
+       C2Tuple_usizeTransactionZ(LDKC2Tuple_usizeTransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_usizeTransactionZ)); }
+       operator LDKC2Tuple_usizeTransactionZ() && { LDKC2Tuple_usizeTransactionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_usizeTransactionZ)); return res; }
+       ~C2Tuple_usizeTransactionZ() { C2Tuple_usizeTransactionZ_free(self); }
+       C2Tuple_usizeTransactionZ& operator=(C2Tuple_usizeTransactionZ&& o) { C2Tuple_usizeTransactionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_usizeTransactionZ)); return *this; }
+       LDKC2Tuple_usizeTransactionZ* operator &() { return &self; }
+       LDKC2Tuple_usizeTransactionZ* operator ->() { return &self; }
+       const LDKC2Tuple_usizeTransactionZ* operator &() const { return &self; }
+       const LDKC2Tuple_usizeTransactionZ* operator ->() const { return &self; }
+};
 class CResult_ChannelFeaturesDecodeErrorZ {
 private:
        LDKCResult_ChannelFeaturesDecodeErrorZ self;
@@ -3722,6 +3978,21 @@ public:
        const LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_NodeAnnouncementDecodeErrorZ* 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 CResult_HTLCOutputInCommitmentDecodeErrorZ {
 private:
        LDKCResult_HTLCOutputInCommitmentDecodeErrorZ self;
@@ -4322,20 +4593,20 @@ public:
        const LDKC2Tuple_PaymentHashPaymentSecretZ* operator &() const { return &self; }
        const LDKC2Tuple_PaymentHashPaymentSecretZ* operator ->() const { return &self; }
 };
-class CResult_AcceptChannelDecodeErrorZ {
+class COption_AccessZ {
 private:
-       LDKCResult_AcceptChannelDecodeErrorZ self;
+       LDKCOption_AccessZ self;
 public:
-       CResult_AcceptChannelDecodeErrorZ(const CResult_AcceptChannelDecodeErrorZ&) = delete;
-       CResult_AcceptChannelDecodeErrorZ(CResult_AcceptChannelDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); }
-       CResult_AcceptChannelDecodeErrorZ(LDKCResult_AcceptChannelDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); }
-       operator LDKCResult_AcceptChannelDecodeErrorZ() && { LDKCResult_AcceptChannelDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); return res; }
-       ~CResult_AcceptChannelDecodeErrorZ() { CResult_AcceptChannelDecodeErrorZ_free(self); }
-       CResult_AcceptChannelDecodeErrorZ& operator=(CResult_AcceptChannelDecodeErrorZ&& o) { CResult_AcceptChannelDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); return *this; }
-       LDKCResult_AcceptChannelDecodeErrorZ* operator &() { return &self; }
-       LDKCResult_AcceptChannelDecodeErrorZ* operator ->() { return &self; }
-       const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; }
-       const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; }
+       COption_AccessZ(const COption_AccessZ&) = delete;
+       COption_AccessZ(COption_AccessZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_AccessZ)); }
+       COption_AccessZ(LDKCOption_AccessZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_AccessZ)); }
+       operator LDKCOption_AccessZ() && { LDKCOption_AccessZ res = self; memset(&self, 0, sizeof(LDKCOption_AccessZ)); return res; }
+       ~COption_AccessZ() { COption_AccessZ_free(self); }
+       COption_AccessZ& operator=(COption_AccessZ&& o) { COption_AccessZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_AccessZ)); return *this; }
+       LDKCOption_AccessZ* operator &() { return &self; }
+       LDKCOption_AccessZ* operator ->() { return &self; }
+       const LDKCOption_AccessZ* operator &() const { return &self; }
+       const LDKCOption_AccessZ* operator ->() const { return &self; }
 };
 class C2Tuple_BlockHashChannelManagerZ {
 private:
@@ -4367,20 +4638,20 @@ public:
        const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; }
        const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; }
 };
-class CResult_PongDecodeErrorZ {
+class CResult_AcceptChannelDecodeErrorZ {
 private:
-       LDKCResult_PongDecodeErrorZ self;
+       LDKCResult_AcceptChannelDecodeErrorZ self;
 public:
-       CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete;
-       CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); }
-       CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); }
-       operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; }
-       ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); }
-       CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; }
-       LDKCResult_PongDecodeErrorZ* operator &() { return &self; }
-       LDKCResult_PongDecodeErrorZ* operator ->() { return &self; }
-       const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; }
-       const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; }
+       CResult_AcceptChannelDecodeErrorZ(const CResult_AcceptChannelDecodeErrorZ&) = delete;
+       CResult_AcceptChannelDecodeErrorZ(CResult_AcceptChannelDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); }
+       CResult_AcceptChannelDecodeErrorZ(LDKCResult_AcceptChannelDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); }
+       operator LDKCResult_AcceptChannelDecodeErrorZ() && { LDKCResult_AcceptChannelDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_AcceptChannelDecodeErrorZ)); return res; }
+       ~CResult_AcceptChannelDecodeErrorZ() { CResult_AcceptChannelDecodeErrorZ_free(self); }
+       CResult_AcceptChannelDecodeErrorZ& operator=(CResult_AcceptChannelDecodeErrorZ&& o) { CResult_AcceptChannelDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_AcceptChannelDecodeErrorZ)); return *this; }
+       LDKCResult_AcceptChannelDecodeErrorZ* operator &() { return &self; }
+       LDKCResult_AcceptChannelDecodeErrorZ* operator ->() { return &self; }
+       const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; }
+       const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; }
 };
 class CVec_SignatureZ {
 private:
@@ -4412,6 +4683,21 @@ public:
        const LDKCVec_u64Z* operator &() const { return &self; }
        const LDKCVec_u64Z* operator ->() const { return &self; }
 };
+class CResult_PongDecodeErrorZ {
+private:
+       LDKCResult_PongDecodeErrorZ self;
+public:
+       CResult_PongDecodeErrorZ(const CResult_PongDecodeErrorZ&) = delete;
+       CResult_PongDecodeErrorZ(CResult_PongDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); }
+       CResult_PongDecodeErrorZ(LDKCResult_PongDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); }
+       operator LDKCResult_PongDecodeErrorZ() && { LDKCResult_PongDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PongDecodeErrorZ)); return res; }
+       ~CResult_PongDecodeErrorZ() { CResult_PongDecodeErrorZ_free(self); }
+       CResult_PongDecodeErrorZ& operator=(CResult_PongDecodeErrorZ&& o) { CResult_PongDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PongDecodeErrorZ)); return *this; }
+       LDKCResult_PongDecodeErrorZ* operator &() { return &self; }
+       LDKCResult_PongDecodeErrorZ* operator ->() { return &self; }
+       const LDKCResult_PongDecodeErrorZ* operator &() const { return &self; }
+       const LDKCResult_PongDecodeErrorZ* operator ->() const { return &self; }
+};
 class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ {
 private:
        LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ self;
@@ -4592,6 +4878,21 @@ public:
        const LDKCResult_DescriptionCreationErrorZ* operator &() const { return &self; }
        const LDKCResult_DescriptionCreationErrorZ* operator ->() const { return &self; }
 };
+class CVec_C2Tuple_PublicKeyTypeZZ {
+private:
+       LDKCVec_C2Tuple_PublicKeyTypeZZ self;
+public:
+       CVec_C2Tuple_PublicKeyTypeZZ(const CVec_C2Tuple_PublicKeyTypeZZ&) = delete;
+       CVec_C2Tuple_PublicKeyTypeZZ(CVec_C2Tuple_PublicKeyTypeZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyTypeZZ)); }
+       CVec_C2Tuple_PublicKeyTypeZZ(LDKCVec_C2Tuple_PublicKeyTypeZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ)); }
+       operator LDKCVec_C2Tuple_PublicKeyTypeZZ() && { LDKCVec_C2Tuple_PublicKeyTypeZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ)); return res; }
+       ~CVec_C2Tuple_PublicKeyTypeZZ() { CVec_C2Tuple_PublicKeyTypeZZ_free(self); }
+       CVec_C2Tuple_PublicKeyTypeZZ& operator=(CVec_C2Tuple_PublicKeyTypeZZ&& o) { CVec_C2Tuple_PublicKeyTypeZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyTypeZZ)); return *this; }
+       LDKCVec_C2Tuple_PublicKeyTypeZZ* operator &() { return &self; }
+       LDKCVec_C2Tuple_PublicKeyTypeZZ* operator ->() { return &self; }
+       const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator &() const { return &self; }
+       const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator ->() const { return &self; }
+};
 class CResult_RoutingFeesDecodeErrorZ {
 private:
        LDKCResult_RoutingFeesDecodeErrorZ self;
@@ -4742,6 +5043,36 @@ public:
        const LDKCVec_PublicKeyZ* operator &() const { return &self; }
        const LDKCVec_PublicKeyZ* operator ->() const { return &self; }
 };
+class COption_TypeZ {
+private:
+       LDKCOption_TypeZ self;
+public:
+       COption_TypeZ(const COption_TypeZ&) = delete;
+       COption_TypeZ(COption_TypeZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_TypeZ)); }
+       COption_TypeZ(LDKCOption_TypeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_TypeZ)); }
+       operator LDKCOption_TypeZ() && { LDKCOption_TypeZ res = self; memset(&self, 0, sizeof(LDKCOption_TypeZ)); return res; }
+       ~COption_TypeZ() { COption_TypeZ_free(self); }
+       COption_TypeZ& operator=(COption_TypeZ&& o) { COption_TypeZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_TypeZ)); return *this; }
+       LDKCOption_TypeZ* operator &() { return &self; }
+       LDKCOption_TypeZ* operator ->() { return &self; }
+       const LDKCOption_TypeZ* operator &() const { return &self; }
+       const LDKCOption_TypeZ* operator ->() const { return &self; }
+};
+class CResult_COption_TypeZDecodeErrorZ {
+private:
+       LDKCResult_COption_TypeZDecodeErrorZ self;
+public:
+       CResult_COption_TypeZDecodeErrorZ(const CResult_COption_TypeZDecodeErrorZ&) = delete;
+       CResult_COption_TypeZDecodeErrorZ(CResult_COption_TypeZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_TypeZDecodeErrorZ)); }
+       CResult_COption_TypeZDecodeErrorZ(LDKCResult_COption_TypeZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_TypeZDecodeErrorZ)); }
+       operator LDKCResult_COption_TypeZDecodeErrorZ() && { LDKCResult_COption_TypeZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_TypeZDecodeErrorZ)); return res; }
+       ~CResult_COption_TypeZDecodeErrorZ() { CResult_COption_TypeZDecodeErrorZ_free(self); }
+       CResult_COption_TypeZDecodeErrorZ& operator=(CResult_COption_TypeZDecodeErrorZ&& o) { CResult_COption_TypeZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_TypeZDecodeErrorZ)); return *this; }
+       LDKCResult_COption_TypeZDecodeErrorZ* operator &() { return &self; }
+       LDKCResult_COption_TypeZDecodeErrorZ* operator ->() { return &self; }
+       const LDKCResult_COption_TypeZDecodeErrorZ* operator &() const { return &self; }
+       const LDKCResult_COption_TypeZDecodeErrorZ* operator ->() const { return &self; }
+};
 class CResult_DirectionalChannelInfoDecodeErrorZ {
 private:
        LDKCResult_DirectionalChannelInfoDecodeErrorZ self;
@@ -5012,6 +5343,21 @@ public:
        const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; }
        const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; }
 };
+class CResult_NoneNoneZ {
+private:
+       LDKCResult_NoneNoneZ self;
+public:
+       CResult_NoneNoneZ(const CResult_NoneNoneZ&) = delete;
+       CResult_NoneNoneZ(CResult_NoneNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneNoneZ)); }
+       CResult_NoneNoneZ(LDKCResult_NoneNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneNoneZ)); }
+       operator LDKCResult_NoneNoneZ() && { LDKCResult_NoneNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneNoneZ)); return res; }
+       ~CResult_NoneNoneZ() { CResult_NoneNoneZ_free(self); }
+       CResult_NoneNoneZ& operator=(CResult_NoneNoneZ&& o) { CResult_NoneNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneNoneZ)); return *this; }
+       LDKCResult_NoneNoneZ* operator &() { return &self; }
+       LDKCResult_NoneNoneZ* operator ->() { return &self; }
+       const LDKCResult_NoneNoneZ* operator &() const { return &self; }
+       const LDKCResult_NoneNoneZ* operator ->() const { return &self; }
+};
 class CResult_PrivateRouteCreationErrorZ {
 private:
        LDKCResult_PrivateRouteCreationErrorZ self;
@@ -5042,21 +5388,6 @@ public:
        const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; }
        const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; }
 };
-class CResult_ChannelUpdateDecodeErrorZ {
-private:
-       LDKCResult_ChannelUpdateDecodeErrorZ self;
-public:
-       CResult_ChannelUpdateDecodeErrorZ(const CResult_ChannelUpdateDecodeErrorZ&) = delete;
-       CResult_ChannelUpdateDecodeErrorZ(CResult_ChannelUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); }
-       CResult_ChannelUpdateDecodeErrorZ(LDKCResult_ChannelUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); }
-       operator LDKCResult_ChannelUpdateDecodeErrorZ() && { LDKCResult_ChannelUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); return res; }
-       ~CResult_ChannelUpdateDecodeErrorZ() { CResult_ChannelUpdateDecodeErrorZ_free(self); }
-       CResult_ChannelUpdateDecodeErrorZ& operator=(CResult_ChannelUpdateDecodeErrorZ&& o) { CResult_ChannelUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); return *this; }
-       LDKCResult_ChannelUpdateDecodeErrorZ* operator &() { return &self; }
-       LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() { return &self; }
-       const LDKCResult_ChannelUpdateDecodeErrorZ* operator &() const { return &self; }
-       const LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() const { return &self; }
-};
 class CVec_APIErrorZ {
 private:
        LDKCVec_APIErrorZ self;
@@ -5072,6 +5403,21 @@ public:
        const LDKCVec_APIErrorZ* operator &() const { return &self; }
        const LDKCVec_APIErrorZ* operator ->() const { return &self; }
 };
+class CResult_ChannelUpdateDecodeErrorZ {
+private:
+       LDKCResult_ChannelUpdateDecodeErrorZ self;
+public:
+       CResult_ChannelUpdateDecodeErrorZ(const CResult_ChannelUpdateDecodeErrorZ&) = delete;
+       CResult_ChannelUpdateDecodeErrorZ(CResult_ChannelUpdateDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); }
+       CResult_ChannelUpdateDecodeErrorZ(LDKCResult_ChannelUpdateDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); }
+       operator LDKCResult_ChannelUpdateDecodeErrorZ() && { LDKCResult_ChannelUpdateDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelUpdateDecodeErrorZ)); return res; }
+       ~CResult_ChannelUpdateDecodeErrorZ() { CResult_ChannelUpdateDecodeErrorZ_free(self); }
+       CResult_ChannelUpdateDecodeErrorZ& operator=(CResult_ChannelUpdateDecodeErrorZ&& o) { CResult_ChannelUpdateDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelUpdateDecodeErrorZ)); return *this; }
+       LDKCResult_ChannelUpdateDecodeErrorZ* operator &() { return &self; }
+       LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() { return &self; }
+       const LDKCResult_ChannelUpdateDecodeErrorZ* operator &() const { return &self; }
+       const LDKCResult_ChannelUpdateDecodeErrorZ* operator ->() const { return &self; }
+};
 class CVec_UpdateFulfillHTLCZ {
 private:
        LDKCVec_UpdateFulfillHTLCZ self;
@@ -5358,7 +5704,7 @@ 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) {
+inline void EventHandler::handle_event(const struct LDKEvent *NONNULL_PTR event) {
        (self.handle_event)(self.this_arg, event);
 }
 inline LDKPublicKey BaseSign::get_per_commitment_point(uint64_t idx) {
@@ -5369,6 +5715,10 @@ inline LDKThirtyTwoBytes BaseSign::release_commitment_secret(uint64_t idx) {
        LDKThirtyTwoBytes ret = (self.release_commitment_secret)(self.this_arg, idx);
        return ret;
 }
+inline LDK::CResult_NoneNoneZ BaseSign::validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx) {
+       LDK::CResult_NoneNoneZ ret = (self.validate_holder_commitment)(self.this_arg, holder_tx);
+       return ret;
+}
 inline LDKThirtyTwoBytes BaseSign::channel_keys_id() {
        LDKThirtyTwoBytes ret = (self.channel_keys_id)(self.this_arg);
        return ret;
@@ -5377,6 +5727,10 @@ inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ BaseSign::sign_counte
        LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = (self.sign_counterparty_commitment)(self.this_arg, commitment_tx);
        return ret;
 }
+inline LDK::CResult_NoneNoneZ BaseSign::validate_counterparty_revocation(uint64_t idx, const uint8_t (*secret)[32]) {
+       LDK::CResult_NoneNoneZ ret = (self.validate_counterparty_revocation)(self.this_arg, idx, secret);
+       return ret;
+}
 inline LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ BaseSign::sign_holder_commitment_and_htlcs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx) {
        LDK::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, commitment_tx);
        return ret;
@@ -5393,7 +5747,7 @@ inline LDK::CResult_SignatureNoneZ BaseSign::sign_counterparty_htlc_transaction(
        LDK::CResult_SignatureNoneZ ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, htlc_tx, input, amount, per_commitment_point, htlc);
        return ret;
 }
-inline LDK::CResult_SignatureNoneZ BaseSign::sign_closing_transaction(struct LDKTransaction closing_tx) {
+inline LDK::CResult_SignatureNoneZ BaseSign::sign_closing_transaction(const struct LDKClosingTransaction *NONNULL_PTR closing_tx) {
        LDK::CResult_SignatureNoneZ ret = (self.sign_closing_transaction)(self.this_arg, closing_tx);
        return ret;
 }
@@ -5432,6 +5786,18 @@ inline LDK::CResult_RecoverableSignatureNoneZ KeysInterface::sign_invoice(struct
        LDK::CResult_RecoverableSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, invoice_preimage);
        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);
+       return ret;
+}
+inline uint16_t Type::type_id() {
+       uint16_t ret = (self.type_id)(self.this_arg);
+       return ret;
+}
+inline LDK::Str Type::debug_str() {
+       LDK::Str ret = (self.debug_str)(self.this_arg);
+       return ret;
+}
 inline LDK::CResult_NoneChannelMonitorUpdateErrZ Persist::persist_new_channel(struct LDKOutPoint id, const struct LDKChannelMonitor *NONNULL_PTR data) {
        LDK::CResult_NoneChannelMonitorUpdateErrZ ret = (self.persist_new_channel)(self.this_arg, id, data);
        return ret;
@@ -5440,6 +5806,14 @@ inline LDK::CResult_NoneChannelMonitorUpdateErrZ Persist::update_persisted_chann
        LDK::CResult_NoneChannelMonitorUpdateErrZ ret = (self.update_persisted_channel)(self.this_arg, id, update, data);
        return ret;
 }
+inline LDK::CResult_NoneLightningErrorZ CustomMessageHandler::handle_custom_message(struct LDKType msg, struct LDKPublicKey sender_node_id) {
+       LDK::CResult_NoneLightningErrorZ ret = (self.handle_custom_message)(self.this_arg, msg, sender_node_id);
+       return ret;
+}
+inline LDK::CVec_C2Tuple_PublicKeyTypeZZ CustomMessageHandler::get_and_clear_pending_msg() {
+       LDK::CVec_C2Tuple_PublicKeyTypeZZ ret = (self.get_and_clear_pending_msg)(self.this_arg);
+       return ret;
+}
 inline uintptr_t SocketDescriptor::send_data(struct LDKu8slice data, bool resume_read) {
        uintptr_t ret = (self.send_data)(self.this_arg, data, resume_read);
        return ret;
@@ -5527,9 +5901,6 @@ inline LDK::CResult_boolLightningErrorZ RoutingMessageHandler::handle_channel_up
        LDK::CResult_boolLightningErrorZ ret = (self.handle_channel_update)(self.this_arg, msg);
        return ret;
 }
-inline void RoutingMessageHandler::handle_htlc_fail_channel_update(const struct LDKHTLCFailChannelUpdate *NONNULL_PTR update) {
-       (self.handle_htlc_fail_channel_update)(self.this_arg, update);
-}
 inline LDK::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ RoutingMessageHandler::get_next_channel_announcements(uint64_t starting_point, uint8_t batch_amount) {
        LDK::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
        return ret;
index c9f31236e621a54ec41f1635078b4d9581eb4f75..cdc062788f781e244ef31941429e66830679f361 100644 (file)
@@ -162,7 +162,7 @@ impl Clone for CResult_PublicKeyErrorZ {
 #[no_mangle]
 /// Creates a new CResult_PublicKeyErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_PublicKeyErrorZ_clone(orig: &CResult_PublicKeyErrorZ) -> CResult_PublicKeyErrorZ { orig.clone() }
+pub extern "C" fn CResult_PublicKeyErrorZ_clone(orig: &CResult_PublicKeyErrorZ) -> CResult_PublicKeyErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_TxCreationKeysDecodeErrorZ
 pub union CResult_TxCreationKeysDecodeErrorZPtr {
@@ -253,7 +253,7 @@ impl Clone for CResult_TxCreationKeysDecodeErrorZ {
 #[no_mangle]
 /// 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_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ChannelPublicKeysDecodeErrorZ
 pub union CResult_ChannelPublicKeysDecodeErrorZPtr {
@@ -344,7 +344,7 @@ impl Clone for CResult_ChannelPublicKeysDecodeErrorZ {
 #[no_mangle]
 /// 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_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_TxCreationKeysErrorZ
 pub union CResult_TxCreationKeysErrorZPtr {
@@ -435,7 +435,7 @@ impl Clone for CResult_TxCreationKeysErrorZ {
 #[no_mangle]
 /// Creates a new CResult_TxCreationKeysErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_TxCreationKeysErrorZ_clone(orig: &CResult_TxCreationKeysErrorZ) -> CResult_TxCreationKeysErrorZ { orig.clone() }
+pub extern "C" fn CResult_TxCreationKeysErrorZ_clone(orig: &CResult_TxCreationKeysErrorZ) -> CResult_TxCreationKeysErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 #[derive(Clone)]
 /// An enum which can either contain a u32 or not
@@ -449,6 +449,9 @@ impl COption_u32Z {
        #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
                if let Self::Some(_) = self { true } else { false }
        }
+       #[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!() }
        }
@@ -469,7 +472,7 @@ 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 { orig.clone() }
+pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ
 pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr {
@@ -560,7 +563,7 @@ impl Clone for CResult_HTLCOutputInCommitmentDecodeErrorZ {
 #[no_mangle]
 /// 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_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ
 pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr {
@@ -651,7 +654,7 @@ impl Clone for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ {
 #[no_mangle]
 /// 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_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { orig.clone() }
+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 {
@@ -742,7 +745,7 @@ impl Clone for CResult_ChannelTransactionParametersDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of crate::c_types::Signatures of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -879,7 +882,7 @@ impl Clone for CResult_HolderCommitmentTransactionDecodeErrorZ {
 #[no_mangle]
 /// 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_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ
 pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr {
@@ -970,7 +973,77 @@ impl Clone for CResult_BuiltCommitmentTransactionDecodeErrorZ {
 #[no_mangle]
 /// 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_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) }
+#[repr(C)]
+/// 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::chan_utils::TrustedClosingTransaction,
+       /// Note that this value is always NULL, as there are no contents in the Err variant
+       pub err: *mut std::ffi::c_void,
+}
+#[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.
+/// `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
+       /// `err` or `result` depending on the state of `result_ok`.
+       pub contents: CResult_TrustedClosingTransactionNoneZPtr,
+       /// Whether this CResult_TrustedClosingTransactionNoneZ 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 {
+                       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: std::ptr::null_mut(),
+               },
+               result_ok: false,
+       }
+}
+#[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 {
+       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<crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::TrustedClosingTransaction, ()>> for CResult_TrustedClosingTransactionNoneZ {
+       fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::TrustedClosingTransaction, ()>) -> Self {
+               let contents = if o.result_ok {
+                       let result = unsafe { o.contents.result };
+                       unsafe { o.contents.result = std::ptr::null_mut() };
+                       CResult_TrustedClosingTransactionNoneZPtr { result }
+               } else {
+                       let _ = unsafe { Box::from_raw(o.contents.err) };
+                       o.contents.err = std::ptr::null_mut();
+                       CResult_TrustedClosingTransactionNoneZPtr { err: std::ptr::null_mut() }
+               };
+               Self {
+                       contents,
+                       result_ok: o.result_ok,
+               }
+       }
+}
 #[repr(C)]
 /// The contents of CResult_CommitmentTransactionDecodeErrorZ
 pub union CResult_CommitmentTransactionDecodeErrorZPtr {
@@ -1061,7 +1134,7 @@ impl Clone for CResult_CommitmentTransactionDecodeErrorZ {
 #[no_mangle]
 /// 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_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { orig.clone() }
+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 {
@@ -1218,7 +1291,7 @@ impl Clone for CResult_CVec_SignatureZNoneZ {
 #[no_mangle]
 /// Creates a new CResult_CVec_SignatureZNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { orig.clone() }
+pub extern "C" fn CResult_CVec_SignatureZNoneZ_clone(orig: &CResult_CVec_SignatureZNoneZ) -> CResult_CVec_SignatureZNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ShutdownScriptDecodeErrorZ
 pub union CResult_ShutdownScriptDecodeErrorZPtr {
@@ -1309,7 +1382,7 @@ impl Clone for CResult_ShutdownScriptDecodeErrorZ {
 #[no_mangle]
 /// 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_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ
 pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr {
@@ -1470,7 +1543,7 @@ impl Clone for CResult_NoneErrorZ {
 #[no_mangle]
 /// Creates a new CResult_NoneErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NoneErrorZ_clone(orig: &CResult_NoneErrorZ) -> CResult_NoneErrorZ { orig.clone() }
+pub extern "C" fn CResult_NoneErrorZ_clone(orig: &CResult_NoneErrorZ) -> CResult_NoneErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_RouteHopDecodeErrorZ
 pub union CResult_RouteHopDecodeErrorZPtr {
@@ -1561,7 +1634,7 @@ impl Clone for CResult_RouteHopDecodeErrorZ {
 #[no_mangle]
 /// 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_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { 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++
@@ -1744,7 +1817,7 @@ impl Clone for CResult_RouteDecodeErrorZ {
 #[no_mangle]
 /// 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 { orig.clone() }
+pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 #[derive(Clone)]
 /// An enum which can either contain a u64 or not
@@ -1758,6 +1831,9 @@ impl COption_u64Z {
        #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
                if let Self::Some(_) = self { true } else { false }
        }
+       #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
+               !self.is_some()
+       }
        #[allow(unused)] pub(crate) fn take(mut self) -> u64 {
                if let Self::Some(v) = self { v } else { unreachable!() }
        }
@@ -1778,7 +1854,7 @@ pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { }
 #[no_mangle]
 /// Creates a new COption_u64Z which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { orig.clone() }
+pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { 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++
@@ -1961,7 +2037,7 @@ impl Clone for CResult_RouteLightningErrorZ {
 #[no_mangle]
 /// 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_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { orig.clone() }
+pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_TxOutAccessErrorZ
 pub union CResult_TxOutAccessErrorZPtr {
@@ -2052,7 +2128,7 @@ impl Clone for CResult_TxOutAccessErrorZ {
 #[no_mangle]
 /// Creates a new CResult_TxOutAccessErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_TxOutAccessErrorZ_clone(orig: &CResult_TxOutAccessErrorZ) -> CResult_TxOutAccessErrorZ { orig.clone() }
+pub extern "C" fn CResult_TxOutAccessErrorZ_clone(orig: &CResult_TxOutAccessErrorZ) -> CResult_TxOutAccessErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A tuple of 2 elements. See the individual fields for the types contained.
 pub struct C2Tuple_usizeTransactionZ {
@@ -2077,15 +2153,15 @@ impl C2Tuple_usizeTransactionZ {
 impl Clone for C2Tuple_usizeTransactionZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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 { orig.clone() }
+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 {
@@ -2273,7 +2349,7 @@ impl Clone for CResult_NoneChannelMonitorUpdateErrZ {
 #[no_mangle]
 /// Creates a new CResult_NoneChannelMonitorUpdateErrZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_clone(orig: &CResult_NoneChannelMonitorUpdateErrZ) -> CResult_NoneChannelMonitorUpdateErrZ { orig.clone() }
+pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_clone(orig: &CResult_NoneChannelMonitorUpdateErrZ) -> CResult_NoneChannelMonitorUpdateErrZ { 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++
@@ -2333,6 +2409,9 @@ impl COption_C2Tuple_usizeTransactionZZ {
        #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
                if let Self::Some(_) = self { true } else { false }
        }
+       #[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_usizeTransactionZ {
                if let Self::Some(v) = self { v } else { unreachable!() }
        }
@@ -2353,7 +2432,44 @@ pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_free(_res: COption_C2Tuple_
 #[no_mangle]
 /// Creates a new COption_C2Tuple_usizeTransactionZZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_clone(orig: &COption_C2Tuple_usizeTransactionZZ) -> COption_C2Tuple_usizeTransactionZZ { orig.clone() }
+pub extern "C" fn COption_C2Tuple_usizeTransactionZZ_clone(orig: &COption_C2Tuple_usizeTransactionZZ) -> COption_C2Tuple_usizeTransactionZZ { Clone::clone(&orig) }
+#[repr(C)]
+#[derive(Clone)]
+/// An enum which can either contain a crate::lightning::routing::network_graph::NetworkUpdate or not
+pub enum COption_NetworkUpdateZ {
+       /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::network_graph::NetworkUpdate
+       Some(crate::lightning::routing::network_graph::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::Some(_) = self { true } else { false }
+       }
+       #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
+               !self.is_some()
+       }
+       #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::network_graph::NetworkUpdate {
+               if let Self::Some(v) = self { v } else { unreachable!() }
+       }
+}
+#[no_mangle]
+/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::network_graph::NetworkUpdate
+pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::network_graph::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::network_graph::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)]
 /// A dynamically-allocated array of crate::lightning::chain::keysinterface::SpendableOutputDescriptors of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -2832,7 +2948,7 @@ impl Clone for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ {
 #[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 { orig.clone() }
+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 {
@@ -2923,7 +3039,7 @@ impl Clone for CResult_StaticPaymentOutputDescriptorDecodeErrorZ {
 #[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 { orig.clone() }
+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 {
@@ -3014,7 +3130,90 @@ impl Clone for CResult_SpendableOutputDescriptorDecodeErrorZ {
 #[no_mangle]
 /// 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_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { 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 std::ffi::c_void,
+       /// Note that this value is always NULL, as there are no contents in the Err variant
+       pub err: *mut std::ffi::c_void,
+}
+#[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
+       /// `err` or `result` depending on the state of `result_ok`.
+       pub contents: CResult_NoneNoneZPtr,
+       /// Whether this CResult_NoneNoneZ 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: std::ptr::null_mut(),
+               },
+               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: std::ptr::null_mut(),
+               },
+               result_ok: false,
+       }
+}
+#[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 {
+       fn drop(&mut self) {
+               if self.result_ok {
+               } else {
+               }
+       }
+}
+impl From<crate::c_types::CResultTempl<(), ()>> for CResult_NoneNoneZ {
+       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 = std::ptr::null_mut();
+                       CResult_NoneNoneZPtr { result: std::ptr::null_mut() }
+               } else {
+                       let _ = unsafe { Box::from_raw(o.contents.err) };
+                       o.contents.err = std::ptr::null_mut();
+                       CResult_NoneNoneZPtr { err: std::ptr::null_mut() }
+               };
+               Self {
+                       contents,
+                       result_ok: o.result_ok,
+               }
+       }
+}
+impl Clone for CResult_NoneNoneZ {
+       fn clone(&self) -> Self {
+               if self.result_ok {
+                       Self { result_ok: true, contents: CResult_NoneNoneZPtr {
+                               result: std::ptr::null_mut()
+                       } }
+               } else {
+                       Self { result_ok: false, contents: CResult_NoneNoneZPtr {
+                               err: std::ptr::null_mut()
+                       } }
+               }
+       }
+}
+#[no_mangle]
+/// 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_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A tuple of 2 elements. See the individual fields for the types contained.
 pub struct C2Tuple_SignatureCVec_SignatureZZ {
@@ -3039,15 +3238,15 @@ impl C2Tuple_SignatureCVec_SignatureZZ {
 impl Clone for C2Tuple_SignatureCVec_SignatureZZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { orig.clone() }
+pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_clone(orig: &C2Tuple_SignatureCVec_SignatureZZ) -> C2Tuple_SignatureCVec_SignatureZZ { Clone::clone(&orig) }
 /// Creates a new C2Tuple_SignatureCVec_SignatureZZ from the contained elements.
 #[no_mangle]
 pub extern "C" fn C2Tuple_SignatureCVec_SignatureZZ_new(a: crate::c_types::Signature, b: crate::c_types::derived::CVec_SignatureZ) -> C2Tuple_SignatureCVec_SignatureZZ {
@@ -3143,7 +3342,7 @@ impl Clone for CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
 #[no_mangle]
 /// Creates a new CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { orig.clone() }
+pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig: &CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ) -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_SignatureNoneZ
 pub union CResult_SignatureNoneZPtr {
@@ -3230,7 +3429,7 @@ impl Clone for CResult_SignatureNoneZ {
 #[no_mangle]
 /// Creates a new CResult_SignatureNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { orig.clone() }
+pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_SignDecodeErrorZ
 pub union CResult_SignDecodeErrorZPtr {
@@ -3321,7 +3520,7 @@ impl Clone for CResult_SignDecodeErrorZ {
 #[no_mangle]
 /// Creates a new CResult_SignDecodeErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_SignDecodeErrorZ_clone(orig: &CResult_SignDecodeErrorZ) -> CResult_SignDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_SignDecodeErrorZ_clone(orig: &CResult_SignDecodeErrorZ) -> CResult_SignDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of u8s of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -3454,7 +3653,7 @@ impl Clone for CResult_RecoverableSignatureNoneZ {
 #[no_mangle]
 /// 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_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { orig.clone() }
+pub extern "C" fn CResult_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of crate::c_types::derived::CVec_u8Zs of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -3587,7 +3786,7 @@ impl Clone for CResult_CVec_CVec_u8ZZNoneZ {
 #[no_mangle]
 /// Creates a new CResult_CVec_CVec_u8ZZNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { orig.clone() }
+pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_InMemorySignerDecodeErrorZ
 pub union CResult_InMemorySignerDecodeErrorZPtr {
@@ -3678,7 +3877,7 @@ impl Clone for CResult_InMemorySignerDecodeErrorZ {
 #[no_mangle]
 /// 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_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -3811,7 +4010,7 @@ impl Clone for CResult_TransactionNoneZ {
 #[no_mangle]
 /// Creates a new CResult_TransactionNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_TransactionNoneZ_clone(orig: &CResult_TransactionNoneZ) -> CResult_TransactionNoneZ { orig.clone() }
+pub extern "C" fn CResult_TransactionNoneZ_clone(orig: &CResult_TransactionNoneZ) -> CResult_TransactionNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A tuple of 2 elements. See the individual fields for the types contained.
 pub struct C2Tuple_BlockHashChannelMonitorZ {
@@ -3967,6 +4166,9 @@ impl COption_u16Z {
        #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
                if let Self::Some(_) = self { true } else { false }
        }
+       #[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!() }
        }
@@ -3987,7 +4189,7 @@ 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 { orig.clone() }
+pub extern "C" fn COption_u16Z_clone(orig: &COption_u16Z) -> COption_u16Z { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_NoneAPIErrorZ
 pub union CResult_NoneAPIErrorZPtr {
@@ -4074,7 +4276,7 @@ impl Clone for CResult_NoneAPIErrorZ {
 #[no_mangle]
 /// Creates a new CResult_NoneAPIErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NoneAPIErrorZ_clone(orig: &CResult_NoneAPIErrorZ) -> CResult_NoneAPIErrorZ { orig.clone() }
+pub extern "C" fn CResult_NoneAPIErrorZ_clone(orig: &CResult_NoneAPIErrorZ) -> CResult_NoneAPIErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of crate::c_types::derived::CResult_NoneAPIErrorZs of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -4253,7 +4455,7 @@ impl Clone for CResult_NonePaymentSendFailureZ {
 #[no_mangle]
 /// 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_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { orig.clone() }
+pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_PaymentHashPaymentSendFailureZ
 pub union CResult_PaymentHashPaymentSendFailureZPtr {
@@ -4344,7 +4546,7 @@ impl Clone for CResult_PaymentHashPaymentSendFailureZ {
 #[no_mangle]
 /// Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_clone(orig: &CResult_PaymentHashPaymentSendFailureZ) -> CResult_PaymentHashPaymentSendFailureZ { orig.clone() }
+pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_clone(orig: &CResult_PaymentHashPaymentSendFailureZ) -> CResult_PaymentHashPaymentSendFailureZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -4415,15 +4617,15 @@ impl C2Tuple_PaymentHashPaymentSecretZ {
 impl Clone for C2Tuple_PaymentHashPaymentSecretZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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_PaymentHashPaymentSecretZ_clone(orig: &C2Tuple_PaymentHashPaymentSecretZ) -> C2Tuple_PaymentHashPaymentSecretZ { orig.clone() }
+pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_clone(orig: &C2Tuple_PaymentHashPaymentSecretZ) -> C2Tuple_PaymentHashPaymentSecretZ { Clone::clone(&orig) }
 /// Creates a new C2Tuple_PaymentHashPaymentSecretZ from the contained elements.
 #[no_mangle]
 pub extern "C" fn C2Tuple_PaymentHashPaymentSecretZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_PaymentHashPaymentSecretZ {
@@ -4523,7 +4725,7 @@ impl Clone for CResult_PaymentSecretAPIErrorZ {
 #[no_mangle]
 /// Creates a new CResult_PaymentSecretAPIErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_PaymentSecretAPIErrorZ_clone(orig: &CResult_PaymentSecretAPIErrorZ) -> CResult_PaymentSecretAPIErrorZ { orig.clone() }
+pub extern "C" fn CResult_PaymentSecretAPIErrorZ_clone(orig: &CResult_PaymentSecretAPIErrorZ) -> CResult_PaymentSecretAPIErrorZ { 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++
@@ -4756,7 +4958,7 @@ impl Clone for CResult_ChannelConfigDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_OutPointDecodeErrorZ
 pub union CResult_OutPointDecodeErrorZPtr {
@@ -4847,7 +5049,113 @@ impl Clone for CResult_OutPointDecodeErrorZ {
 #[no_mangle]
 /// 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 CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) }
+#[repr(C)]
+/// 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::Some(_) = self { true } else { false }
+       }
+       #[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) { }
+#[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,
+       }
+}
+#[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<crate::c_types::CResultTempl<crate::c_types::derived::COption_TypeZ, crate::lightning::ln::msgs::DecodeError>> for CResult_COption_TypeZDecodeErrorZ {
+       fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::COption_TypeZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
+               let contents = if o.result_ok {
+                       let result = unsafe { o.contents.result };
+                       unsafe { o.contents.result = std::ptr::null_mut() };
+                       CResult_COption_TypeZDecodeErrorZPtr { result }
+               } else {
+                       let err = unsafe { o.contents.err };
+                       unsafe { o.contents.err = std::ptr::null_mut(); }
+                       CResult_COption_TypeZDecodeErrorZPtr { err }
+               };
+               Self {
+                       contents,
+                       result_ok: o.result_ok,
+               }
+       }
+}
 #[repr(C)]
 /// The contents of CResult_SiPrefixNoneZ
 pub union CResult_SiPrefixNoneZPtr {
@@ -4934,7 +5242,7 @@ impl Clone for CResult_SiPrefixNoneZ {
 #[no_mangle]
 /// Creates a new CResult_SiPrefixNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_SiPrefixNoneZ_clone(orig: &CResult_SiPrefixNoneZ) -> CResult_SiPrefixNoneZ { orig.clone() }
+pub extern "C" fn CResult_SiPrefixNoneZ_clone(orig: &CResult_SiPrefixNoneZ) -> CResult_SiPrefixNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_InvoiceNoneZ
 pub union CResult_InvoiceNoneZPtr {
@@ -5021,7 +5329,7 @@ impl Clone for CResult_InvoiceNoneZ {
 #[no_mangle]
 /// Creates a new CResult_InvoiceNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_InvoiceNoneZ_clone(orig: &CResult_InvoiceNoneZ) -> CResult_InvoiceNoneZ { orig.clone() }
+pub extern "C" fn CResult_InvoiceNoneZ_clone(orig: &CResult_InvoiceNoneZ) -> CResult_InvoiceNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_SignedRawInvoiceNoneZ
 pub union CResult_SignedRawInvoiceNoneZPtr {
@@ -5108,7 +5416,7 @@ impl Clone for CResult_SignedRawInvoiceNoneZ {
 #[no_mangle]
 /// Creates a new CResult_SignedRawInvoiceNoneZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_SignedRawInvoiceNoneZ_clone(orig: &CResult_SignedRawInvoiceNoneZ) -> CResult_SignedRawInvoiceNoneZ { orig.clone() }
+pub extern "C" fn CResult_SignedRawInvoiceNoneZ_clone(orig: &CResult_SignedRawInvoiceNoneZ) -> CResult_SignedRawInvoiceNoneZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A tuple of 3 elements. See the individual fields for the types contained.
 pub struct C3Tuple_RawInvoice_u832InvoiceSignatureZ {
@@ -5136,16 +5444,16 @@ impl C3Tuple_RawInvoice_u832InvoiceSignatureZ {
 impl Clone for C3Tuple_RawInvoice_u832InvoiceSignatureZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
-                       c: self.c.clone(),
+                       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_RawInvoice_u832InvoiceSignatureZ_clone(orig: &C3Tuple_RawInvoice_u832InvoiceSignatureZ) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ { orig.clone() }
+pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig: &C3Tuple_RawInvoice_u832InvoiceSignatureZ) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ { Clone::clone(&orig) }
 /// Creates a new C3Tuple_RawInvoice_u832InvoiceSignatureZ from the contained elements.
 #[no_mangle]
 pub extern "C" fn C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a: crate::lightning_invoice::RawInvoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::InvoiceSignature) -> C3Tuple_RawInvoice_u832InvoiceSignatureZ {
@@ -5245,7 +5553,7 @@ impl Clone for CResult_PayeePubKeyErrorZ {
 #[no_mangle]
 /// Creates a new CResult_PayeePubKeyErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_PayeePubKeyErrorZ_clone(orig: &CResult_PayeePubKeyErrorZ) -> CResult_PayeePubKeyErrorZ { orig.clone() }
+pub extern "C" fn CResult_PayeePubKeyErrorZ_clone(orig: &CResult_PayeePubKeyErrorZ) -> CResult_PayeePubKeyErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -5382,7 +5690,7 @@ impl Clone for CResult_PositiveTimestampCreationErrorZ {
 #[no_mangle]
 /// 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 CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { orig.clone() }
+pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_NoneSemanticErrorZ
 pub union CResult_NoneSemanticErrorZPtr {
@@ -5469,7 +5777,7 @@ impl Clone for CResult_NoneSemanticErrorZ {
 #[no_mangle]
 /// Creates a new CResult_NoneSemanticErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NoneSemanticErrorZ_clone(orig: &CResult_NoneSemanticErrorZ) -> CResult_NoneSemanticErrorZ { orig.clone() }
+pub extern "C" fn CResult_NoneSemanticErrorZ_clone(orig: &CResult_NoneSemanticErrorZ) -> CResult_NoneSemanticErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_InvoiceSemanticErrorZ
 pub union CResult_InvoiceSemanticErrorZPtr {
@@ -5560,7 +5868,7 @@ impl Clone for CResult_InvoiceSemanticErrorZ {
 #[no_mangle]
 /// Creates a new CResult_InvoiceSemanticErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_InvoiceSemanticErrorZ_clone(orig: &CResult_InvoiceSemanticErrorZ) -> CResult_InvoiceSemanticErrorZ { orig.clone() }
+pub extern "C" fn CResult_InvoiceSemanticErrorZ_clone(orig: &CResult_InvoiceSemanticErrorZ) -> CResult_InvoiceSemanticErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_DescriptionCreationErrorZ
 pub union CResult_DescriptionCreationErrorZPtr {
@@ -5651,7 +5959,7 @@ impl Clone for CResult_DescriptionCreationErrorZ {
 #[no_mangle]
 /// 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_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { orig.clone() }
+pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ExpiryTimeCreationErrorZ
 pub union CResult_ExpiryTimeCreationErrorZPtr {
@@ -5742,7 +6050,7 @@ impl Clone for CResult_ExpiryTimeCreationErrorZ {
 #[no_mangle]
 /// Creates a new CResult_ExpiryTimeCreationErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_clone(orig: &CResult_ExpiryTimeCreationErrorZ) -> CResult_ExpiryTimeCreationErrorZ { orig.clone() }
+pub extern "C" fn CResult_ExpiryTimeCreationErrorZ_clone(orig: &CResult_ExpiryTimeCreationErrorZ) -> CResult_ExpiryTimeCreationErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_PrivateRouteCreationErrorZ
 pub union CResult_PrivateRouteCreationErrorZPtr {
@@ -5833,7 +6141,7 @@ impl Clone for CResult_PrivateRouteCreationErrorZ {
 #[no_mangle]
 /// 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 CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { orig.clone() }
+pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_StringErrorZ
 pub union CResult_StringErrorZPtr {
@@ -5998,7 +6306,7 @@ impl Clone for CResult_ChannelMonitorUpdateDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_HTLCUpdateDecodeErrorZ
 pub union CResult_HTLCUpdateDecodeErrorZPtr {
@@ -6089,7 +6397,7 @@ impl Clone for CResult_HTLCUpdateDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_NoneMonitorUpdateErrorZ
 pub union CResult_NoneMonitorUpdateErrorZPtr {
@@ -6176,7 +6484,7 @@ impl Clone for CResult_NoneMonitorUpdateErrorZ {
 #[no_mangle]
 /// Creates a new CResult_NoneMonitorUpdateErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_clone(orig: &CResult_NoneMonitorUpdateErrorZ) -> CResult_NoneMonitorUpdateErrorZ { orig.clone() }
+pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_clone(orig: &CResult_NoneMonitorUpdateErrorZ) -> CResult_NoneMonitorUpdateErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A tuple of 2 elements. See the individual fields for the types contained.
 pub struct C2Tuple_OutPointScriptZ {
@@ -6201,15 +6509,15 @@ impl C2Tuple_OutPointScriptZ {
 impl Clone for C2Tuple_OutPointScriptZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { orig.clone() }
+pub extern "C" fn C2Tuple_OutPointScriptZ_clone(orig: &C2Tuple_OutPointScriptZ) -> C2Tuple_OutPointScriptZ { Clone::clone(&orig) }
 /// Creates a new C2Tuple_OutPointScriptZ from the contained elements.
 #[no_mangle]
 pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ {
@@ -6243,15 +6551,15 @@ impl C2Tuple_u32ScriptZ {
 impl Clone for C2Tuple_u32ScriptZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { orig.clone() }
+pub extern "C" fn C2Tuple_u32ScriptZ_clone(orig: &C2Tuple_u32ScriptZ) -> C2Tuple_u32ScriptZ { Clone::clone(&orig) }
 /// Creates a new C2Tuple_u32ScriptZ from the contained elements.
 #[no_mangle]
 pub extern "C" fn C2Tuple_u32ScriptZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32ScriptZ {
@@ -6331,15 +6639,15 @@ impl C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ {
 impl Clone for C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { orig.clone() }
+pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ { Clone::clone(&orig) }
 /// Creates a new C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ from the contained elements.
 #[no_mangle]
 pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32ScriptZZ) -> C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ {
@@ -6511,15 +6819,15 @@ impl C2Tuple_u32TxOutZ {
 impl Clone for C2Tuple_u32TxOutZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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 { orig.clone() }
+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 {
@@ -6599,15 +6907,15 @@ impl C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
 impl Clone for C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
+                       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_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { orig.clone() }
+pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ { Clone::clone(&orig) }
 /// Creates a new C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ from the contained elements.
 #[no_mangle]
 pub extern "C" fn C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ {
@@ -6664,6 +6972,52 @@ impl Clone for CVec_TransactionOutputsZ {
        }
 }
 #[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<crate::lightning::chain::channelmonitor::Balance> {
+               if self.datalen == 0 { return Vec::new(); }
+               let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+               self.data = std::ptr::null_mut();
+               self.datalen = 0;
+               ret
+       }
+       #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] {
+               unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+       }
+}
+impl From<Vec<crate::lightning::chain::channelmonitor::Balance>> for CVec_BalanceZ {
+       fn from(v: Vec<crate::lightning::chain::channelmonitor::Balance>) -> 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; }
+               unsafe { Box::from_raw(std::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 { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+               Self::from(res)
+       }
+}
+#[repr(C)]
 /// The contents of CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ
 pub union CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr {
        /// A pointer to the contents in the success state.
@@ -6738,6 +7092,161 @@ impl From<crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_BlockHas
        }
 }
 #[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 std::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::LightningError,
+}
+#[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.
+/// `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
+       /// `err` or `result` depending on the state of `result_ok`.
+       pub contents: CResult_NoneLightningErrorZPtr,
+       /// Whether this CResult_NoneLightningErrorZ 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: std::ptr::null_mut(),
+               },
+               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 {
+                       err: Box::into_raw(Box::new(e)),
+               },
+               result_ok: false,
+       }
+}
+#[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 {
+       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::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>> for CResult_NoneLightningErrorZ {
+       fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self {
+               let contents = if o.result_ok {
+                       let _ = unsafe { Box::from_raw(o.contents.result) };
+                       o.contents.result = std::ptr::null_mut();
+                       CResult_NoneLightningErrorZPtr { result: std::ptr::null_mut() }
+               } else {
+                       let err = unsafe { o.contents.err };
+                       unsafe { o.contents.err = std::ptr::null_mut(); }
+                       CResult_NoneLightningErrorZPtr { err }
+               };
+               Self {
+                       contents,
+                       result_ok: o.result_ok,
+               }
+       }
+}
+impl Clone for CResult_NoneLightningErrorZ {
+       fn clone(&self) -> Self {
+               if self.result_ok {
+                       Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr {
+                               result: std::ptr::null_mut()
+                       } }
+               } else {
+                       Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr {
+                               err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::LightningError>::clone(unsafe { &*self.contents.err })))
+                       } }
+               }
+       }
+}
+#[no_mangle]
+/// 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_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { 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)
+       }
+}
+/// 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<crate::c_types::derived::C2Tuple_PublicKeyTypeZ> {
+               if self.datalen == 0 { return Vec::new(); }
+               let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+               self.data = std::ptr::null_mut();
+               self.datalen = 0;
+               ret
+       }
+       #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] {
+               unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+       }
+}
+impl From<Vec<crate::c_types::derived::C2Tuple_PublicKeyTypeZ>> for CVec_C2Tuple_PublicKeyTypeZZ {
+       fn from(v: Vec<crate::c_types::derived::C2Tuple_PublicKeyTypeZ>) -> 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; }
+               unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+       }
+}
+#[repr(C)]
 /// The contents of CResult_boolLightningErrorZ
 pub union CResult_boolLightningErrorZPtr {
        /// A pointer to the contents in the success state.
@@ -6827,7 +7336,7 @@ impl Clone for CResult_boolLightningErrorZ {
 #[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 { orig.clone() }
+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 {
@@ -6855,16 +7364,16 @@ impl C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
 impl Clone for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
        fn clone(&self) -> Self {
                Self {
-                       a: self.a.clone(),
-                       b: self.b.clone(),
-                       c: self.c.clone(),
+                       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 { orig.clone() }
+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 {
@@ -6967,93 +7476,6 @@ impl Clone for CVec_NodeAnnouncementZ {
        }
 }
 #[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 std::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::LightningError,
-}
-#[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.
-/// `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
-       /// `err` or `result` depending on the state of `result_ok`.
-       pub contents: CResult_NoneLightningErrorZPtr,
-       /// Whether this CResult_NoneLightningErrorZ 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: std::ptr::null_mut(),
-               },
-               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 {
-                       err: Box::into_raw(Box::new(e)),
-               },
-               result_ok: false,
-       }
-}
-#[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 {
-       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::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>> for CResult_NoneLightningErrorZ {
-       fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self {
-               let contents = if o.result_ok {
-                       let _ = unsafe { Box::from_raw(o.contents.result) };
-                       o.contents.result = std::ptr::null_mut();
-                       CResult_NoneLightningErrorZPtr { result: std::ptr::null_mut() }
-               } else {
-                       let err = unsafe { o.contents.err };
-                       unsafe { o.contents.err = std::ptr::null_mut(); }
-                       CResult_NoneLightningErrorZPtr { err }
-               };
-               Self {
-                       contents,
-                       result_ok: o.result_ok,
-               }
-       }
-}
-impl Clone for CResult_NoneLightningErrorZ {
-       fn clone(&self) -> Self {
-               if self.result_ok {
-                       Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr {
-                               result: std::ptr::null_mut()
-                       } }
-               } else {
-                       Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr {
-                               err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::LightningError>::clone(unsafe { &*self.contents.err })))
-                       } }
-               }
-       }
-}
-#[no_mangle]
-/// 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_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { orig.clone() }
-#[repr(C)]
 /// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size.
 /// This corresponds to std::vector in C++
 pub struct CVec_PublicKeyZ {
@@ -7189,7 +7611,7 @@ impl Clone for CResult_CVec_u8ZPeerHandleErrorZ {
 #[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 { orig.clone() }
+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 {
@@ -7276,7 +7698,7 @@ impl Clone for CResult_NonePeerHandleErrorZ {
 #[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 { orig.clone() }
+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 {
@@ -7367,7 +7789,39 @@ impl Clone for CResult_boolPeerHandleErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) }
+#[repr(C)]
+/// An enum which can either contain a crate::lightning::chain::Access or not
+pub enum COption_AccessZ {
+       /// When we're in this state, this COption_AccessZ contains a crate::lightning::chain::Access
+       Some(crate::lightning::chain::Access),
+       /// When we're in this state, this COption_AccessZ contains nothing
+       None
+}
+impl COption_AccessZ {
+       #[allow(unused)] pub(crate) fn is_some(&self) -> bool {
+               if let Self::Some(_) = self { true } else { false }
+       }
+       #[allow(unused)] pub(crate) fn is_none(&self) -> bool {
+               !self.is_some()
+       }
+       #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::Access {
+               if let Self::Some(v) = self { v } else { unreachable!() }
+       }
+}
+#[no_mangle]
+/// Constructs a new COption_AccessZ containing a crate::lightning::chain::Access
+pub extern "C" fn COption_AccessZ_some(o: crate::lightning::chain::Access) -> COption_AccessZ {
+       COption_AccessZ::Some(o)
+}
+#[no_mangle]
+/// Constructs a new COption_AccessZ containing nothing
+pub extern "C" fn COption_AccessZ_none() -> COption_AccessZ {
+       COption_AccessZ::None
+}
+#[no_mangle]
+/// Frees any resources associated with the crate::lightning::chain::Access, if we are in the Some state
+pub extern "C" fn COption_AccessZ_free(_res: COption_AccessZ) { }
 #[repr(C)]
 /// The contents of CResult_DirectionalChannelInfoDecodeErrorZ
 pub union CResult_DirectionalChannelInfoDecodeErrorZPtr {
@@ -7458,7 +7912,7 @@ impl Clone for CResult_DirectionalChannelInfoDecodeErrorZ {
 #[no_mangle]
 /// Creates a new CResult_DirectionalChannelInfoDecodeErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig: &CResult_DirectionalChannelInfoDecodeErrorZ) -> CResult_DirectionalChannelInfoDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig: &CResult_DirectionalChannelInfoDecodeErrorZ) -> CResult_DirectionalChannelInfoDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ChannelInfoDecodeErrorZ
 pub union CResult_ChannelInfoDecodeErrorZPtr {
@@ -7549,7 +8003,7 @@ impl Clone for CResult_ChannelInfoDecodeErrorZ {
 #[no_mangle]
 /// 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_ChannelInfoDecodeErrorZ_clone(orig: &CResult_ChannelInfoDecodeErrorZ) -> CResult_ChannelInfoDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_clone(orig: &CResult_ChannelInfoDecodeErrorZ) -> CResult_ChannelInfoDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_RoutingFeesDecodeErrorZ
 pub union CResult_RoutingFeesDecodeErrorZPtr {
@@ -7640,7 +8094,7 @@ impl Clone for CResult_RoutingFeesDecodeErrorZ {
 #[no_mangle]
 /// 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_RoutingFeesDecodeErrorZ_clone(orig: &CResult_RoutingFeesDecodeErrorZ) -> CResult_RoutingFeesDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_clone(orig: &CResult_RoutingFeesDecodeErrorZ) -> CResult_RoutingFeesDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_NodeAnnouncementInfoDecodeErrorZ
 pub union CResult_NodeAnnouncementInfoDecodeErrorZPtr {
@@ -7731,7 +8185,7 @@ impl Clone for CResult_NodeAnnouncementInfoDecodeErrorZ {
 #[no_mangle]
 /// 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_NodeAnnouncementInfoDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> CResult_NodeAnnouncementInfoDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> CResult_NodeAnnouncementInfoDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// A dynamically-allocated array of u64s of arbitrary size.
 /// This corresponds to std::vector in C++
@@ -7868,7 +8322,7 @@ impl Clone for CResult_NodeInfoDecodeErrorZ {
 #[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 { orig.clone() }
+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 {
@@ -7943,23 +8397,6 @@ impl From<crate::c_types::CResultTempl<crate::lightning::routing::network_graph:
                }
        }
 }
-impl Clone for CResult_NetworkGraphDecodeErrorZ {
-       fn clone(&self) -> Self {
-               if self.result_ok {
-                       Self { result_ok: true, contents: CResult_NetworkGraphDecodeErrorZPtr {
-                               result: Box::into_raw(Box::new(<crate::lightning::routing::network_graph::NetworkGraph>::clone(unsafe { &*self.contents.result })))
-                       } }
-               } else {
-                       Self { result_ok: false, contents: CResult_NetworkGraphDecodeErrorZPtr {
-                               err: Box::into_raw(Box::new(<crate::lightning::ln::msgs::DecodeError>::clone(unsafe { &*self.contents.err })))
-                       } }
-               }
-       }
-}
-#[no_mangle]
-/// Creates a new CResult_NetworkGraphDecodeErrorZ which has the same data as `orig`
-/// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_clone(orig: &CResult_NetworkGraphDecodeErrorZ) -> CResult_NetworkGraphDecodeErrorZ { orig.clone() }
 #[repr(C)]
 /// The contents of CResult_NetAddressu8Z
 pub union CResult_NetAddressu8ZPtr {
@@ -8050,7 +8487,7 @@ impl Clone for CResult_NetAddressu8Z {
 #[no_mangle]
 /// Creates a new CResult_NetAddressu8Z which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NetAddressu8Z_clone(orig: &CResult_NetAddressu8Z) -> CResult_NetAddressu8Z { orig.clone() }
+pub extern "C" fn CResult_NetAddressu8Z_clone(orig: &CResult_NetAddressu8Z) -> CResult_NetAddressu8Z { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_CResult_NetAddressu8ZDecodeErrorZ
 pub union CResult_CResult_NetAddressu8ZDecodeErrorZPtr {
@@ -8141,7 +8578,7 @@ impl Clone for CResult_CResult_NetAddressu8ZDecodeErrorZ {
 #[no_mangle]
 /// Creates a new CResult_CResult_NetAddressu8ZDecodeErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig: &CResult_CResult_NetAddressu8ZDecodeErrorZ) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig: &CResult_CResult_NetAddressu8ZDecodeErrorZ) -> CResult_CResult_NetAddressu8ZDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_NetAddressDecodeErrorZ
 pub union CResult_NetAddressDecodeErrorZPtr {
@@ -8232,7 +8669,7 @@ impl Clone for CResult_NetAddressDecodeErrorZ {
 #[no_mangle]
 /// Creates a new CResult_NetAddressDecodeErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_NetAddressDecodeErrorZ_clone(orig: &CResult_NetAddressDecodeErrorZ) -> CResult_NetAddressDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_NetAddressDecodeErrorZ_clone(orig: &CResult_NetAddressDecodeErrorZ) -> CResult_NetAddressDecodeErrorZ { 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++
@@ -8507,7 +8944,7 @@ impl Clone for CResult_AcceptChannelDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_AnnouncementSignaturesDecodeErrorZ
 pub union CResult_AnnouncementSignaturesDecodeErrorZPtr {
@@ -8598,7 +9035,7 @@ impl Clone for CResult_AnnouncementSignaturesDecodeErrorZ {
 #[no_mangle]
 /// 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_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ChannelReestablishDecodeErrorZ
 pub union CResult_ChannelReestablishDecodeErrorZPtr {
@@ -8689,7 +9126,7 @@ impl Clone for CResult_ChannelReestablishDecodeErrorZ {
 #[no_mangle]
 /// 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 CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ClosingSignedDecodeErrorZ
 pub union CResult_ClosingSignedDecodeErrorZPtr {
@@ -8780,7 +9217,7 @@ impl Clone for CResult_ClosingSignedDecodeErrorZ {
 #[no_mangle]
 /// 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 CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ
 pub union CResult_ClosingSignedFeeRangeDecodeErrorZPtr {
@@ -8871,7 +9308,7 @@ impl Clone for CResult_ClosingSignedFeeRangeDecodeErrorZ {
 #[no_mangle]
 /// 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_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_CommitmentSignedDecodeErrorZ
 pub union CResult_CommitmentSignedDecodeErrorZPtr {
@@ -8962,7 +9399,7 @@ impl Clone for CResult_CommitmentSignedDecodeErrorZ {
 #[no_mangle]
 /// 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_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_FundingCreatedDecodeErrorZ
 pub union CResult_FundingCreatedDecodeErrorZPtr {
@@ -9053,7 +9490,7 @@ impl Clone for CResult_FundingCreatedDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_FundingSignedDecodeErrorZ
 pub union CResult_FundingSignedDecodeErrorZPtr {
@@ -9144,7 +9581,7 @@ impl Clone for CResult_FundingSignedDecodeErrorZ {
 #[no_mangle]
 /// 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_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_FundingLockedDecodeErrorZ
 pub union CResult_FundingLockedDecodeErrorZPtr {
@@ -9235,7 +9672,7 @@ impl Clone for CResult_FundingLockedDecodeErrorZ {
 #[no_mangle]
 /// Creates a new CResult_FundingLockedDecodeErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_FundingLockedDecodeErrorZ_clone(orig: &CResult_FundingLockedDecodeErrorZ) -> CResult_FundingLockedDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_FundingLockedDecodeErrorZ_clone(orig: &CResult_FundingLockedDecodeErrorZ) -> CResult_FundingLockedDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_InitDecodeErrorZ
 pub union CResult_InitDecodeErrorZPtr {
@@ -9326,7 +9763,7 @@ impl Clone for CResult_InitDecodeErrorZ {
 #[no_mangle]
 /// 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_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_OpenChannelDecodeErrorZ
 pub union CResult_OpenChannelDecodeErrorZPtr {
@@ -9417,7 +9854,7 @@ impl Clone for CResult_OpenChannelDecodeErrorZ {
 #[no_mangle]
 /// 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 CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_RevokeAndACKDecodeErrorZ
 pub union CResult_RevokeAndACKDecodeErrorZPtr {
@@ -9508,7 +9945,7 @@ impl Clone for CResult_RevokeAndACKDecodeErrorZ {
 #[no_mangle]
 /// 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_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ShutdownDecodeErrorZ
 pub union CResult_ShutdownDecodeErrorZPtr {
@@ -9599,7 +10036,7 @@ impl Clone for CResult_ShutdownDecodeErrorZ {
 #[no_mangle]
 /// 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_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UpdateFailHTLCDecodeErrorZ
 pub union CResult_UpdateFailHTLCDecodeErrorZPtr {
@@ -9690,7 +10127,7 @@ impl Clone for CResult_UpdateFailHTLCDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ
 pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr {
@@ -9781,7 +10218,7 @@ impl Clone for CResult_UpdateFailMalformedHTLCDecodeErrorZ {
 #[no_mangle]
 /// 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_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UpdateFeeDecodeErrorZ
 pub union CResult_UpdateFeeDecodeErrorZPtr {
@@ -9872,7 +10309,7 @@ impl Clone for CResult_UpdateFeeDecodeErrorZ {
 #[no_mangle]
 /// 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_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ
 pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr {
@@ -9963,7 +10400,7 @@ impl Clone for CResult_UpdateFulfillHTLCDecodeErrorZ {
 #[no_mangle]
 /// 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_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UpdateAddHTLCDecodeErrorZ
 pub union CResult_UpdateAddHTLCDecodeErrorZPtr {
@@ -10054,7 +10491,7 @@ impl Clone for CResult_UpdateAddHTLCDecodeErrorZ {
 #[no_mangle]
 /// 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_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_PingDecodeErrorZ
 pub union CResult_PingDecodeErrorZPtr {
@@ -10145,7 +10582,7 @@ impl Clone for CResult_PingDecodeErrorZ {
 #[no_mangle]
 /// 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_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_PongDecodeErrorZ
 pub union CResult_PongDecodeErrorZPtr {
@@ -10236,7 +10673,7 @@ impl Clone for CResult_PongDecodeErrorZ {
 #[no_mangle]
 /// 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_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ
 pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr {
@@ -10327,7 +10764,7 @@ impl Clone for CResult_UnsignedChannelAnnouncementDecodeErrorZ {
 #[no_mangle]
 /// 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_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ChannelAnnouncementDecodeErrorZ
 pub union CResult_ChannelAnnouncementDecodeErrorZPtr {
@@ -10418,7 +10855,7 @@ impl Clone for CResult_ChannelAnnouncementDecodeErrorZ {
 #[no_mangle]
 /// 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_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ
 pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr {
@@ -10509,7 +10946,7 @@ impl Clone for CResult_UnsignedChannelUpdateDecodeErrorZ {
 #[no_mangle]
 /// 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_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ChannelUpdateDecodeErrorZ
 pub union CResult_ChannelUpdateDecodeErrorZPtr {
@@ -10600,7 +11037,7 @@ impl Clone for CResult_ChannelUpdateDecodeErrorZ {
 #[no_mangle]
 /// 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_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ErrorMessageDecodeErrorZ
 pub union CResult_ErrorMessageDecodeErrorZPtr {
@@ -10691,7 +11128,7 @@ impl Clone for CResult_ErrorMessageDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ
 pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr {
@@ -10782,7 +11219,7 @@ impl Clone for CResult_UnsignedNodeAnnouncementDecodeErrorZ {
 #[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 { orig.clone() }
+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 {
@@ -10873,7 +11310,7 @@ impl Clone for CResult_NodeAnnouncementDecodeErrorZ {
 #[no_mangle]
 /// 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_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_QueryShortChannelIdsDecodeErrorZ
 pub union CResult_QueryShortChannelIdsDecodeErrorZPtr {
@@ -10964,7 +11401,7 @@ impl Clone for CResult_QueryShortChannelIdsDecodeErrorZ {
 #[no_mangle]
 /// 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_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ
 pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr {
@@ -11055,7 +11492,7 @@ impl Clone for CResult_ReplyShortChannelIdsEndDecodeErrorZ {
 #[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 { orig.clone() }
+pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_QueryChannelRangeDecodeErrorZ
 pub union CResult_QueryChannelRangeDecodeErrorZPtr {
@@ -11146,7 +11583,7 @@ impl Clone for CResult_QueryChannelRangeDecodeErrorZ {
 #[no_mangle]
 /// 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_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_ReplyChannelRangeDecodeErrorZ
 pub union CResult_ReplyChannelRangeDecodeErrorZPtr {
@@ -11237,7 +11674,7 @@ impl Clone for CResult_ReplyChannelRangeDecodeErrorZ {
 #[no_mangle]
 /// 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_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_GossipTimestampFilterDecodeErrorZ
 pub union CResult_GossipTimestampFilterDecodeErrorZPtr {
@@ -11328,7 +11765,7 @@ impl Clone for CResult_GossipTimestampFilterDecodeErrorZ {
 #[no_mangle]
 /// 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_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { orig.clone() }
+pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) }
 #[repr(C)]
 /// The contents of CResult_InvoiceSignOrCreationErrorZ
 pub union CResult_InvoiceSignOrCreationErrorZPtr {
@@ -11419,4 +11856,36 @@ impl Clone for CResult_InvoiceSignOrCreationErrorZ {
 #[no_mangle]
 /// Creates a new CResult_InvoiceSignOrCreationErrorZ which has the same data as `orig`
 /// but with all dynamically-allocated buffers duplicated in new buffers.
-pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_clone(orig: &CResult_InvoiceSignOrCreationErrorZ) -> CResult_InvoiceSignOrCreationErrorZ { orig.clone() }
+pub extern "C" fn CResult_InvoiceSignOrCreationErrorZ_clone(orig: &CResult_InvoiceSignOrCreationErrorZ) -> CResult_InvoiceSignOrCreationErrorZ { 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::Some(_) = self { true } else { false }
+       }
+       #[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) { }
index 09c8a5147d4c096fea4c1313af2497a659072269..18d8a08dfa7b5cda7b17e7c1ba33cd3cb28e7fd2 100644 (file)
@@ -15,6 +15,18 @@ use bitcoin::bech32;
 
 use std::convert::TryInto; // Bindings need at least rustc 1.34
 
+use std::io::{Cursor, Read}; // TODO: We should use core2 here when we support no_std
+
+#[repr(C)]
+/// A dummy struct of which an instance must never exist.
+/// This corresponds to the Rust type `Infallible`, or, in unstable rust, `!`
+pub struct NotConstructable {
+       _priv_thing: core::convert::Infallible,
+}
+impl From<core::convert::Infallible> for NotConstructable {
+       fn from(_: core::convert::Infallible) -> Self { unreachable!(); }
+}
+
 /// Integer in the range `0..32`
 #[derive(PartialEq, Eq, Copy, Clone)]
 #[allow(non_camel_case_types)]
@@ -289,6 +301,13 @@ pub extern "C" fn Transaction_free(_res: Transaction) { }
 pub(crate) fn bitcoin_to_C_outpoint(outpoint: ::bitcoin::blockdata::transaction::OutPoint) -> crate::lightning::chain::transaction::OutPoint {
        crate::lightning::chain::transaction::OutPoint_new(ThirtyTwoBytes { data: outpoint.txid.into_inner() }, outpoint.vout.try_into().unwrap())
 }
+pub(crate) fn C_to_bitcoin_outpoint(outpoint: crate::lightning::chain::transaction::OutPoint) -> ::bitcoin::blockdata::transaction::OutPoint {
+       unsafe {
+               ::bitcoin::blockdata::transaction::OutPoint {
+                       txid: (*outpoint.inner).txid, vout: (*outpoint.inner).index as u32
+               }
+       }
+}
 
 #[repr(C)]
 #[derive(Clone)]
@@ -348,6 +367,18 @@ impl u8slice {
                if self.datalen == 0 { return &[]; }
                unsafe { std::slice::from_raw_parts(self.data, self.datalen) }
        }
+       pub(crate) fn to_reader<'a>(&'a self) -> Cursor<&'a [u8]> {
+               let sl = self.to_slice();
+               Cursor::new(sl)
+       }
+       pub(crate) fn from_vec(v: &derived::CVec_u8Z) -> u8slice {
+               Self::from_slice(v.as_slice())
+       }
+}
+pub(crate) fn reader_to_vec<R: Read>(r: &mut R) -> derived::CVec_u8Z {
+       let mut res = Vec::new();
+       r.read_to_end(&mut res).unwrap();
+       derived::CVec_u8Z::from(res)
 }
 
 #[repr(C)]
@@ -390,9 +421,6 @@ impl lightning::util::ser::Writer for VecWriter {
                self.0.extend_from_slice(buf);
                Ok(())
        }
-       fn size_hint(&mut self, size: usize) {
-               self.0.reserve_exact(size);
-       }
 }
 pub(crate) fn serialize_obj<I: lightning::util::ser::Writeable>(i: &I) -> derived::CVec_u8Z {
        let mut out = VecWriter(Vec::new());
index bd628703992bb45184f0d1f85395828b78ff8544..b6c13b149147ee890bef477eb6625a0d25182724 100644 (file)
@@ -14,6 +14,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 147889c27ac4d32ba929ba5c6a9a988dec648335..08997943b07b91c45ba5e7d6c7457fd7633955ed 100644 (file)
@@ -24,6 +24,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -93,16 +94,32 @@ impl ChainMonitor {
 /// pre-filter blocks or only fetch blocks matching a compact filter. Otherwise, clients may
 /// always need to fetch full blocks absent another means for determining which blocks contain
 /// transactions relevant to the watched channels.
-///
-/// Note that chain_source (or a relevant inner pointer) may be NULL or all-0s to represent None
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChainMonitor_new(chain_source: *mut crate::lightning::chain::Filter, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut logger: crate::lightning::util::logger::Logger, mut feeest: crate::lightning::chain::chaininterface::FeeEstimator, mut persister: crate::lightning::chain::channelmonitor::Persist) -> ChainMonitor {
-       let mut local_chain_source = if chain_source == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_source) } }) };
+pub extern "C" fn ChainMonitor_new(mut chain_source: crate::c_types::derived::COption_FilterZ, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut logger: crate::lightning::util::logger::Logger, mut feeest: crate::lightning::chain::chaininterface::FeeEstimator, mut persister: crate::lightning::chain::channelmonitor::Persist) -> ChainMonitor {
+       let mut local_chain_source = { /* chain_source*/ let chain_source_opt = chain_source; { } if chain_source_opt.is_none() { None } else { Some({ chain_source_opt.take() }) } };
        let mut ret = lightning::chain::chainmonitor::ChainMonitor::new(local_chain_source, broadcaster, logger, feeest, persister);
        ChainMonitor { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
+/// Gets the balances in the contained [`ChannelMonitor`]s which are claimable on-chain or
+/// 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`]).
+///
+/// See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for
+/// inclusion in the return value.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainMonitor_get_claimable_balances(this_arg: &ChainMonitor, mut ignored_channels: crate::c_types::derived::CVec_ChannelDetailsZ) -> crate::c_types::derived::CVec_BalanceZ {
+       let mut local_ignored_channels = Vec::new(); for mut item in ignored_channels.as_slice().iter() { local_ignored_channels.push( { item.get_native_ref() }); };
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_claimable_balances(&local_ignored_channels[..]);
+       let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::chain::channelmonitor::Balance::native_into(item) }); };
+       local_ret.into()
+}
+
 impl From<nativeChainMonitor> for crate::lightning::chain::Listen {
        fn from(obj: nativeChainMonitor) -> Self {
                let mut rust_obj = ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true };
index ff5043f6b855c8f58dd07adda28b935da98807df..e446535c6bee646489ec6561cc2a47630e56b760 100644 (file)
@@ -21,6 +21,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -339,8 +340,8 @@ pub extern "C" fn MonitorUpdateError_clone(orig: &MonitorUpdateError) -> Monitor
 pub enum MonitorEvent {
        /// A monitor event containing an HTLCUpdate.
        HTLCEvent(crate::lightning::chain::channelmonitor::HTLCUpdate),
-       /// A monitor event that the Channel's commitment transaction was broadcasted.
-       CommitmentTxBroadcasted(crate::lightning::chain::transaction::OutPoint),
+       /// A monitor event that the Channel's commitment transaction was confirmed.
+       CommitmentTxConfirmed(crate::lightning::chain::transaction::OutPoint),
 }
 use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEvent;
 impl MonitorEvent {
@@ -353,9 +354,9 @@ impl MonitorEvent {
                                        *unsafe { Box::from_raw(a_nonref.take_inner()) },
                                )
                        },
-                       MonitorEvent::CommitmentTxBroadcasted (ref a, ) => {
+                       MonitorEvent::CommitmentTxConfirmed (ref a, ) => {
                                let mut a_nonref = (*a).clone();
-                               nativeMonitorEvent::CommitmentTxBroadcasted (
+                               nativeMonitorEvent::CommitmentTxConfirmed (
                                        *unsafe { Box::from_raw(a_nonref.take_inner()) },
                                )
                        },
@@ -369,8 +370,8 @@ impl MonitorEvent {
                                        *unsafe { Box::from_raw(a.take_inner()) },
                                )
                        },
-                       MonitorEvent::CommitmentTxBroadcasted (mut a, ) => {
-                               nativeMonitorEvent::CommitmentTxBroadcasted (
+                       MonitorEvent::CommitmentTxConfirmed (mut a, ) => {
+                               nativeMonitorEvent::CommitmentTxConfirmed (
                                        *unsafe { Box::from_raw(a.take_inner()) },
                                )
                        },
@@ -385,9 +386,9 @@ impl MonitorEvent {
                                        crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
                                )
                        },
-                       nativeMonitorEvent::CommitmentTxBroadcasted (ref a, ) => {
+                       nativeMonitorEvent::CommitmentTxConfirmed (ref a, ) => {
                                let mut a_nonref = (*a).clone();
-                               MonitorEvent::CommitmentTxBroadcasted (
+                               MonitorEvent::CommitmentTxConfirmed (
                                        crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
                                )
                        },
@@ -401,8 +402,8 @@ impl MonitorEvent {
                                        crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(a), is_owned: true },
                                )
                        },
-                       nativeMonitorEvent::CommitmentTxBroadcasted (mut a, ) => {
-                               MonitorEvent::CommitmentTxBroadcasted (
+                       nativeMonitorEvent::CommitmentTxConfirmed (mut a, ) => {
+                               MonitorEvent::CommitmentTxConfirmed (
                                        crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a), is_owned: true },
                                )
                        },
@@ -423,9 +424,9 @@ pub extern "C" fn MonitorEvent_htlcevent(a: crate::lightning::chain::channelmoni
        MonitorEvent::HTLCEvent(a, )
 }
 #[no_mangle]
-/// Utility method to constructs a new CommitmentTxBroadcasted-variant MonitorEvent
-pub extern "C" fn MonitorEvent_commitment_tx_broadcasted(a: crate::lightning::chain::transaction::OutPoint) -> MonitorEvent {
-       MonitorEvent::CommitmentTxBroadcasted(a, )
+/// Utility method to constructs a new CommitmentTxConfirmed-variant MonitorEvent
+pub extern "C" fn MonitorEvent_commitment_tx_confirmed(a: crate::lightning::chain::transaction::OutPoint) -> MonitorEvent {
+       MonitorEvent::CommitmentTxConfirmed(a, )
 }
 
 use lightning::chain::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
@@ -515,11 +516,243 @@ pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_type
        let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_res
 }
-/// Number of blocks we wait on seeing a HTLC output being solved before we fail corresponding inbound
-/// HTLCs. This prevents us from failing backwards and then getting a reorg resulting in us losing money.
+/// Number of blocks we wait on seeing a HTLC output being solved before we fail corresponding
+/// inbound HTLCs. This prevents us from failing backwards and then getting a reorg resulting in us
+/// losing money.
+///
+/// Note that this is a library-wide security assumption. If a reorg deeper than this number of
+/// blocks occurs, counterparties may be able to steal funds or claims made by and balances exposed
+/// by a  [`ChannelMonitor`] may be incorrect.
 
 #[no_mangle]
 pub static ANTI_REORG_DELAY: u32 = lightning::chain::channelmonitor::ANTI_REORG_DELAY;
+/// 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
+/// be provided.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum Balance {
+       /// The channel is not yet closed (or the commitment or closing transaction has not yet
+       /// appeared in a block). The given balance is claimable (less on-chain fees) if the channel is
+       /// force-closed now.
+       ClaimableOnChannelClose {
+               /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
+               /// required to do so.
+               claimable_amount_satoshis: u64,
+       },
+       /// The channel has been closed, and the given balance is ours but awaiting confirmations until
+       /// we consider it spendable.
+       ClaimableAwaitingConfirmations {
+               /// The amount available to claim, in satoshis, possibly excluding the on-chain fees which
+               /// were spent in broadcasting the transaction.
+               claimable_amount_satoshis: u64,
+               /// The height at which an [`Event::SpendableOutputs`] event will be generated for this
+               /// amount.
+               confirmation_height: u32,
+       },
+       /// 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
+       /// possible our counterparty can take the funds by broadcasting an HTLC timeout on-chain.
+       ///
+       /// Once the spending transaction confirms, before it has reached enough confirmations to be
+       /// considered safe from chain reorganizations, the balance will instead be provided via
+       /// [`Balance::ClaimableAwaitingConfirmations`].
+       ContentiousClaimable {
+               /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
+               /// required to do so.
+               claimable_amount_satoshis: u64,
+               /// The height at which the counterparty may be able to claim the balance if we have not
+               /// done so.
+               timeout_height: u32,
+       },
+       /// HTLCs which we sent to our counterparty which are claimable after a timeout (less on-chain
+       /// fees) if the counterparty does not know the preimage for the HTLCs. These are somewhat
+       /// likely to be claimed by our counterparty before we do.
+       MaybeClaimableHTLCAwaitingTimeout {
+               /// The amount available to claim, in satoshis, excluding the on-chain fees which will be
+               /// required to do so.
+               claimable_amount_satoshis: u64,
+               /// The height at which we will be able to claim the balance if our counterparty has not
+               /// done so.
+               claimable_height: u32,
+       },
+}
+use lightning::chain::channelmonitor::Balance as nativeBalance;
+impl Balance {
+       #[allow(unused)]
+       pub(crate) fn to_native(&self) -> nativeBalance {
+               match self {
+                       Balance::ClaimableOnChannelClose {ref claimable_amount_satoshis, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               nativeBalance::ClaimableOnChannelClose {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                               }
+                       },
+                       Balance::ClaimableAwaitingConfirmations {ref claimable_amount_satoshis, ref confirmation_height, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               let mut confirmation_height_nonref = (*confirmation_height).clone();
+                               nativeBalance::ClaimableAwaitingConfirmations {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                                       confirmation_height: confirmation_height_nonref,
+                               }
+                       },
+                       Balance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               let mut timeout_height_nonref = (*timeout_height).clone();
+                               nativeBalance::ContentiousClaimable {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                                       timeout_height: timeout_height_nonref,
+                               }
+                       },
+                       Balance::MaybeClaimableHTLCAwaitingTimeout {ref claimable_amount_satoshis, ref claimable_height, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               let mut claimable_height_nonref = (*claimable_height).clone();
+                               nativeBalance::MaybeClaimableHTLCAwaitingTimeout {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                                       claimable_height: claimable_height_nonref,
+                               }
+                       },
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn into_native(self) -> nativeBalance {
+               match self {
+                       Balance::ClaimableOnChannelClose {mut claimable_amount_satoshis, } => {
+                               nativeBalance::ClaimableOnChannelClose {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                               }
+                       },
+                       Balance::ClaimableAwaitingConfirmations {mut claimable_amount_satoshis, mut confirmation_height, } => {
+                               nativeBalance::ClaimableAwaitingConfirmations {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                                       confirmation_height: confirmation_height,
+                               }
+                       },
+                       Balance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => {
+                               nativeBalance::ContentiousClaimable {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                                       timeout_height: timeout_height,
+                               }
+                       },
+                       Balance::MaybeClaimableHTLCAwaitingTimeout {mut claimable_amount_satoshis, mut claimable_height, } => {
+                               nativeBalance::MaybeClaimableHTLCAwaitingTimeout {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                                       claimable_height: claimable_height,
+                               }
+                       },
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn from_native(native: &nativeBalance) -> Self {
+               match native {
+                       nativeBalance::ClaimableOnChannelClose {ref claimable_amount_satoshis, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               Balance::ClaimableOnChannelClose {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                               }
+                       },
+                       nativeBalance::ClaimableAwaitingConfirmations {ref claimable_amount_satoshis, ref confirmation_height, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               let mut confirmation_height_nonref = (*confirmation_height).clone();
+                               Balance::ClaimableAwaitingConfirmations {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                                       confirmation_height: confirmation_height_nonref,
+                               }
+                       },
+                       nativeBalance::ContentiousClaimable {ref claimable_amount_satoshis, ref timeout_height, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               let mut timeout_height_nonref = (*timeout_height).clone();
+                               Balance::ContentiousClaimable {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                                       timeout_height: timeout_height_nonref,
+                               }
+                       },
+                       nativeBalance::MaybeClaimableHTLCAwaitingTimeout {ref claimable_amount_satoshis, ref claimable_height, } => {
+                               let mut claimable_amount_satoshis_nonref = (*claimable_amount_satoshis).clone();
+                               let mut claimable_height_nonref = (*claimable_height).clone();
+                               Balance::MaybeClaimableHTLCAwaitingTimeout {
+                                       claimable_amount_satoshis: claimable_amount_satoshis_nonref,
+                                       claimable_height: claimable_height_nonref,
+                               }
+                       },
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn native_into(native: nativeBalance) -> Self {
+               match native {
+                       nativeBalance::ClaimableOnChannelClose {mut claimable_amount_satoshis, } => {
+                               Balance::ClaimableOnChannelClose {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                               }
+                       },
+                       nativeBalance::ClaimableAwaitingConfirmations {mut claimable_amount_satoshis, mut confirmation_height, } => {
+                               Balance::ClaimableAwaitingConfirmations {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                                       confirmation_height: confirmation_height,
+                               }
+                       },
+                       nativeBalance::ContentiousClaimable {mut claimable_amount_satoshis, mut timeout_height, } => {
+                               Balance::ContentiousClaimable {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                                       timeout_height: timeout_height,
+                               }
+                       },
+                       nativeBalance::MaybeClaimableHTLCAwaitingTimeout {mut claimable_amount_satoshis, mut claimable_height, } => {
+                               Balance::MaybeClaimableHTLCAwaitingTimeout {
+                                       claimable_amount_satoshis: claimable_amount_satoshis,
+                                       claimable_height: claimable_height,
+                               }
+                       },
+               }
+       }
+}
+/// Frees any resources used by the Balance
+#[no_mangle]
+pub extern "C" fn Balance_free(this_ptr: Balance) { }
+/// Creates a copy of the Balance
+#[no_mangle]
+pub extern "C" fn Balance_clone(orig: &Balance) -> Balance {
+       orig.clone()
+}
+#[no_mangle]
+/// Utility method to constructs a new ClaimableOnChannelClose-variant Balance
+pub extern "C" fn Balance_claimable_on_channel_close(claimable_amount_satoshis: u64) -> Balance {
+       Balance::ClaimableOnChannelClose {
+               claimable_amount_satoshis,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance
+pub extern "C" fn Balance_claimable_awaiting_confirmations(claimable_amount_satoshis: u64, confirmation_height: u32) -> Balance {
+       Balance::ClaimableAwaitingConfirmations {
+               claimable_amount_satoshis,
+               confirmation_height,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new ContentiousClaimable-variant Balance
+pub extern "C" fn Balance_contentious_claimable(claimable_amount_satoshis: u64, timeout_height: u32) -> Balance {
+       Balance::ContentiousClaimable {
+               claimable_amount_satoshis,
+               timeout_height,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance
+pub extern "C" fn Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis: u64, claimable_height: u32) -> Balance {
+       Balance::MaybeClaimableHTLCAwaitingTimeout {
+               claimable_amount_satoshis,
+               claimable_height,
+       }
+}
+/// Checks if two Balances contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn Balance_eq(a: &Balance, b: &Balance) -> bool {
+       if &a.to_native() == &b.to_native() { true } else { false }
+}
 
 use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
 type nativeChannelMonitor = nativeChannelMonitorImport<crate::lightning::chain::keysinterface::Sign>;
@@ -771,6 +1004,28 @@ pub extern "C" fn ChannelMonitor_current_best_block(this_arg: &ChannelMonitor) -
        crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
+/// 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).
+///
+/// Any balances in the channel which are available on-chain (excluding on-chain fees) are
+/// included here until an [`Event::SpendableOutputs`] event has been generated for the
+/// balance, or until our counterparty has claimed the balance and accrued several
+/// confirmations on the claim transaction.
+///
+/// Note that the balances available when you or your counterparty have broadcasted revoked
+/// state(s) may not be fully captured here.
+///
+/// See [`Balance`] for additional details on the types of claimable balances which
+/// may be returned here and their meanings.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_claimable_balances(this_arg: &ChannelMonitor) -> crate::c_types::derived::CVec_BalanceZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_claimable_balances();
+       let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::chain::channelmonitor::Balance::native_into(item) }); };
+       local_ret.into()
+}
+
 /// `Persist` defines behavior for persisting channel monitors: this could mean
 /// writing once to disk, and/or uploading to one or more backup services.
 ///
index ed6df195e792582944154dcfbb85d97753a05aa7..1472582811b1bc3d0b3de9ed99b7cf2cedcb8660 100644 (file)
@@ -12,6 +12,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -563,6 +564,14 @@ pub struct BaseSign {
        /// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.
        #[must_use]
        pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes,
+       /// 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
+       /// secret won't leave us without a broadcastable holder transaction.
+       /// Policy checks should be implemented in this function, including checking the amount
+       /// sent to us and checking the HTLCs.
+       #[must_use]
+       pub validate_holder_commitment: extern "C" fn (this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_NoneNoneZ,
        /// Gets the holder's channel public keys and basepoints
        pub pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys,
        /// Fill in the pubkeys field as a reference to it will be given to Rust after this returns
@@ -577,8 +586,17 @@ pub struct BaseSign {
        /// Create a signature for a counterparty's commitment transaction and associated HTLC transactions.
        ///
        /// Note that if signing fails or is rejected, the channel will be force-closed.
+       ///
+       /// Policy checks should be implemented in this function, including checking the amount
+       /// sent to us and checking the HTLCs.
        #[must_use]
        pub sign_counterparty_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ,
+       /// Validate the counterparty's revocation.
+       ///
+       /// This is required in order for the signer to make sure that the state has moved
+       /// forward and it is safe to sign the next counterparty commitment.
+       #[must_use]
+       pub validate_counterparty_revocation: extern "C" fn (this_arg: *const c_void, idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ,
        /// Create a signatures for a holder's commitment transaction and its claiming HTLC transactions.
        /// This will only ever be called with a non-revoked commitment_tx.  This will be called with the
        /// latest commitment_tx when we initiate a force-close.
@@ -651,7 +669,7 @@ pub struct BaseSign {
        /// Note that, due to rounding, there may be one \"missing\" satoshi, and either party may have
        /// chosen to forgo their output as dust.
        #[must_use]
-       pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ,
+       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_SignatureNoneZ,
        /// Signs a channel announcement message with our funding key, proving it comes from one
        /// of the channel participants.
        ///
@@ -683,10 +701,12 @@ pub(crate) extern "C" fn BaseSign_clone_fields(orig: &BaseSign) -> BaseSign {
                this_arg: orig.this_arg,
                get_per_commitment_point: Clone::clone(&orig.get_per_commitment_point),
                release_commitment_secret: Clone::clone(&orig.release_commitment_secret),
+               validate_holder_commitment: Clone::clone(&orig.validate_holder_commitment),
                pubkeys: Clone::clone(&orig.pubkeys),
                set_pubkeys: Clone::clone(&orig.set_pubkeys),
                channel_keys_id: Clone::clone(&orig.channel_keys_id),
                sign_counterparty_commitment: Clone::clone(&orig.sign_counterparty_commitment),
+               validate_counterparty_revocation: Clone::clone(&orig.validate_counterparty_revocation),
                sign_holder_commitment_and_htlcs: Clone::clone(&orig.sign_holder_commitment_and_htlcs),
                sign_justice_revoked_output: Clone::clone(&orig.sign_justice_revoked_output),
                sign_justice_revoked_htlc: Clone::clone(&orig.sign_justice_revoked_htlc),
@@ -708,6 +728,11 @@ impl rustBaseSign for BaseSign {
                let mut ret = (self.release_commitment_secret)(self.this_arg, idx);
                ret.data
        }
+       fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction) -> Result<(), ()> {
+               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 _) 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)) })*/ })};
+               local_ret
+       }
        fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
                if let Some(f) = self.set_pubkeys {
                        (f)(&self);
@@ -723,6 +748,11 @@ impl rustBaseSign for BaseSign {
                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 validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::key::SecretKey) -> Result<(), ()> {
+               let mut ret = (self.validate_counterparty_revocation)(self.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 sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
                let mut ret = (self.sign_holder_commitment_and_htlcs)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const _) as *mut _) }, is_owned: false });
                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)) })*/ })};
@@ -743,8 +773,8 @@ impl rustBaseSign for BaseSign {
                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: &bitcoin::blockdata::transaction::Transaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
-               let mut ret = (self.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(closing_tx));
+       fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
+               let mut ret = (self.sign_closing_transaction)(self.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const _) 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
        }
@@ -819,6 +849,11 @@ impl lightning::chain::keysinterface::BaseSign for Sign {
                let mut ret = (self.BaseSign.release_commitment_secret)(self.BaseSign.this_arg, idx);
                ret.data
        }
+       fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction) -> Result<(), ()> {
+               let mut ret = (self.BaseSign.validate_holder_commitment)(self.BaseSign.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const _) 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)) })*/ })};
+               local_ret
+       }
        fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys {
                if let Some(f) = self.BaseSign.set_pubkeys {
                        (f)(&self.BaseSign);
@@ -834,6 +869,11 @@ impl lightning::chain::keysinterface::BaseSign for Sign {
                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 validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::key::SecretKey) -> Result<(), ()> {
+               let mut ret = (self.BaseSign.validate_counterparty_revocation)(self.BaseSign.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 sign_holder_commitment_and_htlcs(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
                let mut ret = (self.BaseSign.sign_holder_commitment_and_htlcs)(self.BaseSign.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const _) as *mut _) }, is_owned: false });
                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)) })*/ })};
@@ -854,8 +894,8 @@ impl lightning::chain::keysinterface::BaseSign for Sign {
                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: &bitcoin::blockdata::transaction::Transaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
-               let mut ret = (self.BaseSign.sign_closing_transaction)(self.BaseSign.this_arg, crate::c_types::Transaction::from_bitcoin(closing_tx));
+       fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1<bitcoin::secp256k1::All>) -> Result<bitcoin::secp256k1::Signature, ()> {
+               let mut ret = (self.BaseSign.sign_closing_transaction)(self.BaseSign.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const _) 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
        }
@@ -1288,11 +1328,13 @@ pub extern "C" fn InMemorySigner_as_BaseSign(this_arg: &InMemorySigner) -> crate
                free: None,
                get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point,
                release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret,
+               validate_holder_commitment: InMemorySigner_BaseSign_validate_holder_commitment,
 
                pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true },
                set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys),
                channel_keys_id: InMemorySigner_BaseSign_channel_keys_id,
                sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment,
+               validate_counterparty_revocation: InMemorySigner_BaseSign_validate_counterparty_revocation,
                sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs,
                sign_justice_revoked_output: InMemorySigner_BaseSign_sign_justice_revoked_output,
                sign_justice_revoked_htlc: InMemorySigner_BaseSign_sign_justice_revoked_htlc,
@@ -1314,6 +1356,12 @@ extern "C" fn InMemorySigner_BaseSign_release_commitment_secret(this_arg: *const
        crate::c_types::ThirtyTwoBytes { data: ret }
 }
 #[must_use]
+extern "C" fn InMemorySigner_BaseSign_validate_holder_commitment(this_arg: *const c_void, _holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_NoneNoneZ {
+       let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, _holder_tx.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( { () /*e*/ }).into() };
+       local_ret
+}
+#[must_use]
 extern "C" fn InMemorySigner_BaseSign_pubkeys(this_arg: *const c_void) -> crate::lightning::ln::chan_utils::ChannelPublicKeys {
        let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, );
        crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const _) as *mut _) }, is_owned: false }
@@ -1337,6 +1385,12 @@ extern "C" fn InMemorySigner_BaseSign_sign_counterparty_commitment(this_arg: *co
        local_ret
 }
 #[must_use]
+extern "C" fn InMemorySigner_BaseSign_validate_counterparty_revocation(this_arg: *const c_void, mut _idx: u64, _secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ {
+       let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, _idx, &::bitcoin::secp256k1::key::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_BaseSign_sign_holder_commitment_and_htlcs(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
        let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_holder_commitment_and_htlcs(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::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::Signature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::Signature::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() };
@@ -1361,8 +1415,8 @@ extern "C" fn InMemorySigner_BaseSign_sign_counterparty_htlc_transaction(this_ar
        local_ret
 }
 #[must_use]
-extern "C" fn InMemorySigner_BaseSign_sign_closing_transaction(this_arg: *const c_void, mut closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
-       let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &closing_tx.into_bitcoin(), secp256k1::SECP256K1);
+extern "C" fn InMemorySigner_BaseSign_sign_closing_transaction(this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
+       let mut ret = <nativeInMemorySigner as lightning::chain::keysinterface::BaseSign<>>::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, closing_tx.get_native_ref(), secp256k1::SECP256K1);
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
        local_ret
 }
@@ -1398,11 +1452,13 @@ pub extern "C" fn InMemorySigner_as_Sign(this_arg: &InMemorySigner) -> crate::li
                        free: None,
                        get_per_commitment_point: InMemorySigner_BaseSign_get_per_commitment_point,
                        release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret,
+                       validate_holder_commitment: InMemorySigner_BaseSign_validate_holder_commitment,
 
                        pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true },
                        set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys),
                        channel_keys_id: InMemorySigner_BaseSign_channel_keys_id,
                        sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment,
+                       validate_counterparty_revocation: InMemorySigner_BaseSign_validate_counterparty_revocation,
                        sign_holder_commitment_and_htlcs: InMemorySigner_BaseSign_sign_holder_commitment_and_htlcs,
                        sign_justice_revoked_output: InMemorySigner_BaseSign_sign_justice_revoked_output,
                        sign_justice_revoked_htlc: InMemorySigner_BaseSign_sign_justice_revoked_htlc,
@@ -1600,7 +1656,7 @@ extern "C" fn KeysManager_KeysInterface_get_shutdown_scriptpubkey(this_arg: *con
 #[must_use]
 extern "C" fn KeysManager_KeysInterface_get_channel_signer(this_arg: *const c_void, mut _inbound: bool, mut channel_value_satoshis: u64) -> crate::lightning::chain::keysinterface::Sign {
        let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::get_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, _inbound, channel_value_satoshis);
-       ret.into()
+       Into::into(ret)
 }
 #[must_use]
 extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes {
@@ -1610,7 +1666,7 @@ extern "C" fn KeysManager_KeysInterface_get_secure_random_bytes(this_arg: *const
 #[must_use]
 extern "C" fn KeysManager_KeysInterface_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SignDecodeErrorZ {
        let mut ret = <nativeKeysManager as lightning::chain::keysinterface::KeysInterface<>>::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( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
 #[must_use]
index 9c8b4f5c044f00b82239e33e446fbd01b1ac574e..78f4b2ea2fff806ba7e9914dbaf13578eaf840a2 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -22,6 +23,7 @@ mod onchaintx {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -30,6 +32,7 @@ mod package {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 2006596dd5ede442ea152b736b50aac544e541f5..6971d5e80e0eea57e339d3b5b3f6bf602ebd565f 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 0fa8612da83a6e50745dd742e67c2fa529fc6bda..daaede48ea294b4b8c7233c45315a72a17a67b13 100644 (file)
@@ -11,6 +11,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -21,6 +22,13 @@ pub extern "C" fn build_commitment_secret(commitment_seed: *const [u8; 32], mut
        crate::c_types::ThirtyTwoBytes { data: ret }
 }
 
+/// 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::Script::from(to_holder_script.into_rust()), ::bitcoin::blockdata::script::Script::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint));
+       crate::c_types::Transaction::from_bitcoin(&ret)
+}
+
 /// Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key)
 /// from the base secret and the per_commitment_point.
 ///
@@ -560,7 +568,7 @@ pub extern "C" fn HTLCOutputInCommitment_set_payment_hash(this_ptr: &mut HTLCOut
 #[no_mangle]
 pub extern "C" fn HTLCOutputInCommitment_get_transaction_output_index(this_ptr: &HTLCOutputInCommitment) -> crate::c_types::derived::COption_u32Z {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().transaction_output_index;
-       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()) } };
+       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 position within the commitment transactions' outputs. This may be None if the value is
@@ -1327,10 +1335,215 @@ pub extern "C" fn BuiltCommitmentTransaction_sign(this_arg: &BuiltCommitmentTran
 }
 
 
+use lightning::ln::chan_utils::ClosingTransaction as nativeClosingTransactionImport;
+type nativeClosingTransaction = nativeClosingTransactionImport;
+
+/// This class tracks the per-transaction information needed to build a closing transaction and will
+/// actually build it and sign.
+///
+/// This class can be used inside a signer implementation to generate a signature given the relevant
+/// secret key.
+#[must_use]
+#[repr(C)]
+pub struct ClosingTransaction {
+       /// 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 nativeClosingTransaction,
+       /// 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 ClosingTransaction {
+       fn drop(&mut self) {
+               if self.is_owned && !<*mut nativeClosingTransaction>::is_null(self.inner) {
+                       let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+               }
+       }
+}
+/// Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn ClosingTransaction_free(this_obj: ClosingTransaction) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ClosingTransaction_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeClosingTransaction); }
+}
+#[allow(unused)]
+impl ClosingTransaction {
+       pub(crate) fn get_native_ref(&self) -> &'static nativeClosingTransaction {
+               unsafe { &*ObjOps::untweak_ptr(self.inner) }
+       }
+       pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeClosingTransaction {
+               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 nativeClosingTransaction {
+               assert!(self.is_owned);
+               let ret = ObjOps::untweak_ptr(self.inner);
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+/// Construct an object of the class
+#[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) -> ClosingTransaction {
+       let mut ret = lightning::ln::chan_utils::ClosingTransaction::new(to_holder_value_sat, to_counterparty_value_sat, ::bitcoin::blockdata::script::Script::from(to_holder_script.into_rust()), ::bitcoin::blockdata::script::Script::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint));
+       ClosingTransaction { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// 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.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClosingTransaction_trust(this_arg: &ClosingTransaction) -> crate::lightning::ln::chan_utils::TrustedClosingTransaction {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.trust();
+       crate::lightning::ln::chan_utils::TrustedClosingTransaction { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
+/// 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.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClosingTransaction_verify(this_arg: &ClosingTransaction, mut funding_outpoint: crate::lightning::chain::transaction::OutPoint) -> crate::c_types::derived::CResult_TrustedClosingTransactionNoneZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(crate::c_types::C_to_bitcoin_outpoint(funding_outpoint));
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::chan_utils::TrustedClosingTransaction { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() };
+       local_ret
+}
+
+/// The value to be sent to the holder, or zero if the output will be omitted
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClosingTransaction_to_holder_value_sat(this_arg: &ClosingTransaction) -> u64 {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_holder_value_sat();
+       ret
+}
+
+/// The value to be sent to the counterparty, or zero if the output will be omitted
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClosingTransaction_to_counterparty_value_sat(this_arg: &ClosingTransaction) -> u64 {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_counterparty_value_sat();
+       ret
+}
+
+/// The destination of the holder's output
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClosingTransaction_to_holder_script(this_arg: &ClosingTransaction) -> crate::c_types::u8slice {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_holder_script();
+       crate::c_types::u8slice::from_slice(&ret[..])
+}
+
+/// The destination of the counterparty's output
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ClosingTransaction_to_counterparty_script(this_arg: &ClosingTransaction) -> crate::c_types::u8slice {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_counterparty_script();
+       crate::c_types::u8slice::from_slice(&ret[..])
+}
+
+
+use lightning::ln::chan_utils::TrustedClosingTransaction as nativeTrustedClosingTransactionImport;
+type nativeTrustedClosingTransaction = nativeTrustedClosingTransactionImport<'static>;
+
+/// A wrapper on ClosingTransaction indicating that the built bitcoin
+/// transaction is trusted.
+///
+/// See trust() and verify() functions on CommitmentTransaction.
+///
+/// This structure implements Deref.
+#[must_use]
+#[repr(C)]
+pub struct TrustedClosingTransaction {
+       /// 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 nativeTrustedClosingTransaction,
+       /// 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 TrustedClosingTransaction {
+       fn drop(&mut self) {
+               if self.is_owned && !<*mut nativeTrustedClosingTransaction>::is_null(self.inner) {
+                       let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
+               }
+       }
+}
+/// Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL.
+#[no_mangle]
+pub extern "C" fn TrustedClosingTransaction_free(this_obj: TrustedClosingTransaction) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn TrustedClosingTransaction_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeTrustedClosingTransaction); }
+}
+#[allow(unused)]
+impl TrustedClosingTransaction {
+       pub(crate) fn get_native_ref(&self) -> &'static nativeTrustedClosingTransaction {
+               unsafe { &*ObjOps::untweak_ptr(self.inner) }
+       }
+       pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTrustedClosingTransaction {
+               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 nativeTrustedClosingTransaction {
+               assert!(self.is_owned);
+               let ret = ObjOps::untweak_ptr(self.inner);
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+/// The pre-built Bitcoin commitment transaction
+#[must_use]
+#[no_mangle]
+pub extern "C" fn TrustedClosingTransaction_built_transaction(this_arg: &TrustedClosingTransaction) -> crate::c_types::Transaction {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.built_transaction();
+       crate::c_types::Transaction::from_bitcoin(ret)
+}
+
+/// Get the SIGHASH_ALL sighash value of the transaction.
+///
+/// This can be used to verify a signature.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn TrustedClosingTransaction_get_sighash_all(this_arg: &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(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis);
+       crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() }
+}
+
+/// Sign a transaction, either because we are counter-signing the counterparty's transaction or
+/// because we are about to broadcast a holder transaction.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn TrustedClosingTransaction_sign(this_arg: &TrustedClosingTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, secp256k1::SECP256K1);
+       crate::c_types::Signature::from_rust(&ret)
+}
+
+
 use lightning::ln::chan_utils::CommitmentTransaction as nativeCommitmentTransactionImport;
 type nativeCommitmentTransaction = nativeCommitmentTransactionImport;
 
-/// This class tracks the per-transaction information needed to build a commitment transaction and to
+/// This class tracks the per-transaction information needed to build a commitment transaction and will
 /// actually build it and sign.  It is used for holder transactions that we sign only when needed
 /// and for transactions we sign for the counterparty.
 ///
@@ -1454,7 +1667,7 @@ pub extern "C" fn CommitmentTransaction_feerate_per_kw(this_arg: &CommitmentTran
 /// 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
-///\tbe used by an external signer - instead use the verify function.
+/// be used by an external signer - instead use the verify function.
 #[must_use]
 #[no_mangle]
 pub extern "C" fn CommitmentTransaction_trust(this_arg: &CommitmentTransaction) -> crate::lightning::ln::chan_utils::TrustedCommitmentTransaction {
index 8982a2ba1e663797c66700d8c9ef5eddc0773399..8ebf7fd4567a4d35835554c9b5477dd76619211b 100644 (file)
@@ -19,6 +19,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -242,6 +243,123 @@ pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_
 #[no_mangle]
 pub static MIN_FINAL_CLTV_EXPIRY: u32 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY;
 
+use lightning::ln::channelmanager::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport;
+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
+extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = 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 = std::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) { std::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 *mut 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()
+}
+
 use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport;
 type nativeChannelCounterparty = nativeChannelCounterpartyImport;
 
@@ -342,6 +460,37 @@ pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_pt
 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() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const _) 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;
+}
+/// Constructs a new ChannelCounterparty given each field
+#[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) -> 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()) } }) };
+       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,
+       }), is_owned: true }
+}
 impl Clone for ChannelCounterparty {
        fn clone(&self) -> Self {
                Self {
@@ -470,7 +619,7 @@ pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails,
 #[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()) } };
+       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
@@ -503,7 +652,7 @@ pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut Chann
 #[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()) } };
+       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
@@ -597,7 +746,7 @@ pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut Channe
 #[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()) } };
+       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
@@ -626,7 +775,7 @@ pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut Chann
 #[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()) } };
+       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
index ba3d77949de83d760591254ba84eb8853cf23cc0..f74b3909f1ee7e66949336936717ff253c38d00d 100644 (file)
@@ -23,6 +23,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -30,6 +31,7 @@ mod sealed {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -366,6 +368,15 @@ pub extern "C" fn InitFeatures_known() -> InitFeatures {
        InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
+/// 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: &InitFeatures) -> bool {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
+       ret
+}
+
 /// Create a blank Features with no features set
 #[must_use]
 #[no_mangle]
@@ -382,6 +393,15 @@ pub extern "C" fn NodeFeatures_known() -> NodeFeatures {
        NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
+/// 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: &NodeFeatures) -> bool {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
+       ret
+}
+
 /// Create a blank Features with no features set
 #[must_use]
 #[no_mangle]
@@ -398,6 +418,15 @@ pub extern "C" fn ChannelFeatures_known() -> ChannelFeatures {
        ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
+/// 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: &ChannelFeatures) -> bool {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
+       ret
+}
+
 /// Create a blank Features with no features set
 #[must_use]
 #[no_mangle]
@@ -414,6 +443,15 @@ pub extern "C" fn InvoiceFeatures_known() -> InvoiceFeatures {
        InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
+/// Returns true if this `Features` object contains unknown feature flags which are set as
+/// \"required\".
+#[must_use]
+#[no_mangle]
+pub extern "C" fn InvoiceFeatures_requires_unknown_bits(this_arg: &InvoiceFeatures) -> bool {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits();
+       ret
+}
+
 /// Returns whether the `payment_secret` feature is supported.
 #[must_use]
 #[no_mangle]
index 89ee33bc20a36d954631f346292e337dfe39ea75..be855e18fad83b4d2b3903e7e12349a33b8b8b89 100644 (file)
@@ -19,6 +19,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -28,10 +29,12 @@ pub mod peer_handler;
 pub mod chan_utils;
 pub mod features;
 pub mod script;
+pub mod wire;
 mod peer_channel_encryptor {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -40,6 +43,7 @@ mod channel {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -48,14 +52,7 @@ mod onion_utils {
 
 use std::str::FromStr;
 use std::ffi::c_void;
-use bitcoin::hashes::Hash;
-use crate::c_types::*;
-
-}
-mod wire {
-
-use std::str::FromStr;
-use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index b8a26157a5db230bdf5efa94601b12bc971d13dd..a4fe3a7ad1b41a9b462c0ee8d200bb6e48562e6e 100644 (file)
@@ -25,6 +25,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -1064,13 +1065,13 @@ pub extern "C" fn FundingCreated_get_funding_output_index(this_ptr: &FundingCrea
 pub extern "C" fn FundingCreated_set_funding_output_index(this_ptr: &mut FundingCreated, mut val: u16) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_output_index = val;
 }
-/// The signature of the channel initiator (funder) on the funding transaction
+/// The signature of the channel initiator (funder) on the initial commitment transaction
 #[no_mangle]
 pub extern "C" fn FundingCreated_get_signature(this_ptr: &FundingCreated) -> crate::c_types::Signature {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
        crate::c_types::Signature::from_rust(&inner_val)
 }
-/// The signature of the channel initiator (funder) on the funding transaction
+/// The signature of the channel initiator (funder) on the initial commitment transaction
 #[no_mangle]
 pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mut val: crate::c_types::Signature) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
@@ -1167,13 +1168,13 @@ pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *con
 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 = val.data;
 }
-/// The signature of the channel acceptor (fundee) on the funding transaction
+/// The signature of the channel acceptor (fundee) on the initial commitment transaction
 #[no_mangle]
 pub extern "C" fn FundingSigned_get_signature(this_ptr: &FundingSigned) -> crate::c_types::Signature {
        let mut inner_val = &mut this_ptr.get_native_mut_ref().signature;
        crate::c_types::Signature::from_rust(&inner_val)
 }
-/// The signature of the channel acceptor (fundee) on the funding transaction
+/// The signature of the channel acceptor (fundee) on the initial commitment transaction
 #[no_mangle]
 pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut val: crate::c_types::Signature) {
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.signature = val.into_rust();
@@ -4668,24 +4669,52 @@ impl CommitmentUpdate {
 }
 /// update_add_htlc messages which should be sent
 #[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_add_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateAddHTLCZ {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().update_add_htlcs;
+       let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const _) as *mut _) }, is_owned: false } }); };
+       local_inner_val.into()
+}
+/// update_add_htlc messages which should be sent
+#[no_mangle]
 pub extern "C" fn CommitmentUpdate_set_update_add_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateAddHTLCZ) {
        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) }.update_add_htlcs = local_val;
 }
 /// update_fulfill_htlc messages which should be sent
 #[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fulfill_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFulfillHTLCZ {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fulfill_htlcs;
+       let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const _) as *mut _) }, is_owned: false } }); };
+       local_inner_val.into()
+}
+/// update_fulfill_htlc messages which should be sent
+#[no_mangle]
 pub extern "C" fn CommitmentUpdate_set_update_fulfill_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFulfillHTLCZ) {
        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) }.update_fulfill_htlcs = local_val;
 }
 /// update_fail_htlc messages which should be sent
 #[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fail_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailHTLCZ {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_htlcs;
+       let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const _) as *mut _) }, is_owned: false } }); };
+       local_inner_val.into()
+}
+/// update_fail_htlc messages which should be sent
+#[no_mangle]
 pub extern "C" fn CommitmentUpdate_set_update_fail_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailHTLCZ) {
        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) }.update_fail_htlcs = local_val;
 }
 /// update_fail_malformed_htlc messages which should be sent
 #[no_mangle]
+pub extern "C" fn CommitmentUpdate_get_update_fail_malformed_htlcs(this_ptr: &CommitmentUpdate) -> crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fail_malformed_htlcs;
+       let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const _) as *mut _) }, is_owned: false } }); };
+       local_inner_val.into()
+}
+/// update_fail_malformed_htlc messages which should be sent
+#[no_mangle]
 pub extern "C" fn CommitmentUpdate_set_update_fail_malformed_htlcs(this_ptr: &mut CommitmentUpdate, mut val: crate::c_types::derived::CVec_UpdateFailMalformedHTLCZ) {
        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) }.update_fail_malformed_htlcs = local_val;
@@ -4755,168 +4784,6 @@ pub(crate) extern "C" fn CommitmentUpdate_clone_void(this_ptr: *const c_void) ->
 pub extern "C" fn CommitmentUpdate_clone(orig: &CommitmentUpdate) -> CommitmentUpdate {
        orig.clone()
 }
-/// The information we received from a peer along the route of a payment we originated. This is
-/// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
-/// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
-#[must_use]
-#[derive(Clone)]
-#[repr(C)]
-pub enum HTLCFailChannelUpdate {
-       /// We received an error which included a full ChannelUpdate message.
-       ChannelUpdateMessage {
-               /// The unwrapped message we received
-               msg: crate::lightning::ln::msgs::ChannelUpdate,
-       },
-       /// We received an error which indicated only that a channel has been closed
-       ChannelClosed {
-               /// The short_channel_id which has now closed.
-               short_channel_id: u64,
-               /// when this true, this channel should be permanently removed from the
-               /// consideration. Otherwise, this channel can be restored as new channel_update is received
-               is_permanent: bool,
-       },
-       /// We received an error which indicated only that a node has failed
-       NodeFailure {
-               /// The node_id that has failed.
-               node_id: crate::c_types::PublicKey,
-               /// when this true, node should be permanently removed from the
-               /// consideration. Otherwise, the channels connected to this node can be
-               /// restored as new channel_update is received
-               is_permanent: bool,
-       },
-}
-use lightning::ln::msgs::HTLCFailChannelUpdate as nativeHTLCFailChannelUpdate;
-impl HTLCFailChannelUpdate {
-       #[allow(unused)]
-       pub(crate) fn to_native(&self) -> nativeHTLCFailChannelUpdate {
-               match self {
-                       HTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
-                               let mut msg_nonref = (*msg).clone();
-                               nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
-                                       msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
-                               }
-                       },
-                       HTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
-                               let mut short_channel_id_nonref = (*short_channel_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
-                               nativeHTLCFailChannelUpdate::ChannelClosed {
-                                       short_channel_id: short_channel_id_nonref,
-                                       is_permanent: is_permanent_nonref,
-                               }
-                       },
-                       HTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
-                               let mut node_id_nonref = (*node_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
-                               nativeHTLCFailChannelUpdate::NodeFailure {
-                                       node_id: node_id_nonref.into_rust(),
-                                       is_permanent: is_permanent_nonref,
-                               }
-                       },
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn into_native(self) -> nativeHTLCFailChannelUpdate {
-               match self {
-                       HTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
-                               nativeHTLCFailChannelUpdate::ChannelUpdateMessage {
-                                       msg: *unsafe { Box::from_raw(msg.take_inner()) },
-                               }
-                       },
-                       HTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
-                               nativeHTLCFailChannelUpdate::ChannelClosed {
-                                       short_channel_id: short_channel_id,
-                                       is_permanent: is_permanent,
-                               }
-                       },
-                       HTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
-                               nativeHTLCFailChannelUpdate::NodeFailure {
-                                       node_id: node_id.into_rust(),
-                                       is_permanent: is_permanent,
-                               }
-                       },
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn from_native(native: &nativeHTLCFailChannelUpdate) -> Self {
-               match native {
-                       nativeHTLCFailChannelUpdate::ChannelUpdateMessage {ref msg, } => {
-                               let mut msg_nonref = (*msg).clone();
-                               HTLCFailChannelUpdate::ChannelUpdateMessage {
-                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
-                               }
-                       },
-                       nativeHTLCFailChannelUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
-                               let mut short_channel_id_nonref = (*short_channel_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
-                               HTLCFailChannelUpdate::ChannelClosed {
-                                       short_channel_id: short_channel_id_nonref,
-                                       is_permanent: is_permanent_nonref,
-                               }
-                       },
-                       nativeHTLCFailChannelUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
-                               let mut node_id_nonref = (*node_id).clone();
-                               let mut is_permanent_nonref = (*is_permanent).clone();
-                               HTLCFailChannelUpdate::NodeFailure {
-                                       node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
-                                       is_permanent: is_permanent_nonref,
-                               }
-                       },
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn native_into(native: nativeHTLCFailChannelUpdate) -> Self {
-               match native {
-                       nativeHTLCFailChannelUpdate::ChannelUpdateMessage {mut msg, } => {
-                               HTLCFailChannelUpdate::ChannelUpdateMessage {
-                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true },
-                               }
-                       },
-                       nativeHTLCFailChannelUpdate::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
-                               HTLCFailChannelUpdate::ChannelClosed {
-                                       short_channel_id: short_channel_id,
-                                       is_permanent: is_permanent,
-                               }
-                       },
-                       nativeHTLCFailChannelUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
-                               HTLCFailChannelUpdate::NodeFailure {
-                                       node_id: crate::c_types::PublicKey::from_rust(&node_id),
-                                       is_permanent: is_permanent,
-                               }
-                       },
-               }
-       }
-}
-/// Frees any resources used by the HTLCFailChannelUpdate
-#[no_mangle]
-pub extern "C" fn HTLCFailChannelUpdate_free(this_ptr: HTLCFailChannelUpdate) { }
-/// Creates a copy of the HTLCFailChannelUpdate
-#[no_mangle]
-pub extern "C" fn HTLCFailChannelUpdate_clone(orig: &HTLCFailChannelUpdate) -> HTLCFailChannelUpdate {
-       orig.clone()
-}
-#[no_mangle]
-/// Utility method to constructs a new ChannelUpdateMessage-variant HTLCFailChannelUpdate
-pub extern "C" fn HTLCFailChannelUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> HTLCFailChannelUpdate {
-       HTLCFailChannelUpdate::ChannelUpdateMessage {
-               msg,
-       }
-}
-#[no_mangle]
-/// Utility method to constructs a new ChannelClosed-variant HTLCFailChannelUpdate
-pub extern "C" fn HTLCFailChannelUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> HTLCFailChannelUpdate {
-       HTLCFailChannelUpdate::ChannelClosed {
-               short_channel_id,
-               is_permanent,
-       }
-}
-#[no_mangle]
-/// Utility method to constructs a new NodeFailure-variant HTLCFailChannelUpdate
-pub extern "C" fn HTLCFailChannelUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> HTLCFailChannelUpdate {
-       HTLCFailChannelUpdate::NodeFailure {
-               node_id,
-               is_permanent,
-       }
-}
 /// A trait to describe an object which can receive channel messages.
 ///
 /// Messages MAY be called in parallel when they originate from different their_node_ids, however
@@ -5119,8 +4986,6 @@ pub struct RoutingMessageHandler {
        /// false or returning an Err otherwise.
        #[must_use]
        pub handle_channel_update: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ,
-       /// Handle some updates to the route graph that we learned due to an outbound failed payment.
-       pub handle_htlc_fail_channel_update: extern "C" fn (this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate),
        /// Gets a subset of the channel announcements and updates required to dump our routing table
        /// to a remote node, starting at the short_channel_id indicated by starting_point and
        /// including the batch_amount entries immediately higher in numerical value than starting_point.
@@ -5172,7 +5037,6 @@ pub(crate) extern "C" fn RoutingMessageHandler_clone_fields(orig: &RoutingMessag
                handle_node_announcement: Clone::clone(&orig.handle_node_announcement),
                handle_channel_announcement: Clone::clone(&orig.handle_channel_announcement),
                handle_channel_update: Clone::clone(&orig.handle_channel_update),
-               handle_htlc_fail_channel_update: Clone::clone(&orig.handle_htlc_fail_channel_update),
                get_next_channel_announcements: Clone::clone(&orig.get_next_channel_announcements),
                get_next_node_announcements: Clone::clone(&orig.get_next_node_announcements),
                sync_routing_table: Clone::clone(&orig.sync_routing_table),
@@ -5209,9 +5073,6 @@ impl rustRoutingMessageHandler for RoutingMessageHandler {
                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_htlc_fail_channel_update(&self, mut update: &lightning::ln::msgs::HTLCFailChannelUpdate) {
-               (self.handle_htlc_fail_channel_update)(self.this_arg, &crate::lightning::ln::msgs::HTLCFailChannelUpdate::from_native(update))
-       }
        fn get_next_channel_announcements(&self, mut starting_point: u64, mut batch_amount: u8) -> Vec<(lightning::ln::msgs::ChannelAnnouncement, Option<lightning::ln::msgs::ChannelUpdate>, Option<lightning::ln::msgs::ChannelUpdate>)> {
                let mut ret = (self.get_next_channel_announcements)(self.this_arg, starting_point, batch_amount);
                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 = 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 }); };
@@ -5270,6 +5131,7 @@ mod fuzzy_internal_msgs {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -5723,13 +5585,6 @@ pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) ->
        crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) })
 }
 #[no_mangle]
-/// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
-pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
-       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
-       local_res
-}
-#[no_mangle]
 /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read
 pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
@@ -5738,6 +5593,13 @@ pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &ReplyShortChannelIdsEnd) -
 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) })
 }
+#[no_mangle]
+/// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write
+pub extern "C" fn ReplyShortChannelIdsEnd_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyShortChannelIdsEndDecodeErrorZ {
+       let res = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
 ///\n\t * Calculates the overflow safe ending block height for the query.\n\t * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`\n\t 
 #[must_use]
 #[no_mangle]
@@ -5746,13 +5608,6 @@ pub extern "C" fn QueryChannelRange_end_blocknum(this_arg: &QueryChannelRange) -
        ret
 }
 
-#[no_mangle]
-/// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
-pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
-       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
-       local_res
-}
 #[no_mangle]
 /// Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read
 pub extern "C" fn QueryChannelRange_write(obj: &QueryChannelRange) -> crate::c_types::derived::CVec_u8Z {
@@ -5763,6 +5618,13 @@ pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> cra
        crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) })
 }
 #[no_mangle]
+/// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write
+pub extern "C" fn QueryChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_QueryChannelRangeDecodeErrorZ {
+       let res = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
+#[no_mangle]
 /// Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write
 pub extern "C" fn ReplyChannelRange_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReplyChannelRangeDecodeErrorZ {
        let res = crate::c_types::deserialize_obj(ser);
@@ -5779,13 +5641,6 @@ pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> cra
        crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) })
 }
 #[no_mangle]
-/// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
-pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
-       let res = crate::c_types::deserialize_obj(ser);
-       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
-       local_res
-}
-#[no_mangle]
 /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
 pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref())
@@ -5794,3 +5649,10 @@ pub extern "C" fn GossipTimestampFilter_write(obj: &GossipTimestampFilter) -> cr
 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) })
 }
+#[no_mangle]
+/// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
+pub extern "C" fn GossipTimestampFilter_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_GossipTimestampFilterDecodeErrorZ {
+       let res = crate::c_types::deserialize_obj(ser);
+       let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::GossipTimestampFilter { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_res
+}
index fda89fc7528fa91e0d723bd6d0847134144efdea..eeb69979afdd0d4dd243cd8a0983bf9e26d359e1 100644 (file)
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
+/// Handler for BOLT1-compliant messages.
+#[repr(C)]
+pub struct CustomMessageHandler {
+       /// 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,
+       /// Called with the message type that was received and the buffer to be read.
+       /// Can return a `MessageHandlingError` if the message could not be handled.
+       #[must_use]
+       pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::ln::wire::Type, sender_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ,
+       /// Gets the list of pending messages which were generated by the custom message
+       /// handler, clearing the list in the process. The first tuple element must
+       /// correspond to the intended recipients node ids. If no connection to one of the
+       /// specified node does not exist, the message is simply not sent to it.
+       #[must_use]
+       pub get_and_clear_pending_msg: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyTypeZZ,
+       /// 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.
+       /// 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<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for CustomMessageHandler {}
+unsafe impl Sync for CustomMessageHandler {}
+#[no_mangle]
+pub(crate) extern "C" fn CustomMessageHandler_clone_fields(orig: &CustomMessageHandler) -> CustomMessageHandler {
+       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),
+               CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader_clone_fields(&orig.CustomMessageReader),
+               free: Clone::clone(&orig.free),
+       }
+}
+impl lightning::ln::wire::CustomMessageReader for CustomMessageHandler {
+       type CustomMessage = crate::lightning::ln::wire::Type;
+       fn read<R:std::io::Read>(&self, mut message_type: u16, mut buffer: &mut R) -> Result<Option<crate::lightning::ln::wire::Type>, lightning::ln::msgs::DecodeError> {
+               let mut ret = (self.CustomMessageReader.read)(self.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((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
+               local_ret
+       }
+}
+
+use lightning::ln::peer_handler::CustomMessageHandler as rustCustomMessageHandler;
+impl rustCustomMessageHandler for CustomMessageHandler {
+       fn handle_custom_message(&self, mut msg: crate::lightning::ln::wire::Type, mut sender_node_id: &bitcoin::secp256k1::key::PublicKey) -> Result<(), lightning::ln::msgs::LightningError> {
+               let mut ret = (self.handle_custom_message)(self.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::key::PublicKey, crate::lightning::ln::wire::Type)> {
+               let mut ret = (self.get_and_clear_pending_msg)(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_rust(), orig_ret_0_1); 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 std::ops::Deref for CustomMessageHandler {
+       type Target = Self;
+       fn deref(&self) -> &Self {
+               self
+       }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn CustomMessageHandler_free(this_ptr: CustomMessageHandler) { }
+impl Drop for CustomMessageHandler {
+       fn drop(&mut self) {
+               if let Some(f) = self.free {
+                       f(self.this_arg);
+               }
+       }
+}
 
 use lightning::ln::peer_handler::IgnoringMessageHandler as nativeIgnoringMessageHandlerImport;
 type nativeIgnoringMessageHandler = nativeIgnoringMessageHandlerImport;
@@ -126,7 +202,6 @@ pub extern "C" fn IgnoringMessageHandler_as_RoutingMessageHandler(this_arg: &Ign
                handle_node_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement,
                handle_channel_announcement: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement,
                handle_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update,
-               handle_htlc_fail_channel_update: IgnoringMessageHandler_RoutingMessageHandler_handle_htlc_fail_channel_update,
                get_next_channel_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements,
                get_next_node_announcements: IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcements,
                sync_routing_table: IgnoringMessageHandler_RoutingMessageHandler_sync_routing_table,
@@ -160,9 +235,6 @@ extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update
        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
 }
-extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, _update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate) {
-       <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &_update.to_native())
-}
 #[must_use]
 extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut _starting_point: u64, mut _batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
        let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _starting_point, _batch_amount);
@@ -204,6 +276,78 @@ extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_ch
        local_ret
 }
 
+use core::convert::Infallible as nativeInfallible;
+impl From<nativeInfallible> for crate::lightning::ln::wire::Type {
+       fn from(obj: nativeInfallible) -> Self {
+               unreachable!();
+       }
+}
+impl From<nativeIgnoringMessageHandler> for crate::lightning::ln::wire::CustomMessageReader {
+       fn from(obj: nativeIgnoringMessageHandler) -> Self {
+               let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
+               let mut ret = IgnoringMessageHandler_as_CustomMessageReader(&rust_obj);
+               // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+               rust_obj.inner = std::ptr::null_mut();
+               ret.free = Some(IgnoringMessageHandler_free_void);
+               ret
+       }
+}
+/// 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
+#[no_mangle]
+pub extern "C" fn IgnoringMessageHandler_as_CustomMessageReader(this_arg: &IgnoringMessageHandler) -> crate::lightning::ln::wire::CustomMessageReader {
+       crate::lightning::ln::wire::CustomMessageReader {
+               this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+               free: None,
+               read: IgnoringMessageHandler_CustomMessageReader_read,
+       }
+}
+
+#[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 = <nativeIgnoringMessageHandler as lightning::ln::wire::CustomMessageReader<>>::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 { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
+       local_ret
+}
+
+impl From<nativeIgnoringMessageHandler> for crate::lightning::ln::peer_handler::CustomMessageHandler {
+       fn from(obj: nativeIgnoringMessageHandler) -> Self {
+               let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
+               let mut ret = IgnoringMessageHandler_as_CustomMessageHandler(&rust_obj);
+               // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+               rust_obj.inner = std::ptr::null_mut();
+               ret.free = Some(IgnoringMessageHandler_free_void);
+               ret
+       }
+}
+/// 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
+#[no_mangle]
+pub extern "C" fn IgnoringMessageHandler_as_CustomMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::lightning::ln::peer_handler::CustomMessageHandler {
+       crate::lightning::ln::peer_handler::CustomMessageHandler {
+               this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+               free: None,
+               handle_custom_message: IgnoringMessageHandler_CustomMessageHandler_handle_custom_message,
+               get_and_clear_pending_msg: IgnoringMessageHandler_CustomMessageHandler_get_and_clear_pending_msg,
+               CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader {
+                       this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+                       free: None,
+                       read: IgnoringMessageHandler_CustomMessageReader_read,
+               },
+       }
+}
+
+#[must_use]
+extern "C" fn IgnoringMessageHandler_CustomMessageHandler_handle_custom_message(this_arg: *const c_void, mut msg: crate::lightning::ln::wire::Type, mut sender_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       unreachable!();
+}
+#[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 = <nativeIgnoringMessageHandler as lightning::ln::peer_handler::CustomMessageHandler<>>::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()
+}
+
 
 use lightning::ln::peer_handler::ErroringMessageHandler as nativeErroringMessageHandlerImport;
 type nativeErroringMessageHandler = nativeErroringMessageHandlerImport;
@@ -707,7 +851,7 @@ pub extern "C" fn PeerHandleError_clone(orig: &PeerHandleError) -> PeerHandleErr
 }
 
 use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport;
-type nativePeerManager = nativePeerManagerImport<crate::lightning::ln::peer_handler::SocketDescriptor, crate::lightning::ln::msgs::ChannelMessageHandler, crate::lightning::ln::msgs::RoutingMessageHandler, crate::lightning::util::logger::Logger>;
+type nativePeerManager = nativePeerManagerImport<crate::lightning::ln::peer_handler::SocketDescriptor, crate::lightning::ln::msgs::ChannelMessageHandler, crate::lightning::ln::msgs::RoutingMessageHandler, crate::lightning::util::logger::Logger, crate::lightning::ln::peer_handler::CustomMessageHandler>;
 
 /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls
 /// socket events into messages which it passes on to its [`MessageHandler`].
@@ -779,8 +923,8 @@ impl PeerManager {
 /// cryptographically secure random bytes.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut our_node_secret: crate::c_types::SecretKey, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger) -> PeerManager {
-       let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, our_node_secret.into_rust(), unsafe { &*ephemeral_random_data}, logger);
+pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::peer_handler::MessageHandler, mut our_node_secret: crate::c_types::SecretKey, ephemeral_random_data: *const [u8; 32], mut logger: crate::lightning::util::logger::Logger, mut custom_message_handler: crate::lightning::ln::peer_handler::CustomMessageHandler) -> PeerManager {
+       let mut ret = lightning::ln::peer_handler::PeerManager::new(*unsafe { Box::from_raw(message_handler.take_inner()) }, our_node_secret.into_rust(), unsafe { &*ephemeral_random_data}, logger, custom_message_handler);
        PeerManager { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
@@ -883,6 +1027,9 @@ pub extern "C" fn PeerManager_read_event(this_arg: &PeerManager, peer_descriptor
 /// 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.
+///
 /// [`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
index 9f74a41f44afe3d8333f1b7f76109c105d3c91a9..73c90247ac61a5062fdebcf4b8a03381f9a15619 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
diff --git a/lightning-c-bindings/src/lightning/ln/wire.rs b/lightning-c-bindings/src/lightning/ln/wire.rs
new file mode 100644 (file)
index 0000000..5a943a2
--- /dev/null
@@ -0,0 +1,153 @@
+// 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.
+
+//! Wire encoding/decoding for Lightning messages according to [BOLT #1], and for
+//! custom message through the [`CustomMessageReader`] trait.
+//! 
+//! [BOLT #1]: https://github.com/lightningnetwork/lightning-rfc/blob/master/01-messaging.md
+
+use std::str::FromStr;
+use std::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+/// Trait to be implemented by custom message (unrelated to the channel/gossip LN layers)
+/// decoders.
+#[repr(C)]
+pub struct CustomMessageReader {
+       /// 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,
+       /// Decodes a custom message to `CustomMessageType`. If the given message type is known to the
+       /// implementation and the message could be decoded, must return `Ok(Some(message))`. If the
+       /// message type is unknown to the implementation, must return `Ok(None)`. If a decoding error
+       /// occur, must return `Err(DecodeError::X)` where `X` details the encountered error.
+       #[must_use]
+       pub read: extern "C" fn (this_arg: *const c_void, message_type: u16, buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_TypeZDecodeErrorZ,
+       /// 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<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for CustomMessageReader {}
+unsafe impl Sync for CustomMessageReader {}
+#[no_mangle]
+pub(crate) extern "C" fn CustomMessageReader_clone_fields(orig: &CustomMessageReader) -> CustomMessageReader {
+       CustomMessageReader {
+               this_arg: orig.this_arg,
+               read: Clone::clone(&orig.read),
+               free: Clone::clone(&orig.free),
+       }
+}
+
+use lightning::ln::wire::CustomMessageReader as rustCustomMessageReader;
+impl rustCustomMessageReader for CustomMessageReader {
+       type CustomMessage = crate::lightning::ln::wire::Type;
+       fn read<R:std::io::Read>(&self, mut message_type: u16, mut buffer: &mut R) -> Result<Option<crate::lightning::ln::wire::Type>, lightning::ln::msgs::DecodeError> {
+               let mut ret = (self.read)(self.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((*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 std::ops::Deref for CustomMessageReader {
+       type Target = Self;
+       fn deref(&self) -> &Self {
+               self
+       }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn CustomMessageReader_free(this_ptr: CustomMessageReader) { }
+impl Drop for CustomMessageReader {
+       fn drop(&mut self) {
+               if let Some(f) = self.free {
+                       f(self.this_arg);
+               }
+       }
+}
+mod encode {
+
+use std::str::FromStr;
+use std::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+}
+/// Defines a type identifier for sending messages over the wire.
+///
+/// Messages implementing this trait specify a type and must be [`Writeable`].
+#[repr(C)]
+pub struct Type {
+       /// 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 type identifying the message payload.
+       #[must_use]
+       pub type_id: extern "C" fn (this_arg: *const c_void) -> u16,
+       /// Return a human-readable "debug" string describing this object
+       pub debug_str: 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,
+       /// 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<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for Type {}
+unsafe impl Sync for Type {}
+#[no_mangle]
+pub(crate) extern "C" fn Type_clone_fields(orig: &Type) -> Type {
+       Type {
+               this_arg: orig.this_arg,
+               type_id: Clone::clone(&orig.type_id),
+               debug_str: Clone::clone(&orig.debug_str),
+               write: Clone::clone(&orig.write),
+               free: Clone::clone(&orig.free),
+       }
+}
+impl core::fmt::Debug for Type {
+       fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
+               f.write_str((self.debug_str)(self.this_arg).into_str())
+       }
+}
+impl lightning::util::ser::Writeable for Type {
+       fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+               let vec = (self.write)(self.this_arg);
+               w.write_all(vec.as_slice())
+       }
+}
+
+use lightning::ln::wire::Type as rustType;
+impl rustType for Type {
+       fn type_id(&self) -> u16 {
+               let mut ret = (self.type_id)(self.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 std::ops::Deref for Type {
+       type Target = Self;
+       fn deref(&self) -> &Self {
+               self
+       }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn Type_free(this_ptr: Type) { }
+impl Drop for Type {
+       fn drop(&mut self) {
+               if let Some(f) = self.free {
+                       f(self.this_arg);
+               }
+       }
+}
index ddbcbb7a8657c4766850d4c21728e63c019fb0e6..659087a9857627c3941c9ecc2296dac26748c3c7 100644 (file)
@@ -18,6 +18,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -29,6 +30,7 @@ mod prelude {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 9cc0eb411ac8ab5dc0fc24416c8c775531e48bcb..1cc1bfbccc1917d02050307d476262ffb27792d1 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index fe64794943167c60a3ce21f55067f4999c7aabc4..f1e72f1963c27ccdc5b5eaa28272ee676c626d1c 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -64,40 +65,19 @@ impl NetworkGraph {
                ret
        }
 }
-impl Clone for NetworkGraph {
-       fn clone(&self) -> Self {
-               Self {
-                       inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::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 NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void
-}
-#[no_mangle]
-/// Creates a copy of the NetworkGraph
-pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph {
-       orig.clone()
-}
 
-use lightning::routing::network_graph::LockedNetworkGraph as nativeLockedNetworkGraphImport;
-type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>;
+use lightning::routing::network_graph::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport;
+type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>;
 
-/// A simple newtype for RwLockReadGuard<'a, NetworkGraph>.
-/// This exists only to make accessing a RwLock<NetworkGraph> possible from
-/// the C bindings, as it can be done directly in Rust code.
+/// A read-only view of [`NetworkGraph`].
 #[must_use]
 #[repr(C)]
-pub struct LockedNetworkGraph {
+pub struct ReadOnlyNetworkGraph {
        /// 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 nativeLockedNetworkGraph,
+       pub inner: *mut nativeReadOnlyNetworkGraph,
        /// 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
@@ -105,37 +85,232 @@ pub struct LockedNetworkGraph {
        pub is_owned: bool,
 }
 
-impl Drop for LockedNetworkGraph {
+impl Drop for ReadOnlyNetworkGraph {
        fn drop(&mut self) {
-               if self.is_owned && !<*mut nativeLockedNetworkGraph>::is_null(self.inner) {
+               if self.is_owned && !<*mut nativeReadOnlyNetworkGraph>::is_null(self.inner) {
                        let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) };
                }
        }
 }
-/// Frees any resources used by the LockedNetworkGraph, if is_owned is set and inner is non-NULL.
+/// Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL.
 #[no_mangle]
-pub extern "C" fn LockedNetworkGraph_free(this_obj: LockedNetworkGraph) { }
+pub extern "C" fn ReadOnlyNetworkGraph_free(this_obj: ReadOnlyNetworkGraph) { }
 #[allow(unused)]
 /// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn LockedNetworkGraph_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeLockedNetworkGraph); }
+extern "C" fn ReadOnlyNetworkGraph_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeReadOnlyNetworkGraph); }
 }
 #[allow(unused)]
-impl LockedNetworkGraph {
-       pub(crate) fn get_native_ref(&self) -> &'static nativeLockedNetworkGraph {
+impl ReadOnlyNetworkGraph {
+       pub(crate) fn get_native_ref(&self) -> &'static nativeReadOnlyNetworkGraph {
                unsafe { &*ObjOps::untweak_ptr(self.inner) }
        }
-       pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeLockedNetworkGraph {
+       pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReadOnlyNetworkGraph {
                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 nativeLockedNetworkGraph {
+       pub(crate) fn take_inner(mut self) -> *mut nativeReadOnlyNetworkGraph {
                assert!(self.is_owned);
                let ret = ObjOps::untweak_ptr(self.inner);
                self.inner = std::ptr::null_mut();
                ret
        }
 }
+/// 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.
+///
+/// [BOLT #4]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md
+#[must_use]
+#[derive(Clone)]
+#[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 only that a channel has been closed, which should be applied via
+       /// [`NetworkGraph::close_channel_from_update`].
+       ChannelClosed {
+               /// The short channel id of the closed channel.
+               short_channel_id: u64,
+               /// Whether the channel should be permanently removed or temporarily disabled until a new
+               /// `channel_update` message is received.
+               is_permanent: bool,
+       },
+       /// An error indicating only that a node has failed, which should be applied via
+       /// [`NetworkGraph::fail_node`].
+       NodeFailure {
+               /// The node id of the failed node.
+               node_id: crate::c_types::PublicKey,
+               /// Whether the node should be permanently removed from consideration or can be restored
+               /// when a new `channel_update` message is received.
+               is_permanent: bool,
+       },
+}
+use lightning::routing::network_graph::NetworkUpdate as nativeNetworkUpdate;
+impl NetworkUpdate {
+       #[allow(unused)]
+       pub(crate) fn to_native(&self) -> nativeNetworkUpdate {
+               match self {
+                       NetworkUpdate::ChannelUpdateMessage {ref msg, } => {
+                               let mut msg_nonref = (*msg).clone();
+                               nativeNetworkUpdate::ChannelUpdateMessage {
+                                       msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) },
+                               }
+                       },
+                       NetworkUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
+                               let mut short_channel_id_nonref = (*short_channel_id).clone();
+                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               nativeNetworkUpdate::ChannelClosed {
+                                       short_channel_id: short_channel_id_nonref,
+                                       is_permanent: is_permanent_nonref,
+                               }
+                       },
+                       NetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
+                               let mut node_id_nonref = (*node_id).clone();
+                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               nativeNetworkUpdate::NodeFailure {
+                                       node_id: node_id_nonref.into_rust(),
+                                       is_permanent: is_permanent_nonref,
+                               }
+                       },
+               }
+       }
+       #[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::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
+                               nativeNetworkUpdate::ChannelClosed {
+                                       short_channel_id: short_channel_id,
+                                       is_permanent: is_permanent,
+                               }
+                       },
+                       NetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
+                               nativeNetworkUpdate::NodeFailure {
+                                       node_id: node_id.into_rust(),
+                                       is_permanent: is_permanent,
+                               }
+                       },
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn from_native(native: &nativeNetworkUpdate) -> Self {
+               match native {
+                       nativeNetworkUpdate::ChannelUpdateMessage {ref msg, } => {
+                               let mut msg_nonref = (*msg).clone();
+                               NetworkUpdate::ChannelUpdateMessage {
+                                       msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true },
+                               }
+                       },
+                       nativeNetworkUpdate::ChannelClosed {ref short_channel_id, ref is_permanent, } => {
+                               let mut short_channel_id_nonref = (*short_channel_id).clone();
+                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               NetworkUpdate::ChannelClosed {
+                                       short_channel_id: short_channel_id_nonref,
+                                       is_permanent: is_permanent_nonref,
+                               }
+                       },
+                       nativeNetworkUpdate::NodeFailure {ref node_id, ref is_permanent, } => {
+                               let mut node_id_nonref = (*node_id).clone();
+                               let mut is_permanent_nonref = (*is_permanent).clone();
+                               NetworkUpdate::NodeFailure {
+                                       node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref),
+                                       is_permanent: is_permanent_nonref,
+                               }
+                       },
+               }
+       }
+       #[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::ChannelClosed {mut short_channel_id, mut is_permanent, } => {
+                               NetworkUpdate::ChannelClosed {
+                                       short_channel_id: short_channel_id,
+                                       is_permanent: is_permanent,
+                               }
+                       },
+                       nativeNetworkUpdate::NodeFailure {mut node_id, mut is_permanent, } => {
+                               NetworkUpdate::NodeFailure {
+                                       node_id: crate::c_types::PublicKey::from_rust(&node_id),
+                                       is_permanent: is_permanent,
+                               }
+                       },
+               }
+       }
+}
+/// Frees any resources used by the NetworkUpdate
+#[no_mangle]
+pub extern "C" fn NetworkUpdate_free(this_ptr: NetworkUpdate) { }
+/// Creates a copy of the NetworkUpdate
+#[no_mangle]
+pub extern "C" fn NetworkUpdate_clone(orig: &NetworkUpdate) -> NetworkUpdate {
+       orig.clone()
+}
+#[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 ChannelClosed-variant NetworkUpdate
+pub extern "C" fn NetworkUpdate_channel_closed(short_channel_id: u64, is_permanent: bool) -> NetworkUpdate {
+       NetworkUpdate::ChannelClosed {
+               short_channel_id,
+               is_permanent,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new NodeFailure-variant NetworkUpdate
+pub extern "C" fn NetworkUpdate_node_failure(node_id: crate::c_types::PublicKey, is_permanent: bool) -> NetworkUpdate {
+       NetworkUpdate::NodeFailure {
+               node_id,
+               is_permanent,
+       }
+}
+#[no_mangle]
+/// Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read
+pub extern "C" fn NetworkUpdate_write(obj: &NetworkUpdate) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
+}
+impl From<nativeNetGraphMsgHandler> for crate::lightning::util::events::EventHandler {
+       fn from(obj: nativeNetGraphMsgHandler) -> Self {
+               let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
+               let mut ret = NetGraphMsgHandler_as_EventHandler(&rust_obj);
+               // We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
+               rust_obj.inner = std::ptr::null_mut();
+               ret.free = Some(NetGraphMsgHandler_free_void);
+               ret
+       }
+}
+/// Constructs a new EventHandler which calls the relevant methods on this_arg.
+/// This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
+#[no_mangle]
+pub extern "C" fn NetGraphMsgHandler_as_EventHandler(this_arg: &NetGraphMsgHandler) -> crate::lightning::util::events::EventHandler {
+       crate::lightning::util::events::EventHandler {
+               this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void },
+               free: None,
+               handle_event: NetGraphMsgHandler_EventHandler_handle_event,
+       }
+}
+
+extern "C" fn NetGraphMsgHandler_EventHandler_handle_event(this_arg: *const c_void, event: &crate::lightning::util::events::Event) {
+       <nativeNetGraphMsgHandler as lightning::util::events::EventHandler<>>::handle_event(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &event.to_native())
+}
+
 
 use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
 type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::lightning::chain::Access, crate::lightning::util::logger::Logger>;
@@ -145,6 +320,9 @@ type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::lightning:
 /// This network graph is then used for routing payments.
 /// Provides interface to help with initial routing sync by
 /// serving historical announcements.
+///
+/// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
+/// [`NetworkGraph`].
 #[must_use]
 #[repr(C)]
 pub struct NetGraphMsgHandler {
@@ -191,63 +369,39 @@ impl NetGraphMsgHandler {
                ret
        }
 }
-/// Creates a new tracker of the actual state of the network of channels and nodes,
-/// assuming a fresh network graph.
-/// Chain monitor is used to make sure announced channels exist on-chain,
-/// channel data is correct, and that the announcement is signed with
-/// channel owners' keys.
-///
-/// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
-#[must_use]
+/// Representation of the payment channel network
 #[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_new(mut genesis_hash: crate::c_types::ThirtyTwoBytes, chain_access: *mut crate::lightning::chain::Access, mut logger: crate::lightning::util::logger::Logger) -> NetGraphMsgHandler {
-       let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
-       let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), local_chain_access, logger);
-       NetGraphMsgHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
+pub extern "C" fn NetGraphMsgHandler_get_network_graph(this_ptr: &NetGraphMsgHandler) -> crate::lightning::routing::network_graph::NetworkGraph {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().network_graph;
+       crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const _) as *mut _) }, is_owned: false }
+}
+/// Representation of the payment channel network
+#[no_mangle]
+pub extern "C" fn NetGraphMsgHandler_set_network_graph(this_ptr: &mut NetGraphMsgHandler, mut val: crate::lightning::routing::network_graph::NetworkGraph) {
+       unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network_graph = *unsafe { Box::from_raw(val.take_inner()) };
 }
-
 /// Creates a new tracker of the actual state of the network of channels and nodes,
 /// assuming an existing Network Graph.
-///
-/// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
+/// Chain monitor is used to make sure announced channels exist on-chain,
+/// channel data is correct, and that the announcement is signed with
+/// channel owners' keys.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_from_net_graph(chain_access: *mut crate::lightning::chain::Access, mut logger: crate::lightning::util::logger::Logger, mut network_graph: crate::lightning::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler {
-       let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
-       let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(local_chain_access, logger, *unsafe { Box::from_raw(network_graph.take_inner()) });
+pub extern "C" fn NetGraphMsgHandler_new(mut network_graph: crate::lightning::routing::network_graph::NetworkGraph, mut chain_access: crate::c_types::derived::COption_AccessZ, mut logger: crate::lightning::util::logger::Logger) -> NetGraphMsgHandler {
+       let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
+       let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(*unsafe { Box::from_raw(network_graph.take_inner()) }, local_chain_access, logger);
        NetGraphMsgHandler { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
 /// 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.
-///
-/// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
 #[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, chain_access: *mut crate::lightning::chain::Access) {
-       let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
+pub extern "C" fn NetGraphMsgHandler_add_chain_access(this_arg: &mut NetGraphMsgHandler, mut chain_access: crate::c_types::derived::COption_AccessZ) {
+       let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
        unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetGraphMsgHandler)) }.add_chain_access(local_chain_access)
 }
 
-/// Take a read lock on the network_graph and return it in the C-bindings
-/// newtype helper. This is likely only useful when called via the C
-/// bindings as you can call `self.network_graph.read().unwrap()` in Rust
-/// yourself.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_read_locked_graph(this_arg: &NetGraphMsgHandler) -> crate::lightning::routing::network_graph::LockedNetworkGraph {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_locked_graph();
-       crate::lightning::routing::network_graph::LockedNetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
-}
-
-/// Get a reference to the NetworkGraph which this read-lock contains.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn LockedNetworkGraph_graph(this_arg: &LockedNetworkGraph) -> crate::lightning::routing::network_graph::NetworkGraph {
-       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.graph();
-       crate::lightning::routing::network_graph::NetworkGraph { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const _) as *mut _) }, is_owned: false }
-}
-
 impl From<nativeNetGraphMsgHandler> for crate::lightning::ln::msgs::RoutingMessageHandler {
        fn from(obj: nativeNetGraphMsgHandler) -> Self {
                let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
@@ -268,7 +422,6 @@ pub extern "C" fn NetGraphMsgHandler_as_RoutingMessageHandler(this_arg: &NetGrap
                handle_node_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_node_announcement,
                handle_channel_announcement: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announcement,
                handle_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update,
-               handle_htlc_fail_channel_update: NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update,
                get_next_channel_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements,
                get_next_node_announcements: NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcements,
                sync_routing_table: NetGraphMsgHandler_RoutingMessageHandler_sync_routing_table,
@@ -296,9 +449,6 @@ extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_announceme
        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
 }
-extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_htlc_fail_channel_update(this_arg: *const c_void, update: &crate::lightning::ln::msgs::HTLCFailChannelUpdate) {
-       <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_htlc_fail_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, &update.to_native())
-}
 #[must_use]
 extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ {
        let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, msg.get_native_ref());
@@ -476,7 +626,7 @@ pub extern "C" fn DirectionalChannelInfo_set_htlc_minimum_msat(this_ptr: &mut Di
 #[no_mangle]
 pub extern "C" fn DirectionalChannelInfo_get_htlc_maximum_msat(this_ptr: &DirectionalChannelInfo) -> 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()) } };
+       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 which may be relayed to the next hop via the channel.
@@ -693,7 +843,7 @@ pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val
 #[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()) } };
+       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.
@@ -890,6 +1040,16 @@ pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut
 pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees {
        orig.clone()
 }
+/// Checks if two RoutingFeess contain equal inner contents.
+#[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 std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::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: &RoutingFees) -> crate::c_types::derived::CVec_u8Z {
@@ -1257,6 +1417,14 @@ pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBy
        crate::lightning::routing::network_graph::NetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
+/// Returns a read-only view of the network graph.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NetworkGraph_read_only(this_arg: &NetworkGraph) -> crate::lightning::routing::network_graph::ReadOnlyNetworkGraph {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_only();
+       crate::lightning::routing::network_graph::ReadOnlyNetworkGraph { inner: ObjOps::heap_alloc(ret), is_owned: true }
+}
+
 /// For an already known node (from channel announcements), update its stored properties from a
 /// given node announcement.
 ///
@@ -1265,8 +1433,8 @@ pub extern "C" fn NetworkGraph_new(mut genesis_hash: crate::c_types::ThirtyTwoBy
 /// routing messages from a source using a protocol other than the lightning P2P protocol.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_announcement(msg.get_native_ref(), secp256k1::SECP256K1);
+pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_announcement(msg.get_native_ref(), secp256k1::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( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
@@ -1277,8 +1445,8 @@ pub extern "C" fn NetworkGraph_update_node_from_announcement(this_arg: &mut Netw
 /// peers.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetworkGraph)) }.update_node_from_unsigned_announcement(msg.get_native_ref());
+pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_node_from_unsigned_announcement(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
 }
@@ -1291,13 +1459,11 @@ pub extern "C" fn NetworkGraph_update_node_from_unsigned_announcement(this_arg:
 ///
 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
 /// the corresponding UTXO exists on chain and is correctly-formatted.
-///
-/// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, chain_access: *mut crate::lightning::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
-       let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_announcement(msg.get_native_ref(), &local_chain_access, secp256k1::SECP256K1);
+pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_announcement(msg.get_native_ref(), &local_chain_access, secp256k1::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( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
@@ -1308,13 +1474,11 @@ pub extern "C" fn NetworkGraph_update_channel_from_announcement(this_arg: &mut N
 ///
 /// If a `chain::Access` object is provided via `chain_access`, it will be called to verify
 /// the corresponding UTXO exists on chain and is correctly-formatted.
-///
-/// Note that chain_access (or a relevant inner pointer) may be NULL or all-0s to represent None
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, chain_access: *mut crate::lightning::chain::Access) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut local_chain_access = if chain_access == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_access) } }) };
-       let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_from_unsigned_announcement(msg.get_native_ref(), &local_chain_access);
+pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement, mut chain_access: crate::c_types::derived::COption_AccessZ) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut local_chain_access = { /* chain_access*/ let chain_access_opt = chain_access; { } if chain_access_opt.is_none() { None } else { Some({ chain_access_opt.take() }) } };
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_from_unsigned_announcement(msg.get_native_ref(), &local_chain_access);
        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
 }
@@ -1324,8 +1488,14 @@ pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_ar
 /// May cause the removal of nodes too, if this was their last channel.
 /// If not permanent, makes channels unavailable for routing.
 #[no_mangle]
-pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &mut NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
-       unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetworkGraph)) }.close_channel_from_update(short_channel_id, is_permanent)
+pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &NetworkGraph, mut short_channel_id: u64, mut is_permanent: bool) {
+       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_from_update(short_channel_id, is_permanent)
+}
+
+/// Marks a node in the graph as failed.
+#[no_mangle]
+pub extern "C" fn NetworkGraph_fail_node(this_arg: &NetworkGraph, mut _node_id: crate::c_types::PublicKey, mut is_permanent: bool) {
+       unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_node(&_node_id.into_rust(), is_permanent)
 }
 
 /// For an already known (from announcement) channel, update info about one of the directions
@@ -1336,8 +1506,8 @@ pub extern "C" fn NetworkGraph_close_channel_from_update(this_arg: &mut NetworkG
 /// routing messages from a source using a protocol other than the lightning P2P protocol.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel(msg.get_native_ref(), secp256k1::SECP256K1);
+pub extern "C" fn NetworkGraph_update_channel(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel(msg.get_native_ref(), secp256k1::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( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
        local_ret
 }
@@ -1347,8 +1517,8 @@ pub extern "C" fn NetworkGraph_update_channel(this_arg: &mut NetworkGraph, msg:
 /// associated signatures here we cannot relay the channel update to any of our peers.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &mut NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
-       let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut nativeNetworkGraph)) }.update_channel_unsigned(msg.get_native_ref());
+pub extern "C" fn NetworkGraph_update_channel_unsigned(this_arg: &NetworkGraph, msg: &crate::lightning::ln::msgs::UnsignedChannelUpdate) -> crate::c_types::derived::CResult_NoneLightningErrorZ {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_unsigned(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
 }
index 7b017f48e92e1f63d7ddcec6b4c95326f82a3a61..ef58e5772b2ff43b0b34b9a6750d699dd9e7b478 100644 (file)
@@ -13,6 +13,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -175,6 +176,25 @@ pub(crate) extern "C" fn RouteHop_clone_void(this_ptr: *const c_void) -> *mut c_
 pub extern "C" fn RouteHop_clone(orig: &RouteHop) -> RouteHop {
        orig.clone()
 }
+/// Checks if two RouteHops contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn RouteHop_hash(o: &RouteHop) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// 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.
+#[no_mangle]
+pub extern "C" fn RouteHop_eq(a: &RouteHop, b: &RouteHop) -> 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 RouteHop object into a byte array which can be read by RouteHop_read
 pub extern "C" fn RouteHop_write(obj: &RouteHop) -> crate::c_types::derived::CVec_u8Z {
@@ -250,6 +270,18 @@ impl Route {
 /// given path is variable, keeping the length of any path to less than 20 should currently
 /// ensure it is viable.
 #[no_mangle]
+pub extern "C" fn Route_get_paths(this_ptr: &Route) -> crate::c_types::derived::CVec_CVec_RouteHopZZ {
+       let mut inner_val = &mut this_ptr.get_native_mut_ref().paths;
+       let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { let mut local_inner_val_0 = Vec::new(); for item in item.iter() { local_inner_val_0.push( { crate::lightning::routing::router::RouteHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const _) as *mut _) }, is_owned: false } }); }; local_inner_val_0.into() }); };
+       local_inner_val.into()
+}
+/// The list of routes taken for a single (potentially-)multi-part payment. The pubkey of the
+/// last RouteHop in each path must be the same.
+/// Each entry represents a list of hops, NOT INCLUDING our own, where the last hop is the
+/// destination. Thus, this must always be at least length one. While the maximum length of any
+/// given path is variable, keeping the length of any path to less than 20 should currently
+/// ensure it is viable.
+#[no_mangle]
 pub extern "C" fn Route_set_paths(this_ptr: &mut Route, mut val: crate::c_types::derived::CVec_CVec_RouteHopZZ) {
        let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { let mut local_val_0 = Vec::new(); for mut item in item.into_rust().drain(..) { local_val_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_val_0 }); };
        unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.paths = local_val;
@@ -282,6 +314,44 @@ pub(crate) extern "C" fn Route_clone_void(this_ptr: *const c_void) -> *mut c_voi
 pub extern "C" fn Route_clone(orig: &Route) -> Route {
        orig.clone()
 }
+/// Checks if two Routes contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Route_hash(o: &Route) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// 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.
+#[no_mangle]
+pub extern "C" fn Route_eq(a: &Route, b: &Route) -> 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 the total amount of fees paid on this [`Route`].
+///
+/// This doesn't include any extra payment made to the recipient, which can happen in excess of
+/// the amount passed to [`get_route`]'s `final_value_msat`.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Route_get_total_fees(this_arg: &Route) -> u64 {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_fees();
+       ret
+}
+
+/// Returns the total amount paid on this [`Route`], excluding the fees.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn Route_get_total_amount(this_arg: &Route) -> u64 {
+       let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_total_amount();
+       ret
+}
+
 #[no_mangle]
 /// Serialize the Route object into a byte array which can be read by Route_read
 pub extern "C" fn Route_write(obj: &Route) -> crate::c_types::derived::CVec_u8Z {
@@ -349,15 +419,6 @@ impl RouteHint {
                ret
        }
 }
-/// 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 }
-}
 impl Clone for RouteHint {
        fn clone(&self) -> Self {
                Self {
@@ -377,6 +438,25 @@ pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c
 pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint {
        orig.clone()
 }
+/// Checks if two RouteHints contain equal inner contents.
+#[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 std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::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::routing::router::RouteHintHop as nativeRouteHintHopImport;
 type nativeRouteHintHop = nativeRouteHintHopImport;
@@ -476,7 +556,7 @@ pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop
 #[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()) } };
+       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.
@@ -489,7 +569,7 @@ pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop
 #[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()) } };
+       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.
@@ -513,15 +593,6 @@ pub extern "C" fn RouteHintHop_new(mut src_node_id_arg: crate::c_types::PublicKe
                htlc_maximum_msat: local_htlc_maximum_msat_arg,
        }), is_owned: true }
 }
-/// 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 }
-}
 impl Clone for RouteHintHop {
        fn clone(&self) -> Self {
                Self {
@@ -541,6 +612,25 @@ pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mu
 pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop {
        orig.clone()
 }
+/// Checks if two RouteHintHops contain equal inner contents.
+#[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 std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::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 }
+}
 /// Gets a keysend route from us (payer) to the given target node (payee). This is needed because
 /// keysend payments do not have an invoice from which to pull the payee's supported features, which
 /// makes it tricky to otherwise supply the `payee_features` parameter of `get_route`.
index 5e042c83ed74d0c740fdbfb09d747de24fffa553..0bec9636f839bb152c6bb34dc28abaf03c2f989e 100644 (file)
@@ -11,6 +11,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 4764a70c106b9d34f43e2e2e0a8502dc347fcbbc..229fe039961b5aef8a8a47ddc03ce0b6e5c43d5a 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 611670ffe91ce82e4b8ed4bd3a78139930c41ca5..55541a5cd7388e2988998c5b3e4a36362d8de2ee 100644 (file)
@@ -15,6 +15,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -165,6 +166,183 @@ pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_type
 pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose {
        PaymentPurpose::SpontaneousPayment(a, )
 }
+/// The reason the channel was closed. See individual variants more details.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum ClosureReason {
+       /// Closure generated from receiving a peer error message.
+       ///
+       /// Our counterparty may have broadcasted their latest commitment state, and we have
+       /// as well.
+       CounterpartyForceClosed {
+               /// The error which the peer sent us.
+               ///
+               /// 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 exploit
+               /// a security vulnerability in the terminal emulator or the logging subsystem.
+               peer_msg: crate::c_types::Str,
+       },
+       /// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
+       ///
+       /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel.
+       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.
+       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`.
+       CommitmentTxConfirmed,
+       /// Closure generated from processing an event, likely a HTLC forward/relay/reception.
+       ProcessingError {
+               /// A developer-readable error message which we generated.
+               err: crate::c_types::Str,
+       },
+       /// The `PeerManager` informed us that we've disconnected from the peer. We close channels
+       /// if the `PeerManager` informed us that it is unlikely we'll be able to connect to the
+       /// peer again in the future or if the peer disconnected before we finished negotiating
+       /// the channel open. The first case may be caused by incompatible features which our
+       /// counterparty, or we, require.
+       DisconnectedPeer,
+       /// Closure generated from `ChannelManager::read` if the ChannelMonitor is newer than
+       /// the ChannelManager deserialized.
+       OutdatedChannelManager,
+}
+use lightning::util::events::ClosureReason as nativeClosureReason;
+impl ClosureReason {
+       #[allow(unused)]
+       pub(crate) fn to_native(&self) -> nativeClosureReason {
+               match self {
+                       ClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
+                               let mut peer_msg_nonref = (*peer_msg).clone();
+                               nativeClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg_nonref.into_string(),
+                               }
+                       },
+                       ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
+                       ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
+                       ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
+                       ClosureReason::ProcessingError {ref err, } => {
+                               let mut err_nonref = (*err).clone();
+                               nativeClosureReason::ProcessingError {
+                                       err: err_nonref.into_string(),
+                               }
+                       },
+                       ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
+                       ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn into_native(self) -> nativeClosureReason {
+               match self {
+                       ClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
+                               nativeClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg.into_string(),
+                               }
+                       },
+                       ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed,
+                       ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure,
+                       ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed,
+                       ClosureReason::ProcessingError {mut err, } => {
+                               nativeClosureReason::ProcessingError {
+                                       err: err.into_string(),
+                               }
+                       },
+                       ClosureReason::DisconnectedPeer => nativeClosureReason::DisconnectedPeer,
+                       ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn from_native(native: &nativeClosureReason) -> Self {
+               match native {
+                       nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => {
+                               let mut peer_msg_nonref = (*peer_msg).clone();
+                               ClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg_nonref.into(),
+                               }
+                       },
+                       nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
+                       nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
+                       nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
+                       nativeClosureReason::ProcessingError {ref err, } => {
+                               let mut err_nonref = (*err).clone();
+                               ClosureReason::ProcessingError {
+                                       err: err_nonref.into(),
+                               }
+                       },
+                       nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
+                       nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn native_into(native: nativeClosureReason) -> Self {
+               match native {
+                       nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => {
+                               ClosureReason::CounterpartyForceClosed {
+                                       peer_msg: peer_msg.into(),
+                               }
+                       },
+                       nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed,
+                       nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure,
+                       nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed,
+                       nativeClosureReason::ProcessingError {mut err, } => {
+                               ClosureReason::ProcessingError {
+                                       err: err.into(),
+                               }
+                       },
+                       nativeClosureReason::DisconnectedPeer => ClosureReason::DisconnectedPeer,
+                       nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager,
+               }
+       }
+}
+/// Frees any resources used by the ClosureReason
+#[no_mangle]
+pub extern "C" fn ClosureReason_free(this_ptr: ClosureReason) { }
+/// Creates a copy of the ClosureReason
+#[no_mangle]
+pub extern "C" fn ClosureReason_clone(orig: &ClosureReason) -> ClosureReason {
+       orig.clone()
+}
+#[no_mangle]
+/// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
+pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::c_types::Str) -> 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}
+#[no_mangle]
+/// Utility method to constructs a new CooperativeClosure-variant ClosureReason
+pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason {
+       ClosureReason::CooperativeClosure}
+#[no_mangle]
+/// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
+pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason {
+       ClosureReason::CommitmentTxConfirmed}
+#[no_mangle]
+/// Utility method to constructs a new ProcessingError-variant ClosureReason
+pub extern "C" fn ClosureReason_processing_error(err: crate::c_types::Str) -> ClosureReason {
+       ClosureReason::ProcessingError {
+               err,
+       }
+}
+#[no_mangle]
+/// Utility method to constructs a new DisconnectedPeer-variant ClosureReason
+pub extern "C" fn ClosureReason_disconnected_peer() -> ClosureReason {
+       ClosureReason::DisconnectedPeer}
+#[no_mangle]
+/// Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
+pub extern "C" fn ClosureReason_outdated_channel_manager() -> ClosureReason {
+       ClosureReason::OutdatedChannelManager}
+#[no_mangle]
+/// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
+pub extern "C" fn ClosureReason_write(obj: &ClosureReason) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
+}
 /// An Event which you should probably take some action in response to.
 ///
 /// Note that while Writeable and Readable are implemented for Event, you probably shouldn't use
@@ -211,8 +389,11 @@ pub enum Event {
                /// payment is to pay an invoice or to send a spontaneous payment.
                purpose: crate::lightning::util::events::PaymentPurpose,
        },
-       /// Indicates an outbound payment we made succeeded (ie it made it all the way to its target
+       /// 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.
        PaymentSent {
                /// The preimage to the hash given to ChannelManager::send_payment.
                /// Note that this serves as a payment receipt, if you wish to have such a thing, you must
@@ -221,13 +402,28 @@ pub enum Event {
        },
        /// Indicates an outbound payment we made failed. Probably some intermediary node dropped
        /// something. You may wish to retry with a different route.
-       PaymentFailed {
+       PaymentPathFailed {
                /// The hash which was given to ChannelManager::send_payment.
                payment_hash: crate::c_types::ThirtyTwoBytes,
                /// Indicates the payment was rejected for some reason by the recipient. This implies that
                /// the payment has failed, not just the route in question. If this is not set, you may
                /// retry the payment via a different route.
                rejected_by_dest: bool,
+               /// Any failure information conveyed via the Onion return packet by a node along the failed
+               /// payment route.
+               ///
+               /// Should be applied to the [`NetworkGraph`] so that routing decisions can take into
+               /// account the update. [`NetGraphMsgHandler`] is capable of doing this.
+               ///
+               /// [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
+               /// [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler
+               network_update: crate::c_types::derived::COption_NetworkUpdateZ,
+               /// For both single-path and multi-path payments, this is set if all paths of the payment have
+               /// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the
+               /// larger MPP payment were still in flight when this event was generated.
+               all_paths_failed: bool,
+               /// The payment path that failed.
+               path: crate::c_types::derived::CVec_RouteHopZ,
        },
        /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
        /// time in the future.
@@ -268,6 +464,14 @@ pub enum Event {
                /// transaction.
                claim_from_onchain_tx: bool,
        },
+       /// Used to indicate that a channel with the given `channel_id` is in the process of closure.
+       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,
+               /// The reason the channel was closed.
+               reason: crate::lightning::util::events::ClosureReason,
+       },
 }
 use lightning::util::events::Event as nativeEvent;
 impl Event {
@@ -302,12 +506,20 @@ impl Event {
                                        payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data),
                                }
                        },
-                       Event::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
+                       Event::PaymentPathFailed {ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, } => {
                                let mut payment_hash_nonref = (*payment_hash).clone();
                                let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
-                               nativeEvent::PaymentFailed {
+                               let mut network_update_nonref = (*network_update).clone();
+                               let mut local_network_update_nonref = { /* network_update_nonref*/ let network_update_nonref_opt = network_update_nonref; { } if network_update_nonref_opt.is_none() { None } else { Some({ network_update_nonref_opt.take().into_native() }) } };
+                               let mut all_paths_failed_nonref = (*all_paths_failed).clone();
+                               let mut path_nonref = (*path).clone();
+                               let mut local_path_nonref = Vec::new(); for mut item in path_nonref.into_rust().drain(..) { local_path_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+                               nativeEvent::PaymentPathFailed {
                                        payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data),
                                        rejected_by_dest: rejected_by_dest_nonref,
+                                       network_update: local_network_update_nonref,
+                                       all_paths_failed: all_paths_failed_nonref,
+                                       path: local_path_nonref,
                                }
                        },
                        Event::PendingHTLCsForwardable {ref time_forwardable, } => {
@@ -332,6 +544,14 @@ impl Event {
                                        claim_from_onchain_tx: claim_from_onchain_tx_nonref,
                                }
                        },
+                       Event::ChannelClosed {ref channel_id, ref reason, } => {
+                               let mut channel_id_nonref = (*channel_id).clone();
+                               let mut reason_nonref = (*reason).clone();
+                               nativeEvent::ChannelClosed {
+                                       channel_id: channel_id_nonref.data,
+                                       reason: reason_nonref.into_native(),
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -357,10 +577,15 @@ impl Event {
                                        payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data),
                                }
                        },
-                       Event::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
-                               nativeEvent::PaymentFailed {
+                       Event::PaymentPathFailed {mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, } => {
+                               let mut local_network_update = { /* network_update*/ let network_update_opt = network_update; { } if network_update_opt.is_none() { None } else { Some({ network_update_opt.take().into_native() }) } };
+                               let mut local_path = Vec::new(); for mut item in path.into_rust().drain(..) { local_path.push( { *unsafe { Box::from_raw(item.take_inner()) } }); };
+                               nativeEvent::PaymentPathFailed {
                                        payment_hash: ::lightning::ln::PaymentHash(payment_hash.data),
                                        rejected_by_dest: rejected_by_dest,
+                                       network_update: local_network_update,
+                                       all_paths_failed: all_paths_failed,
+                                       path: local_path,
                                }
                        },
                        Event::PendingHTLCsForwardable {mut time_forwardable, } => {
@@ -381,6 +606,12 @@ impl Event {
                                        claim_from_onchain_tx: claim_from_onchain_tx,
                                }
                        },
+                       Event::ChannelClosed {mut channel_id, mut reason, } => {
+                               nativeEvent::ChannelClosed {
+                                       channel_id: channel_id.data,
+                                       reason: reason.into_native(),
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -414,12 +645,20 @@ impl Event {
                                        payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 },
                                }
                        },
-                       nativeEvent::PaymentFailed {ref payment_hash, ref rejected_by_dest, } => {
+                       nativeEvent::PaymentPathFailed {ref payment_hash, ref rejected_by_dest, ref network_update, ref all_paths_failed, ref path, } => {
                                let mut payment_hash_nonref = (*payment_hash).clone();
                                let mut rejected_by_dest_nonref = (*rejected_by_dest).clone();
-                               Event::PaymentFailed {
+                               let mut network_update_nonref = (*network_update).clone();
+                               let mut local_network_update_nonref = if network_update_nonref.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::network_graph::NetworkUpdate::native_into(network_update_nonref.unwrap()) }) };
+                               let mut all_paths_failed_nonref = (*all_paths_failed).clone();
+                               let mut path_nonref = (*path).clone();
+                               let mut local_path_nonref = Vec::new(); for mut item in path_nonref.drain(..) { local_path_nonref.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+                               Event::PaymentPathFailed {
                                        payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
                                        rejected_by_dest: rejected_by_dest_nonref,
+                                       network_update: local_network_update_nonref,
+                                       all_paths_failed: all_paths_failed_nonref,
+                                       path: local_path_nonref.into(),
                                }
                        },
                        nativeEvent::PendingHTLCsForwardable {ref time_forwardable, } => {
@@ -437,13 +676,21 @@ impl Event {
                        },
                        nativeEvent::PaymentForwarded {ref fee_earned_msat, ref claim_from_onchain_tx, } => {
                                let mut fee_earned_msat_nonref = (*fee_earned_msat).clone();
-                               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_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 claim_from_onchain_tx_nonref = (*claim_from_onchain_tx).clone();
                                Event::PaymentForwarded {
                                        fee_earned_msat: local_fee_earned_msat_nonref,
                                        claim_from_onchain_tx: claim_from_onchain_tx_nonref,
                                }
                        },
+                       nativeEvent::ChannelClosed {ref channel_id, ref reason, } => {
+                               let mut channel_id_nonref = (*channel_id).clone();
+                               let mut reason_nonref = (*reason).clone();
+                               Event::ChannelClosed {
+                                       channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref },
+                                       reason: crate::lightning::util::events::ClosureReason::native_into(reason_nonref),
+                               }
+                       },
                }
        }
        #[allow(unused)]
@@ -469,10 +716,15 @@ impl Event {
                                        payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 },
                                }
                        },
-                       nativeEvent::PaymentFailed {mut payment_hash, mut rejected_by_dest, } => {
-                               Event::PaymentFailed {
+                       nativeEvent::PaymentPathFailed {mut payment_hash, mut rejected_by_dest, mut network_update, mut all_paths_failed, mut path, } => {
+                               let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::network_graph::NetworkUpdate::native_into(network_update.unwrap()) }) };
+                               let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
+                               Event::PaymentPathFailed {
                                        payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
                                        rejected_by_dest: rejected_by_dest,
+                                       network_update: local_network_update,
+                                       all_paths_failed: all_paths_failed,
+                                       path: local_path.into(),
                                }
                        },
                        nativeEvent::PendingHTLCsForwardable {mut time_forwardable, } => {
@@ -487,12 +739,18 @@ impl Event {
                                }
                        },
                        nativeEvent::PaymentForwarded {mut fee_earned_msat, mut claim_from_onchain_tx, } => {
-                               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()) } };
+                               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() }) };
                                Event::PaymentForwarded {
                                        fee_earned_msat: local_fee_earned_msat,
                                        claim_from_onchain_tx: claim_from_onchain_tx,
                                }
                        },
+                       nativeEvent::ChannelClosed {mut channel_id, mut reason, } => {
+                               Event::ChannelClosed {
+                                       channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id },
+                                       reason: crate::lightning::util::events::ClosureReason::native_into(reason),
+                               }
+                       },
                }
        }
 }
@@ -531,11 +789,14 @@ pub extern "C" fn Event_payment_sent(payment_preimage: crate::c_types::ThirtyTwo
        }
 }
 #[no_mangle]
-/// Utility method to constructs a new PaymentFailed-variant Event
-pub extern "C" fn Event_payment_failed(payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool) -> Event {
-       Event::PaymentFailed {
+/// Utility method to constructs a new PaymentPathFailed-variant Event
+pub extern "C" fn Event_payment_path_failed(payment_hash: crate::c_types::ThirtyTwoBytes, rejected_by_dest: bool, network_update: crate::c_types::derived::COption_NetworkUpdateZ, all_paths_failed: bool, path: crate::c_types::derived::CVec_RouteHopZ) -> Event {
+       Event::PaymentPathFailed {
                payment_hash,
                rejected_by_dest,
+               network_update,
+               all_paths_failed,
+               path,
        }
 }
 #[no_mangle]
@@ -561,6 +822,14 @@ pub extern "C" fn Event_payment_forwarded(fee_earned_msat: crate::c_types::deriv
        }
 }
 #[no_mangle]
+/// Utility method to constructs a new ChannelClosed-variant Event
+pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, reason: crate::lightning::util::events::ClosureReason) -> Event {
+       Event::ChannelClosed {
+               channel_id,
+               reason,
+       }
+}
+#[no_mangle]
 /// Serialize the Event object into a byte array which can be read by Event_read
 pub extern "C" fn Event_write(obj: &Event) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(&unsafe { &*obj }.to_native())
@@ -692,12 +961,6 @@ pub enum MessageSendEvent {
                /// The action which should be taken.
                action: crate::lightning::ln::msgs::ErrorAction,
        },
-       /// When a payment fails we may receive updates back from the hop where it failed. In such
-       /// cases this event is generated so that we can inform the network graph of this information.
-       PaymentFailureNetworkUpdate {
-               /// The channel/node update which should be sent to NetGraphMsgHandler
-               update: crate::lightning::ln::msgs::HTLCFailChannelUpdate,
-       },
        /// Query a peer for channels with funding transaction UTXOs in a block range.
        SendChannelRangeQuery {
                /// The node_id of this message recipient
@@ -851,12 +1114,6 @@ impl MessageSendEvent {
                                        action: action_nonref.into_native(),
                                }
                        },
-                       MessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
-                               let mut update_nonref = (*update).clone();
-                               nativeMessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: update_nonref.into_native(),
-                               }
-                       },
                        MessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
                                let mut node_id_nonref = (*node_id).clone();
                                let mut msg_nonref = (*msg).clone();
@@ -980,11 +1237,6 @@ impl MessageSendEvent {
                                        action: action.into_native(),
                                }
                        },
-                       MessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
-                               nativeMessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: update.into_native(),
-                               }
-                       },
                        MessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
                                nativeMessageSendEvent::SendChannelRangeQuery {
                                        node_id: node_id.into_rust(),
@@ -1132,12 +1384,6 @@ impl MessageSendEvent {
                                        action: crate::lightning::ln::msgs::ErrorAction::native_into(action_nonref),
                                }
                        },
-                       nativeMessageSendEvent::PaymentFailureNetworkUpdate {ref update, } => {
-                               let mut update_nonref = (*update).clone();
-                               MessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update_nonref),
-                               }
-                       },
                        nativeMessageSendEvent::SendChannelRangeQuery {ref node_id, ref msg, } => {
                                let mut node_id_nonref = (*node_id).clone();
                                let mut msg_nonref = (*msg).clone();
@@ -1261,11 +1507,6 @@ impl MessageSendEvent {
                                        action: crate::lightning::ln::msgs::ErrorAction::native_into(action),
                                }
                        },
-                       nativeMessageSendEvent::PaymentFailureNetworkUpdate {mut update, } => {
-                               MessageSendEvent::PaymentFailureNetworkUpdate {
-                                       update: crate::lightning::ln::msgs::HTLCFailChannelUpdate::native_into(update),
-                               }
-                       },
                        nativeMessageSendEvent::SendChannelRangeQuery {mut node_id, mut msg, } => {
                                MessageSendEvent::SendChannelRangeQuery {
                                        node_id: crate::c_types::PublicKey::from_rust(&node_id),
@@ -1422,13 +1663,6 @@ pub extern "C" fn MessageSendEvent_handle_error(node_id: crate::c_types::PublicK
        }
 }
 #[no_mangle]
-/// Utility method to constructs a new PaymentFailureNetworkUpdate-variant MessageSendEvent
-pub extern "C" fn MessageSendEvent_payment_failure_network_update(update: crate::lightning::ln::msgs::HTLCFailChannelUpdate) -> MessageSendEvent {
-       MessageSendEvent::PaymentFailureNetworkUpdate {
-               update,
-       }
-}
-#[no_mangle]
 /// Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent
 pub extern "C" fn MessageSendEvent_send_channel_range_query(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::QueryChannelRange) -> MessageSendEvent {
        MessageSendEvent::SendChannelRangeQuery {
@@ -1574,7 +1808,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::util::events::Event),
+       pub handle_event: extern "C" fn (this_arg: *const c_void, event: &crate::lightning::util::events::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.
        pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
@@ -1592,8 +1826,8 @@ pub(crate) extern "C" fn EventHandler_clone_fields(orig: &EventHandler) -> Event
 
 use lightning::util::events::EventHandler as rustEventHandler;
 impl rustEventHandler for EventHandler {
-       fn handle_event(&self, mut event: lightning::util::events::Event) {
-               (self.handle_event)(self.this_arg, crate::lightning::util::events::Event::native_into(event))
+       fn handle_event(&self, mut event: &lightning::util::events::Event) {
+               (self.handle_event)(self.this_arg, &crate::lightning::util::events::Event::from_native(event))
        }
 }
 
index cec6bb5c2035480a69f7994dd2bbab496e1e5e86..7aa67a2e41f3e13c4a91cfd7cdce51eeba1e3201 100644 (file)
@@ -15,6 +15,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index b583dd42cdceda68f2eb13ebafb0884b46e9754b..782d81326c288ddd455149844cb7f98893442a94 100644 (file)
@@ -24,6 +24,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 8a9e9dfe2bce9803b7fe85e23f263db9c01d31cb..195c8a5aa57ff1759186e884dc2a05871f554438 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -23,6 +24,7 @@ mod fuzz_wrappers {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -31,6 +33,7 @@ mod ser_macros {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -39,6 +42,7 @@ mod byte_utils {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -47,6 +51,7 @@ mod chacha20 {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -54,6 +59,7 @@ mod real_chacha {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -63,6 +69,7 @@ mod zbase32 {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -71,6 +78,7 @@ mod poly1305 {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -79,6 +87,7 @@ mod chacha20poly1305rfc {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -86,6 +95,7 @@ mod real_chachapoly {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -95,6 +105,7 @@ mod transaction_utils {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -103,6 +114,7 @@ mod scid_utils {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -111,6 +123,7 @@ mod macro_logger {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 7fde9a6489618acb690785b80739df3584a1cdd4..6e9a501723ffe31e7ae99d006b3305e87525a09d 100644 (file)
@@ -11,6 +11,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 5279e3aa3dbac22411b363a46b322fbc33f13678..c3c7ee3545abdca12332587d427771ecf1e346e8 100644 (file)
@@ -12,6 +12,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -19,20 +20,28 @@ use crate::c_types::*;
 use lightning_background_processor::BackgroundProcessor as nativeBackgroundProcessorImport;
 type nativeBackgroundProcessor = nativeBackgroundProcessorImport;
 
-/// BackgroundProcessor takes care of tasks that (1) need to happen periodically to keep
+/// `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep
 /// Rust-Lightning running properly, and (2) either can or should be run in the background. Its
 /// responsibilities are:
-/// * Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so,
+/// * Processing [`Event`]s with a user-provided [`EventHandler`].
+/// * Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so,
 ///   writing it to disk/backups by invoking the callback given to it at startup.
-///   ChannelManager persistence should be done in the background.
-/// * Calling `ChannelManager::timer_tick_occurred()` and
-///   `PeerManager::timer_tick_occurred()` every minute (can be done in the
-///   background).
-///
-/// Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date,
-/// then there is a risk of channels force-closing on startup when the manager realizes it's
-/// outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used
-/// for unilateral chain closure fees are at risk.
+///   [`ChannelManager`] persistence should be done in the background.
+/// * Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
+///   at the appropriate intervals.
+///
+/// It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied
+/// upon as doing so may result in high latency.
+///
+/// # Note
+///
+/// If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then
+/// there is a risk of channels force-closing on startup when the manager realizes it's outdated.
+/// However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for
+/// unilateral chain closure fees are at risk.
+///
+/// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor
+/// [`Event`]: lightning::util::events::Event
 ///BackgroundProcessor will immediately stop on drop. It should be stored until shutdown.
 #[must_use]
 #[repr(C)]
@@ -143,25 +152,38 @@ impl Drop for ChannelManagerPersister {
 /// `persist_manager` returns an error. In case of an error, the error is retrieved by calling
 /// either [`join`] or [`stop`].
 ///
-/// Typically, users should either implement [`ChannelManagerPersister`] to never return an
-/// error or call [`join`] and handle any error that may arise. For the latter case, the
-/// `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
+/// # Data Persistence
 ///
 /// `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
 /// uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
 /// [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
 /// provided implementation.
 ///
+/// Typically, users should either implement [`ChannelManagerPersister`] to never return an
+/// error or call [`join`] and handle any error that may arise. For the latter case,
+/// `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
+///
+/// # Event Handling
+///
+/// `event_handler` is responsible for handling events that users should be notified of (e.g.,
+/// payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common
+/// functionality implemented by other handlers.
+/// * [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures.
+///
 /// [top-level documentation]: Self
 /// [`join`]: Self::join
 /// [`stop`]: Self::stop
 /// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
 /// [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
 /// [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager
+/// [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph
+///
+/// Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None
 #[must_use]
 #[no_mangle]
-pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning_background_processor::ChannelManagerPersister, mut event_handler: crate::lightning::util::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger) -> BackgroundProcessor {
-       let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.get_native_ref(), peer_manager.get_native_ref(), logger);
+pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning_background_processor::ChannelManagerPersister, mut event_handler: crate::lightning::util::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, mut net_graph_msg_handler: crate::lightning::routing::network_graph::NetGraphMsgHandler, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger) -> BackgroundProcessor {
+       let mut local_net_graph_msg_handler = if net_graph_msg_handler.inner.is_null() { None } else { Some( { net_graph_msg_handler.get_native_ref() }) };
+       let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.get_native_ref(), local_net_graph_msg_handler, peer_manager.get_native_ref(), logger);
        BackgroundProcessor { inner: ObjOps::heap_alloc(ret), is_owned: true }
 }
 
index a82129125c1e8e8fdc43ca78fceda8d5a8011cb8..3f1459420fd81ecee3de5c36a419541b06525bcc 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index 80b6d5d5ba4b56848a66cb3441ca137a263e2774..e2937ab68a257a2cce808404a3e729a372f4254f 100644 (file)
@@ -17,6 +17,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -26,6 +27,7 @@ mod de {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -33,6 +35,7 @@ mod hrp_sm {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -78,6 +81,7 @@ mod ser {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -106,6 +110,7 @@ mod tb {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -753,6 +758,15 @@ pub extern "C" fn Currency_simnet() -> Currency {
 pub extern "C" fn Currency_signet() -> Currency {
        Currency::Signet}
 /// Checks if two Currencys contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Currency_hash(o: &Currency) -> u64 {
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(&o.to_native(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two Currencys contain equal inner contents.
 /// This ignores pointers and is_owned flags and looks at the values in fields.
 #[no_mangle]
 pub extern "C" fn Currency_eq(a: &Currency, b: &Currency) -> bool {
@@ -809,15 +823,6 @@ impl Sha256 {
                ret
        }
 }
-/// Checks if two Sha256s contain equal inner contents.
-/// This 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 Sha256_eq(a: &Sha256, b: &Sha256) -> 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 Sha256 {
        fn clone(&self) -> Self {
                Self {
@@ -837,6 +842,25 @@ pub(crate) extern "C" fn Sha256_clone_void(this_ptr: *const c_void) -> *mut c_vo
 pub extern "C" fn Sha256_clone(orig: &Sha256) -> Sha256 {
        orig.clone()
 }
+/// Checks if two Sha256s contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Sha256_hash(o: &Sha256) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two Sha256s contain equal inner contents.
+/// This 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 Sha256_eq(a: &Sha256, b: &Sha256) -> 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_invoice::Description as nativeDescriptionImport;
 type nativeDescription = nativeDescriptionImport;
@@ -891,15 +915,6 @@ impl Description {
                ret
        }
 }
-/// Checks if two Descriptions contain equal inner contents.
-/// This 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 Description_eq(a: &Description, b: &Description) -> 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 Description {
        fn clone(&self) -> Self {
                Self {
@@ -919,6 +934,25 @@ pub(crate) extern "C" fn Description_clone_void(this_ptr: *const c_void) -> *mut
 pub extern "C" fn Description_clone(orig: &Description) -> Description {
        orig.clone()
 }
+/// Checks if two Descriptions contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Description_hash(o: &Description) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two Descriptions contain equal inner contents.
+/// This 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 Description_eq(a: &Description, b: &Description) -> 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_invoice::PayeePubKey as nativePayeePubKeyImport;
 type nativePayeePubKey = nativePayeePubKeyImport;
@@ -970,15 +1004,6 @@ impl PayeePubKey {
                ret
        }
 }
-/// Checks if two PayeePubKeys contain equal inner contents.
-/// This 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 PayeePubKey_eq(a: &PayeePubKey, b: &PayeePubKey) -> 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 PayeePubKey {
        fn clone(&self) -> Self {
                Self {
@@ -998,6 +1023,25 @@ pub(crate) extern "C" fn PayeePubKey_clone_void(this_ptr: *const c_void) -> *mut
 pub extern "C" fn PayeePubKey_clone(orig: &PayeePubKey) -> PayeePubKey {
        orig.clone()
 }
+/// Checks if two PayeePubKeys contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn PayeePubKey_hash(o: &PayeePubKey) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two PayeePubKeys contain equal inner contents.
+/// This 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 PayeePubKey_eq(a: &PayeePubKey, b: &PayeePubKey) -> 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_invoice::ExpiryTime as nativeExpiryTimeImport;
 type nativeExpiryTime = nativeExpiryTimeImport;
@@ -1055,15 +1099,6 @@ impl ExpiryTime {
                ret
        }
 }
-/// Checks if two ExpiryTimes contain equal inner contents.
-/// This 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 ExpiryTime_eq(a: &ExpiryTime, b: &ExpiryTime) -> 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 ExpiryTime {
        fn clone(&self) -> Self {
                Self {
@@ -1083,6 +1118,25 @@ pub(crate) extern "C" fn ExpiryTime_clone_void(this_ptr: *const c_void) -> *mut
 pub extern "C" fn ExpiryTime_clone(orig: &ExpiryTime) -> ExpiryTime {
        orig.clone()
 }
+/// Checks if two ExpiryTimes contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn ExpiryTime_hash(o: &ExpiryTime) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two ExpiryTimes contain equal inner contents.
+/// This 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 ExpiryTime_eq(a: &ExpiryTime, b: &ExpiryTime) -> 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_invoice::MinFinalCltvExpiry as nativeMinFinalCltvExpiryImport;
 type nativeMinFinalCltvExpiry = nativeMinFinalCltvExpiryImport;
@@ -1134,15 +1188,6 @@ impl MinFinalCltvExpiry {
                ret
        }
 }
-/// Checks if two MinFinalCltvExpirys contain equal inner contents.
-/// This 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 MinFinalCltvExpiry_eq(a: &MinFinalCltvExpiry, b: &MinFinalCltvExpiry) -> 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 MinFinalCltvExpiry {
        fn clone(&self) -> Self {
                Self {
@@ -1162,6 +1207,25 @@ pub(crate) extern "C" fn MinFinalCltvExpiry_clone_void(this_ptr: *const c_void)
 pub extern "C" fn MinFinalCltvExpiry_clone(orig: &MinFinalCltvExpiry) -> MinFinalCltvExpiry {
        orig.clone()
 }
+/// Checks if two MinFinalCltvExpirys contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn MinFinalCltvExpiry_hash(o: &MinFinalCltvExpiry) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two MinFinalCltvExpirys contain equal inner contents.
+/// This 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 MinFinalCltvExpiry_eq(a: &MinFinalCltvExpiry, b: &MinFinalCltvExpiry) -> 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 }
+}
 /// Fallback address in case no LN payment is possible
 #[must_use]
 #[derive(Clone)]
@@ -1300,6 +1364,15 @@ pub extern "C" fn Fallback_script_hash(a: crate::c_types::TwentyBytes) -> Fallba
        Fallback::ScriptHash(a, )
 }
 /// Checks if two Fallbacks contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn Fallback_hash(o: &Fallback) -> u64 {
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(&o.to_native(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two Fallbacks contain equal inner contents.
 /// This ignores pointers and is_owned flags and looks at the values in fields.
 #[no_mangle]
 pub extern "C" fn Fallback_eq(a: &Fallback, b: &Fallback) -> bool {
@@ -1356,15 +1429,6 @@ impl InvoiceSignature {
                ret
        }
 }
-/// Checks if two InvoiceSignatures contain equal inner contents.
-/// This 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 InvoiceSignature_eq(a: &InvoiceSignature, b: &InvoiceSignature) -> 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 InvoiceSignature {
        fn clone(&self) -> Self {
                Self {
@@ -1384,6 +1448,15 @@ pub(crate) extern "C" fn InvoiceSignature_clone_void(this_ptr: *const c_void) ->
 pub extern "C" fn InvoiceSignature_clone(orig: &InvoiceSignature) -> InvoiceSignature {
        orig.clone()
 }
+/// Checks if two InvoiceSignatures contain equal inner contents.
+/// This 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 InvoiceSignature_eq(a: &InvoiceSignature, b: &InvoiceSignature) -> 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_invoice::PrivateRoute as nativePrivateRouteImport;
 type nativePrivateRoute = nativePrivateRouteImport;
@@ -1439,15 +1512,6 @@ impl PrivateRoute {
                ret
        }
 }
-/// Checks if two PrivateRoutes contain equal inner contents.
-/// This 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 PrivateRoute_eq(a: &PrivateRoute, b: &PrivateRoute) -> 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 PrivateRoute {
        fn clone(&self) -> Self {
                Self {
@@ -1467,6 +1531,25 @@ pub(crate) extern "C" fn PrivateRoute_clone_void(this_ptr: *const c_void) -> *mu
 pub extern "C" fn PrivateRoute_clone(orig: &PrivateRoute) -> PrivateRoute {
        orig.clone()
 }
+/// Checks if two PrivateRoutes contain equal inner contents.
+#[no_mangle]
+pub extern "C" fn PrivateRoute_hash(o: &PrivateRoute) -> u64 {
+       if o.inner.is_null() { return 0; }
+       // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+       #[allow(deprecated)]
+       let mut hasher = core::hash::SipHasher::new();
+       std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+       std::hash::Hasher::finish(&hasher)
+}
+/// Checks if two PrivateRoutes contain equal inner contents.
+/// This 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 PrivateRoute_eq(a: &PrivateRoute, b: &PrivateRoute) -> 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 }
+}
 /// Disassembles the `SignedRawInvoice` into its three parts:
 ///  1. raw invoice
 ///  2. hash of the raw invoice
@@ -1621,7 +1704,7 @@ pub extern "C" fn RawInvoice_private_routes(this_arg: &RawInvoice) -> crate::c_t
 #[no_mangle]
 pub extern "C" fn RawInvoice_amount_pico_btc(this_arg: &RawInvoice) -> crate::c_types::derived::COption_u64Z {
        let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_pico_btc();
-       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()) } };
+       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
 }
 
@@ -1691,10 +1774,17 @@ pub extern "C" fn Invoice_check_signature(this_arg: &Invoice) -> crate::c_types:
 /// ```
 /// use lightning_invoice::*;
 ///
-/// let invoice = \"lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdp\\
-/// \tl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d7\\
-/// \t3gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ec\\
-/// \tky03ylcqca784w\";
+/// let invoice = \"lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\\
+/// h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\\
+/// 5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\\
+/// h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\\
+/// j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\\
+/// ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\\
+/// guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\\
+/// ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\\
+/// p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\\
+/// 8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\\
+/// j5r6drg6k6zcqj0fcwg\";
 ///
 /// let signed = invoice.parse::<SignedRawInvoice>().unwrap();
 ///
@@ -1736,14 +1826,11 @@ pub extern "C" fn Invoice_payee_pub_key(this_arg: &Invoice) -> crate::c_types::P
 }
 
 /// Get the payment secret if one was included in the invoice
-///
-/// 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 Invoice_payment_secret(this_arg: &Invoice) -> crate::c_types::ThirtyTwoBytes {
        let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_secret();
-       let mut local_ret = if ret.is_none() { crate::c_types::ThirtyTwoBytes::null() } else {  { crate::c_types::ThirtyTwoBytes { data: (ret.unwrap()).0 } } };
-       local_ret
+       crate::c_types::ThirtyTwoBytes { data: ret.0 }
 }
 
 /// Get the invoice features if they were included in the invoice
@@ -1813,7 +1900,7 @@ pub extern "C" fn Invoice_currency(this_arg: &Invoice) -> crate::lightning_invoi
 #[no_mangle]
 pub extern "C" fn Invoice_amount_pico_btc(this_arg: &Invoice) -> crate::c_types::derived::COption_u64Z {
        let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_pico_btc();
-       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()) } };
+       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
 }
 
@@ -1991,6 +2078,9 @@ pub enum SemanticError {
        NoDescription,
        /// The invoice contains multiple descriptions and/or description hashes which isn't allowed
        MultipleDescriptions,
+       /// The invoice is missing the mandatory payment secret, which all modern lightning nodes
+       /// should provide.
+       NoPaymentSecret,
        /// The invoice contains multiple payment secrets
        MultiplePaymentSecrets,
        /// The invoice's features are invalid
@@ -1999,6 +2089,8 @@ pub enum SemanticError {
        InvalidRecoveryId,
        /// The invoice's signature is invalid
        InvalidSignature,
+       /// The invoice's amount was not a whole number of millisatoshis
+       ImpreciseAmount,
 }
 use lightning_invoice::SemanticError as nativeSemanticError;
 impl SemanticError {
@@ -2009,10 +2101,12 @@ impl SemanticError {
                        SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
                        SemanticError::NoDescription => nativeSemanticError::NoDescription,
                        SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
+                       SemanticError::NoPaymentSecret => nativeSemanticError::NoPaymentSecret,
                        SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
                        SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
                        SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
                        SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
+                       SemanticError::ImpreciseAmount => nativeSemanticError::ImpreciseAmount,
                }
        }
        #[allow(unused)]
@@ -2022,10 +2116,12 @@ impl SemanticError {
                        SemanticError::MultiplePaymentHashes => nativeSemanticError::MultiplePaymentHashes,
                        SemanticError::NoDescription => nativeSemanticError::NoDescription,
                        SemanticError::MultipleDescriptions => nativeSemanticError::MultipleDescriptions,
+                       SemanticError::NoPaymentSecret => nativeSemanticError::NoPaymentSecret,
                        SemanticError::MultiplePaymentSecrets => nativeSemanticError::MultiplePaymentSecrets,
                        SemanticError::InvalidFeatures => nativeSemanticError::InvalidFeatures,
                        SemanticError::InvalidRecoveryId => nativeSemanticError::InvalidRecoveryId,
                        SemanticError::InvalidSignature => nativeSemanticError::InvalidSignature,
+                       SemanticError::ImpreciseAmount => nativeSemanticError::ImpreciseAmount,
                }
        }
        #[allow(unused)]
@@ -2035,10 +2131,12 @@ impl SemanticError {
                        nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
                        nativeSemanticError::NoDescription => SemanticError::NoDescription,
                        nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
+                       nativeSemanticError::NoPaymentSecret => SemanticError::NoPaymentSecret,
                        nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
                        nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
                        nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
                        nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
+                       nativeSemanticError::ImpreciseAmount => SemanticError::ImpreciseAmount,
                }
        }
        #[allow(unused)]
@@ -2048,10 +2146,12 @@ impl SemanticError {
                        nativeSemanticError::MultiplePaymentHashes => SemanticError::MultiplePaymentHashes,
                        nativeSemanticError::NoDescription => SemanticError::NoDescription,
                        nativeSemanticError::MultipleDescriptions => SemanticError::MultipleDescriptions,
+                       nativeSemanticError::NoPaymentSecret => SemanticError::NoPaymentSecret,
                        nativeSemanticError::MultiplePaymentSecrets => SemanticError::MultiplePaymentSecrets,
                        nativeSemanticError::InvalidFeatures => SemanticError::InvalidFeatures,
                        nativeSemanticError::InvalidRecoveryId => SemanticError::InvalidRecoveryId,
                        nativeSemanticError::InvalidSignature => SemanticError::InvalidSignature,
+                       nativeSemanticError::ImpreciseAmount => SemanticError::ImpreciseAmount,
                }
        }
 }
@@ -2077,6 +2177,10 @@ pub extern "C" fn SemanticError_no_description() -> SemanticError {
 pub extern "C" fn SemanticError_multiple_descriptions() -> SemanticError {
        SemanticError::MultipleDescriptions}
 #[no_mangle]
+/// Utility method to constructs a new NoPaymentSecret-variant SemanticError
+pub extern "C" fn SemanticError_no_payment_secret() -> SemanticError {
+       SemanticError::NoPaymentSecret}
+#[no_mangle]
 /// Utility method to constructs a new MultiplePaymentSecrets-variant SemanticError
 pub extern "C" fn SemanticError_multiple_payment_secrets() -> SemanticError {
        SemanticError::MultiplePaymentSecrets}
@@ -2092,6 +2196,10 @@ pub extern "C" fn SemanticError_invalid_recovery_id() -> SemanticError {
 /// Utility method to constructs a new InvalidSignature-variant SemanticError
 pub extern "C" fn SemanticError_invalid_signature() -> SemanticError {
        SemanticError::InvalidSignature}
+#[no_mangle]
+/// Utility method to constructs a new ImpreciseAmount-variant SemanticError
+pub extern "C" fn SemanticError_imprecise_amount() -> SemanticError {
+       SemanticError::ImpreciseAmount}
 /// Checks if two SemanticErrors contain equal inner contents.
 /// This ignores pointers and is_owned flags and looks at the values in fields.
 #[no_mangle]
index 281da5e14556402af5cccb631983a234c72129d3..74807a517ae91b04c3ce8323586a12edf5ab2a0f 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
index bd87bff761ff79fa915578b96f23e9fd7a60d883..a93e915c80047080572143589b080486ee0113a1 100644 (file)
@@ -10,6 +10,7 @@
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
@@ -17,6 +18,7 @@ mod util {
 
 use std::str::FromStr;
 use std::ffi::c_void;
+use core::convert::Infallible;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;