Merge pull request #721 from TheBlueMatt/2020-09-649-bindings
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Thu, 12 Nov 2020 21:22:54 +0000 (13:22 -0800)
committerGitHub <noreply@github.com>
Thu, 12 Nov 2020 21:22:54 +0000 (13:22 -0800)
Bindings Updates for #649

30 files changed:
.github/workflows/build.yml
c-bindings-gen/src/blocks.rs
c-bindings-gen/src/main.rs
c-bindings-gen/src/types.rs
lightning-c-bindings/README.md
lightning-c-bindings/demo.c
lightning-c-bindings/demo.cpp
lightning-c-bindings/include/lightning.h
lightning-c-bindings/include/lightningpp.hpp
lightning-c-bindings/include/rust_types.h
lightning-c-bindings/src/c_types/derived.rs
lightning-c-bindings/src/c_types/mod.rs
lightning-c-bindings/src/chain/chaininterface.rs
lightning-c-bindings/src/chain/chainmonitor.rs [new file with mode: 0644]
lightning-c-bindings/src/chain/channelmonitor.rs [new file with mode: 0644]
lightning-c-bindings/src/chain/keysinterface.rs
lightning-c-bindings/src/chain/mod.rs
lightning-c-bindings/src/chain/transaction.rs
lightning-c-bindings/src/ln/chan_utils.rs
lightning-c-bindings/src/ln/channelmanager.rs
lightning-c-bindings/src/ln/channelmonitor.rs [deleted file]
lightning-c-bindings/src/ln/features.rs
lightning-c-bindings/src/ln/mod.rs
lightning-c-bindings/src/ln/msgs.rs
lightning-c-bindings/src/ln/peer_handler.rs
lightning-c-bindings/src/routing/network_graph.rs
lightning-c-bindings/src/routing/router.rs
lightning-c-bindings/src/util/config.rs
lightning-c-bindings/src/util/errors.rs
lightning/src/chain/mod.rs

index 065a3241a8e324cd09db7ace5489d03d20ec88d5..bafdd29fffd975a7ae5ab1585e224de279ea2729 100644 (file)
@@ -170,18 +170,10 @@ jobs:
             # cbindgen's bindings output order can be FS-dependant, so check that the lines are all the same:
             mv lightning-c-bindings/include/lightning.h lightning-c-bindings/include/lightning.h.new
             git checkout lightning-c-bindings/include/lightning.h
-            cat lightning-c-bindings/include/lightning.h | sort > lightning-c-bindings/include/lightning.h.sorted
-            cat lightning-c-bindings/include/lightning.h.new | sort > lightning-c-bindings/include/lightning.h.new.sorted
+            cat lightning-c-bindings/include/lightning.h | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.sorted
+            cat lightning-c-bindings/include/lightning.h.new | grep -v "Generated with cbindgen:[0-9\.]*" | sort > lightning-c-bindings/include/lightning.h.new.sorted
             diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted
-            #
-            mv lightning-c-bindings/include/lightningpp.hpp lightning-c-bindings/include/lightningpp.hpp.new
-            git checkout lightning-c-bindings/include/lightningpp.hpp
-            cat lightning-c-bindings/include/lightningpp.hpp | sort > lightning-c-bindings/include/lightningpp.hpp.sorted
-            cat lightning-c-bindings/include/lightningpp.hpp.new | sort > lightning-c-bindings/include/lightningpp.hpp.new.sorted
-            diff lightning-c-bindings/include/lightningpp.hpp.sorted lightning-c-bindings/include/lightningpp.hpp.new.sorted
-            #
             [ "$(diff lightning-c-bindings/include/lightning.h.sorted lightning-c-bindings/include/lightning.h.new.sorted)" != "" ] && exit 2
-            [ "$(diff lightning-c-bindings/include/lightningpp.hpp.sorted lightning-c-bindings/include/lightningpp.hpp.new.sorted)" != "" ] && exit 3
             git diff --exit-code
           fi
 
index 9e255a1521e928a3500b31f13c9283b13be0a5d7..076f9373116985d638bcae7411b637b99be11f1c 100644 (file)
@@ -113,20 +113,15 @@ pub fn write_method_params<W: std::io::Write>(w: &mut W, sig: &syn::Signature, a
                        syn::FnArg::Typed(arg) => {
                                if types.skip_arg(&*arg.ty, generics) { continue; }
                                if !arg.attrs.is_empty() { unimplemented!(); }
-                               let mut is_ref = if let syn::Type::Reference(_) = *arg.ty { true } else { false };
-                               if let syn::Type::Reference(syn::TypeReference { ref elem, .. }) = *arg.ty {
-                                       if let syn::Type::Slice(_) = &**elem {
-                                               // Slices are mapped to non-ref Vec types, so we want them to be mut
-                                               // letting us drain(..) the underlying Vec.
-                                               is_ref = false;
-                                       }
-                               }
+                               // First get the c type so that we can check if it ends up being a reference:
+                               let mut c_type = Vec::new();
+                               types.write_c_type(&mut c_type, &*arg.ty, generics, false);
                                match &*arg.pat {
                                        syn::Pat::Ident(ident) => {
                                                if !ident.attrs.is_empty() || ident.subpat.is_some() {
                                                        unimplemented!();
                                                }
-                                               write!(w, "{}{}{}: ", if first_arg { "" } else { ", " }, if is_ref || !fn_decl { "" } else { "mut " }, ident.ident).unwrap();
+                                               write!(w, "{}{}{}: ", if first_arg { "" } else { ", " }, if !fn_decl || c_type[0] == '&' as u8 || c_type[0] == '*' as u8 { "" } else { "mut " }, ident.ident).unwrap();
                                                first_arg = false;
                                        },
                                        syn::Pat::Wild(wild) => {
@@ -136,7 +131,7 @@ pub fn write_method_params<W: std::io::Write>(w: &mut W, sig: &syn::Signature, a
                                        },
                                        _ => unimplemented!(),
                                }
-                               types.write_c_type(w, &*arg.ty, generics, false);
+                               w.write(&c_type).unwrap();
                        }
                }
        }
index 52ee3b05f16e887a09c272606d95394f7c90a15f..ecbd947baa8fb7dfd72231ee39b73716632842a2 100644 (file)
@@ -56,7 +56,7 @@ fn convert_macro<W: std::io::Write>(w: &mut W, macro_path: &syn::Path, stream: &
 
 /// Convert "impl trait_path for for_obj { .. }" for manually-mapped types (ie (de)serialization)
 fn maybe_convert_trait_impl<W: std::io::Write>(w: &mut W, trait_path: &syn::Path, for_obj: &syn::Ident, types: &TypeResolver) {
-       if let Some(t) = types.maybe_resolve_path(&trait_path) {
+       if let Some(t) = types.maybe_resolve_path(&trait_path, None) {
                let s = types.maybe_resolve_ident(for_obj).unwrap();
                if !types.crate_types.opaques.get(&s).is_some() { return; }
                match &t as &str {
@@ -97,7 +97,7 @@ macro_rules! walk_supertraits { ($t: expr, $types: expr, ($( $pat: pat => $e: ex
                                                        $( $pat => $e, )*
                                                }
                                        } else {
-                                               let path = $types.resolve_path(&supertrait.path);
+                                               let path = $types.resolve_path(&supertrait.path, None);
                                                match (&path as &str, &supertrait.path.segments.iter().last().unwrap().ident) {
                                                        $( $pat => $e, )*
                                                }
@@ -357,7 +357,7 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty
                                let mut bounds_iter = t.bounds.iter();
                                match bounds_iter.next().unwrap() {
                                        syn::TypeParamBound::Trait(tr) => {
-                                               writeln!(w, "\ttype {} = crate::{};", t.ident, types.resolve_path(&tr.path)).unwrap();
+                                               writeln!(w, "\ttype {} = crate::{};", t.ident, types.resolve_path(&tr.path, None)).unwrap();
                                        },
                                        _ => unimplemented!(),
                                }
@@ -397,7 +397,7 @@ fn writeln_opaque<W: std::io::Write>(w: &mut W, ident: &syn::Ident, struct_name:
        writeln!(w, ";\n").unwrap();
        writeln!(extra_headers, "struct native{}Opaque;\ntypedef struct native{}Opaque LDKnative{};", ident, ident, ident).unwrap();
        writeln_docs(w, &attrs, "");
-       writeln!(w, "#[must_use]\n#[repr(C)]\npub struct {} {{\n\t/// Nearly everyhwere, inner must be non-null, however in places where", struct_name).unwrap();
+       writeln!(w, "#[must_use]\n#[repr(C)]\npub struct {} {{\n\t/// Nearly everywhere, inner must be non-null, however in places where", struct_name).unwrap();
        writeln!(w, "\t/// the Rust equivalent takes an Option, it may be set to null to indicate None.").unwrap();
        writeln!(w, "\tpub inner: *mut native{},\n\tpub is_owned: bool,\n}}\n", ident).unwrap();
        writeln!(w, "impl Drop for {} {{\n\tfn drop(&mut self) {{", struct_name).unwrap();
@@ -579,7 +579,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                if let Some(trait_path) = i.trait_.as_ref() {
                                        if trait_path.0.is_some() { unimplemented!(); }
                                        if types.understood_c_path(&trait_path.1) {
-                                               let full_trait_path = types.resolve_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();
                                                // We learn the associated types maping from the original trait object.
                                                // That's great, except that they are unresolved idents, so if we learn
@@ -628,7 +628,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                                if let syn::ReturnType::Type(_, rtype) = &$m.sig.output {
                                                                        if let syn::Type::Reference(r) = &**rtype {
                                                                                write!(w, "\n\t\t{}{}: ", $indent, $m.sig.ident).unwrap();
-                                                                               types.write_empty_rust_val(w, &*r.elem);
+                                                                               types.write_empty_rust_val(Some(&gen_types), w, &*r.elem);
                                                                                writeln!(w, ",\n{}\t\tset_{}: Some({}_{}_set_{}),", $indent, $m.sig.ident, ident, trait_obj.ident, $m.sig.ident).unwrap();
                                                                                printed = true;
                                                                        }
@@ -722,7 +722,7 @@ fn writeln_impl<W: std::io::Write>(w: &mut W, i: &syn::ItemImpl, types: &mut Typ
                                                                                writeln!(w, "\t// This is a bit race-y in the general case, but for our specific use-cases today, we're safe").unwrap();
                                                                                writeln!(w, "\t// Specifically, we must ensure that the first time we're called it can never be in parallel").unwrap();
                                                                                write!(w, "\tif ").unwrap();
-                                                                               types.write_empty_rust_val_check(w, &*r.elem, &format!("trait_self_arg.{}", $m.sig.ident));
+                                                                               types.write_empty_rust_val_check(Some(&gen_types), w, &*r.elem, &format!("trait_self_arg.{}", $m.sig.ident));
                                                                                writeln!(w, " {{").unwrap();
                                                                                writeln!(w, "\t\tunsafe {{ &mut *(trait_self_arg as *const {}  as *mut {}) }}.{} = {}_{}_{}(trait_self_arg.this_arg);", trait_obj.ident, trait_obj.ident, $m.sig.ident, ident, trait_obj.ident, $m.sig.ident).unwrap();
                                                                                writeln!(w, "\t}}").unwrap();
@@ -1057,8 +1057,6 @@ struct FullLibraryAST {
 /// `out_path` and fills it with wrapper structs/functions to allow calling the things in the AST
 /// at `module` from C.
 fn convert_file<'a, 'b>(libast: &'a FullLibraryAST, crate_types: &mut CrateTypes<'a>, in_dir: &str, out_dir: &str, path: &str, orig_crate: &str, module: &str, header_file: &mut File, cpp_header_file: &mut File) {
-       eprintln!("Converting {}...", path);
-
        let syntax = if let Some(ast) = libast.files.get(module) { ast } else { return };
 
        assert!(syntax.shebang.is_none()); // Not sure what this is, hope we dont have one
@@ -1096,6 +1094,8 @@ fn convert_file<'a, 'b>(libast: &'a FullLibraryAST, crate_types: &mut CrateTypes
                        orig_crate, &new_mod, header_file, cpp_header_file);
        }
 
+       eprintln!("Converting {} entries...", path);
+
        let mut type_resolver = TypeResolver::new(orig_crate, module, crate_types);
 
        for item in syntax.items.iter() {
@@ -1125,7 +1125,7 @@ fn convert_file<'a, 'b>(libast: &'a FullLibraryAST, crate_types: &mut CrateTypes
                                // Re-export any primitive-type constants.
                                if let syn::Visibility::Public(_) = c.vis {
                                        if let syn::Type::Path(p) = &*c.ty {
-                                               let resolved_path = type_resolver.resolve_path(&p.path);
+                                               let resolved_path = type_resolver.resolve_path(&p.path, None);
                                                if type_resolver.is_primitive(&resolved_path) {
                                                        writeln!(out, "\n#[no_mangle]").unwrap();
                                                        writeln!(out, "pub static {}: {} = {}::{}::{};", c.ident, resolved_path, orig_crate, module, c.ident).unwrap();
@@ -1139,8 +1139,18 @@ fn convert_file<'a, 'b>(libast: &'a FullLibraryAST, crate_types: &mut CrateTypes
                                                ExportStatus::Export => {},
                                                ExportStatus::NoExport|ExportStatus::TestOnly => continue,
                                        }
-                                       if t.generics.lt_token.is_none() {
-                                               writeln_opaque(&mut out, &t.ident, &format!("{}", t.ident), &t.generics, &t.attrs, &type_resolver, header_file, cpp_header_file);
+
+                                       let mut process_alias = true;
+                                       for tok in t.generics.params.iter() {
+                                               if let syn::GenericParam::Lifetime(_) = tok {}
+                                               else { process_alias = false; }
+                                       }
+                                       if process_alias {
+                                               match &*t.ty {
+                                                       syn::Type::Path(_) =>
+                                                               writeln_opaque(&mut out, &t.ident, &format!("{}", t.ident), &t.generics, &t.attrs, &type_resolver, header_file, cpp_header_file),
+                                                       _ => {}
+                                               }
                                        }
                                }
                        },
@@ -1180,6 +1190,52 @@ fn load_ast(in_dir: &str, path: &str, module: String, ast_storage: &mut FullLibr
        ast_storage.files.insert(module, syntax);
 }
 
+/// Insert ident -> absolute Path resolutions into imports from the given UseTree and path-prefix.
+fn process_use_intern<'a>(u: &'a syn::UseTree, mut path: syn::punctuated::Punctuated<syn::PathSegment, syn::token::Colon2>, imports: &mut HashMap<&'a syn::Ident, syn::Path>) {
+       match u {
+               syn::UseTree::Path(p) => {
+                       path.push(syn::PathSegment { ident: p.ident.clone(), arguments: syn::PathArguments::None });
+                       process_use_intern(&p.tree, path, imports);
+               },
+               syn::UseTree::Name(n) => {
+                       path.push(syn::PathSegment { ident: n.ident.clone(), arguments: syn::PathArguments::None });
+                       imports.insert(&n.ident, syn::Path { leading_colon: Some(syn::Token![::](Span::call_site())), segments: path });
+               },
+               syn::UseTree::Group(g) => {
+                       for i in g.items.iter() {
+                               process_use_intern(i, path.clone(), imports);
+                       }
+               },
+               _ => {}
+       }
+}
+
+/// Map all the Paths in a Type into absolute paths given a set of imports (generated via process_use_intern)
+fn resolve_imported_refs(imports: &HashMap<&syn::Ident, syn::Path>, mut ty: syn::Type) -> syn::Type {
+       match &mut ty {
+               syn::Type::Path(p) => {
+                       if let Some(ident) = p.path.get_ident() {
+                               if let Some(newpath) = imports.get(ident) {
+                                       p.path = newpath.clone();
+                               }
+                       } else { unimplemented!(); }
+               },
+               syn::Type::Reference(r) => {
+                       r.elem = Box::new(resolve_imported_refs(imports, (*r.elem).clone()));
+               },
+               syn::Type::Slice(s) => {
+                       s.elem = Box::new(resolve_imported_refs(imports, (*s.elem).clone()));
+               },
+               syn::Type::Tuple(t) => {
+                       for e in t.elems.iter_mut() {
+                               *e = resolve_imported_refs(imports, e.clone());
+                       }
+               },
+               _ => unimplemented!(),
+       }
+       ty
+}
+
 /// Walk the FullLibraryAST, deciding how things will be mapped and adding tracking to CrateTypes.
 fn walk_ast<'a>(in_dir: &str, path: &str, module: String, ast_storage: &'a FullLibraryAST, crate_types: &mut CrateTypes<'a>) {
        let syntax = if let Some(ast) = ast_storage.files.get(&module) { ast } else { return };
@@ -1189,8 +1245,13 @@ fn walk_ast<'a>(in_dir: &str, path: &str, module: String, ast_storage: &'a FullL
                walk_ast(in_dir, &path, new_mod, ast_storage, crate_types);
        }
 
+       let mut import_maps = HashMap::new();
+
        for item in syntax.items.iter() {
                match item {
+                       syn::Item::Use(u) => {
+                               process_use_intern(&u.tree, syn::punctuated::Punctuated::new(), &mut import_maps);
+                       },
                        syn::Item::Struct(s) => {
                                if let syn::Visibility::Public(_) = s.vis {
                                        match export_status(&s.attrs) {
@@ -1211,6 +1272,31 @@ fn walk_ast<'a>(in_dir: &str, path: &str, module: String, ast_storage: &'a FullL
                                        crate_types.traits.insert(trait_path, &t);
                                }
                        },
+                       syn::Item::Type(t) => {
+                               if let syn::Visibility::Public(_) = t.vis {
+                                       match export_status(&t.attrs) {
+                                               ExportStatus::Export => {},
+                                               ExportStatus::NoExport|ExportStatus::TestOnly => continue,
+                                       }
+                                       let type_path = format!("{}::{}", module, t.ident);
+                                       let mut process_alias = true;
+                                       for tok in t.generics.params.iter() {
+                                               if let syn::GenericParam::Lifetime(_) = tok {}
+                                               else { process_alias = false; }
+                                       }
+                                       if process_alias {
+                                               match &*t.ty {
+                                                       syn::Type::Path(_) => {
+                                                               // If its a path with no generics, assume we don't map the aliased type and map it opaque
+                                                               crate_types.opaques.insert(type_path, &t.ident);
+                                                       },
+                                                       _ => {
+                                                               crate_types.type_aliases.insert(type_path, resolve_imported_refs(&import_maps, (*t.ty).clone()));
+                                                       }
+                                               }
+                                       }
+                               }
+                       },
                        syn::Item::Enum(e) if is_enum_opaque(e) => {
                                if let syn::Visibility::Public(_) = e.vis {
                                        match export_status(&e.attrs) {
@@ -1264,7 +1350,7 @@ fn main() {
        // ...then walk the ASTs tracking what types we will map, and how, so that we can resolve them
        // when parsing other file ASTs...
        let mut libtypes = CrateTypes { traits: HashMap::new(), opaques: HashMap::new(), mirrored_enums: HashMap::new(),
-               templates_defined: HashMap::new(), template_file: &mut derived_templates };
+               type_aliases: HashMap::new(), templates_defined: HashMap::default(), template_file: &mut derived_templates };
        walk_ast(&args[1], "/lib.rs", "".to_string(), &libast, &mut libtypes);
 
        // ... finally, do the actual file conversion/mapping, writing out types as we go.
index 56bb4e67bc9411be155147a5af24ee920ac7545b..3fc35e8b2558f8de6f7da2d4d017664a8b3390d1 100644 (file)
@@ -1,6 +1,7 @@
 use std::collections::HashMap;
 use std::fs::File;
 use std::io::Write;
+use std::hash;
 
 use proc_macro2::{TokenTree, Span};
 
@@ -144,7 +145,7 @@ impl<'a> GenericTypes<'a> {
                                                        }
 
                                                        assert_simple_bound(&trait_bound);
-                                                       if let Some(mut path) = types.maybe_resolve_path(&trait_bound.path) {
+                                                       if let Some(mut path) = types.maybe_resolve_path(&trait_bound.path, None) {
                                                                if types.skip_path(&path) { continue; }
                                                                if non_lifetimes_processed { return false; }
                                                                non_lifetimes_processed = true;
@@ -177,7 +178,7 @@ impl<'a> GenericTypes<'a> {
                                                                        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),
+                                                                       *gen = ("crate::".to_string() + &types.resolve_path(&trait_bound.path, None),
                                                                                Some(&trait_bound.path));
                                                                }
                                                        }
@@ -225,6 +226,13 @@ pub enum DeclType<'a> {
        EnumIgnored,
 }
 
+// templates_defined is walked to write the C++ header, so if we use the default hashing it get
+// reordered on each genbindings run. Instead, we use SipHasher (which defaults to 0-keys) so that
+// the sorting is stable across runs. It is deprecated, but the "replacement" doesn't actually
+// accomplish the same goals, so we just ignore it.
+#[allow(deprecated)]
+type NonRandomHash = hash::BuildHasherDefault<hash::SipHasher>;
+
 /// Top-level struct tracking everything which has been defined while walking the crate.
 pub struct CrateTypes<'a> {
        /// This may contain structs or enums, but only when either is mapped as
@@ -234,11 +242,13 @@ pub struct CrateTypes<'a> {
        pub mirrored_enums: HashMap<String, &'a syn::ItemEnum>,
        /// Traits which are mapped as a pointer + jump table
        pub traits: HashMap<String, &'a syn::ItemTrait>,
+       /// Aliases from paths to some other Type
+       pub type_aliases: HashMap<String, syn::Type>,
        /// Template continer types defined, map from mangled type name -> whether a destructor fn
        /// exists.
        ///
        /// This is used at the end of processing to make C++ wrapper classes
-       pub templates_defined: HashMap<String, bool>,
+       pub templates_defined: HashMap<String, bool, NonRandomHash>,
        /// The output file for any created template container types, written to as we find new
        /// template containers which need to be defined.
        pub template_file: &'a mut File,
@@ -255,6 +265,17 @@ pub struct TypeResolver<'mod_lifetime, 'crate_lft: 'mod_lifetime> {
        pub crate_types: &'mod_lifetime mut CrateTypes<'crate_lft>,
 }
 
+/// Returned by write_empty_rust_val_check_suffix to indicate what type of dereferencing needs to
+/// happen to get the inner value of a generic.
+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 pointer which we want to convert to a reference.
+       ReferenceAsPointer,
+}
+
 impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        pub fn new(orig_crate: &'a str, module_path: &'a str, crate_types: &'a mut CrateTypes<'c>) -> Self {
                let mut imports = HashMap::new();
@@ -340,8 +361,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "bitcoin::blockdata::script::Script" if is_ref => Some("crate::c_types::u8slice"),
                        "bitcoin::blockdata::script::Script" if !is_ref => Some("crate::c_types::derived::CVec_u8Z"),
                        "bitcoin::blockdata::transaction::OutPoint" if is_ref => Some("crate::chain::transaction::OutPoint"),
-                       "bitcoin::blockdata::transaction::Transaction" if is_ref && !ptr_for_ref => Some("crate::c_types::Transaction"),
-                       "bitcoin::blockdata::transaction::Transaction" => Some("crate::c_types::derived::CVec_u8Z"),
+                       "bitcoin::blockdata::transaction::Transaction" => Some("crate::c_types::Transaction"),
                        "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut"),
                        "bitcoin::OutPoint" => Some("crate::chain::transaction::OutPoint"),
                        "bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network"),
@@ -413,7 +433,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "bitcoin::blockdata::script::Script" if is_ref => Some("&::bitcoin::blockdata::script::Script::from(Vec::from("),
                        "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::consensus::encode::deserialize(&"),
+                       "bitcoin::blockdata::transaction::Transaction" => Some(""),
                        "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(""),
                        "bitcoin::network::constants::Network" => Some(""),
                        "bitcoin::blockdata::block::BlockHeader" => Some("&::bitcoin::consensus::encode::deserialize(unsafe { &*"),
@@ -471,8 +491,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "bitcoin::secp256k1::key::SecretKey" if is_ref => Some("}[..]).unwrap()"),
                        "bitcoin::blockdata::script::Script" if is_ref => Some(".to_slice()))"),
                        "bitcoin::blockdata::script::Script" if !is_ref => Some(".into_rust())"),
-                       "bitcoin::blockdata::transaction::Transaction" if is_ref => Some(".into_bitcoin()"),
-                       "bitcoin::blockdata::transaction::Transaction" => Some(".into_rust()[..]).unwrap()"),
+                       "bitcoin::blockdata::transaction::Transaction" => Some(".into_bitcoin()"),
                        "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(".into_rust()"),
                        "bitcoin::network::constants::Network" => Some(".into_bitcoin()"),
                        "bitcoin::blockdata::block::BlockHeader" => Some(" }).unwrap()"),
@@ -553,8 +572,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "bitcoin::secp256k1::Error" if !is_ref => Some("crate::c_types::Secp256k1Error::from_rust("),
                        "bitcoin::blockdata::script::Script" if is_ref => Some("crate::c_types::u8slice::from_slice(&"),
                        "bitcoin::blockdata::script::Script" if !is_ref => Some(""),
-                       "bitcoin::blockdata::transaction::Transaction" if is_ref && !ptr_for_ref => Some("crate::c_types::Transaction::from_slice(&local_"),
-                       "bitcoin::blockdata::transaction::Transaction" => Some("local_"),
+                       "bitcoin::blockdata::transaction::Transaction" => Some("crate::c_types::Transaction::from_vec(local_"),
                        "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust("),
                        "bitcoin::blockdata::block::BlockHeader" if is_ref => Some("&local_"),
                        "bitcoin::blockdata::block::Block" if is_ref => Some("crate::c_types::u8slice::from_slice(&local_"),
@@ -617,8 +635,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        "bitcoin::secp256k1::Error" if !is_ref => Some(")"),
                        "bitcoin::blockdata::script::Script" if is_ref => Some("[..])"),
                        "bitcoin::blockdata::script::Script" if !is_ref => Some(".into_bytes().into()"),
-                       "bitcoin::blockdata::transaction::Transaction" if is_ref && !ptr_for_ref => Some(")"),
-                       "bitcoin::blockdata::transaction::Transaction" => Some(".into()"),
+                       "bitcoin::blockdata::transaction::Transaction" => Some(")"),
                        "bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(")"),
                        "bitcoin::blockdata::block::BlockHeader" if is_ref => Some(""),
                        "bitcoin::blockdata::block::Block" if is_ref => Some(")"),
@@ -653,6 +670,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        fn empty_val_check_suffix_from_path(&self, full_path: &str) -> Option<&str> {
                match full_path {
                        "ln::channelmanager::PaymentSecret" => Some(".data == [0; 32]"),
+                       "bitcoin::secp256k1::key::PublicKey" => Some(".is_null()"),
+                       "bitcoin::secp256k1::Signature" => Some(".is_null()"),
                        _ => None
                }
        }
@@ -681,7 +700,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        fn is_known_container(&self, full_path: &str, is_ref: bool) -> bool {
                (full_path == "Result" && !is_ref) || (full_path == "Vec" && !is_ref) || full_path.ends_with("Tuple")
        }
-       fn to_c_conversion_container_new_var<'b>(&self, full_path: &str, is_ref: bool, single_contained: Option<&syn::Type>, var_name: &syn::Ident, var_access: &str)
+       fn to_c_conversion_container_new_var<'b>(&self, generics: Option<&GenericTypes>, full_path: &str, is_ref: bool, single_contained: Option<&syn::Type>, var_name: &syn::Ident, var_access: &str)
                        // Returns prefix + Vec<(prefix, var-name-to-inline-convert)> + suffix
                        // expecting one element in the vec per generic type, each of which is inline-converted
                        -> Option<(&'b str, Vec<(String, String)>, &'b str)> {
@@ -700,7 +719,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        },
                        "Option" => {
                                if let Some(syn::Type::Path(p)) = single_contained {
-                                       if self.c_type_has_inner_from_path(&self.resolve_path(&p.path)) {
+                                       if self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)) {
                                                if is_ref {
                                                        return Some(("if ", vec![
                                                                (".is_none() { std::ptr::null() } else { ".to_owned(), format!("({}.as_ref().unwrap())", var_access))
@@ -714,7 +733,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                }
                                if let Some(t) = single_contained {
                                        let mut v = Vec::new();
-                                       self.write_empty_rust_val(&mut v, t);
+                                       self.write_empty_rust_val(generics, &mut v, t);
                                        let s = String::from_utf8(v).unwrap();
                                        return Some(("if ", vec![
                                                (format!(".is_none() {{ {} }} else {{ ", s), format!("({}.unwrap())", var_access))
@@ -727,7 +746,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
 
        /// only_contained_has_inner implies that there is only one contained element in the container
        /// and it has an inner field (ie is an "opaque" type we've defined).
-       fn from_c_conversion_container_new_var<'b>(&self, full_path: &str, is_ref: bool, single_contained: Option<&syn::Type>, var_name: &syn::Ident, var_access: &str)
+       fn from_c_conversion_container_new_var<'b>(&self, generics: Option<&GenericTypes>, full_path: &str, is_ref: bool, single_contained: Option<&syn::Type>, var_name: &syn::Ident, var_access: &str)
                        // Returns prefix + Vec<(prefix, var-name-to-inline-convert)> + suffix
                        // expecting one element in the vec per generic type, each of which is inline-converted
                        -> Option<(&'b str, Vec<(String, String)>, &'b str)> {
@@ -746,7 +765,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        },
                        "Option" => {
                                if let Some(syn::Type::Path(p)) = single_contained {
-                                       if self.c_type_has_inner_from_path(&self.resolve_path(&p.path)) {
+                                       if self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)) {
                                                if is_ref {
                                                        return Some(("if ", vec![(".inner.is_null() { None } else { Some((*".to_string(), format!("{}", var_name))], ").clone()) }"))
                                                } else {
@@ -757,16 +776,21 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
 
                                if let Some(t) = single_contained {
                                        let mut v = Vec::new();
-                                       let needs_deref = self.write_empty_rust_val_check_suffix(&mut v, t);
+                                       let ret_ref = self.write_empty_rust_val_check_suffix(generics, &mut v, t);
                                        let s = String::from_utf8(v).unwrap();
-                                       if needs_deref {
-                                               return Some(("if ", vec![
-                                                       (format!("{} {{ None }} else {{ Some(", s), format!("unsafe {{ &mut *{} }}", var_access))
-                                               ], ") }"));
-                                       } else {
-                                               return Some(("if ", vec![
-                                                       (format!("{} {{ None }} else {{ Some(", s), format!("{}", var_access))
-                                               ], ") }"));
+                                       match ret_ref {
+                                               EmptyValExpectedTy::ReferenceAsPointer =>
+                                                       return Some(("if ", vec![
+                                                               (format!("{} {{ None }} else {{ Some(", s), format!("unsafe {{ &mut *{} }}", var_access))
+                                                       ], ") }")),
+                                               EmptyValExpectedTy::OwnedPointer =>
+                                                       return Some(("if ", vec![
+                                                               (format!("{} {{ None }} else {{ Some(", s), format!("unsafe {{ *Box::from_raw({}) }}", var_access))
+                                                       ], ") }")),
+                                               EmptyValExpectedTy::NonPointer =>
+                                                       return Some(("if ", vec![
+                                                               (format!("{} {{ None }} else {{ Some(", s), format!("{}", var_access))
+                                                       ], ") }")),
                                        }
                                } else { unreachable!(); }
                        },
@@ -813,6 +837,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                let new_path = format!("{}", p.ident);
                                self.process_use_intern(w, &p.tree, &new_path);
                        },
+                       syn::UseTree::Name(n) => {
+                               let full_path = format!("{}", n.ident);
+                               self.imports.insert(n.ident.clone(), full_path);
+                       },
                        _ => unimplemented!(),
                }
                if u.leading_colon.is_some() { unimplemented!() }
@@ -864,10 +892,17 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                } else { None }
        }
 
-       pub fn maybe_resolve_path(&self, p: &syn::Path) -> Option<String> {
+       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 };
+
                if p.leading_colon.is_some() {
-                       // At some point we may need this, but for now, its unused, so just fail.
-                       return None;
+                       Some(p.segments.iter().enumerate().map(|(idx, seg)| {
+                               format!("{}{}", if idx == 0 { "" } else { "::" }, seg.ident)
+                       }).collect())
                } else if let Some(id) = p.get_ident() {
                        self.maybe_resolve_ident(id)
                } else {
@@ -878,23 +913,19 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        let mut seg_iter = p.segments.iter();
                        let first_seg = seg_iter.next().unwrap();
                        let remaining: String = seg_iter.map(|seg| {
-                               if let syn::PathArguments::None = seg.arguments {
-                                       format!("{}", seg.ident)
-                               } else {
-                                       format!("{}", seg.ident)
-                               }
+                               format!("::{}", seg.ident)
                        }).collect();
                        if let Some(imp) = self.imports.get(&first_seg.ident) {
                                if remaining != "" {
-                                       Some(imp.clone() + "::" + &remaining)
+                                       Some(imp.clone() + &remaining)
                                } else {
                                        Some(imp.clone())
                                }
                        } else { None }
                }
        }
-       pub fn resolve_path(&self, p: &syn::Path) -> String {
-               self.maybe_resolve_path(p).unwrap()
+       pub fn resolve_path(&self, p: &syn::Path, generics: Option<&GenericTypes>) -> String {
+               self.maybe_resolve_path(p, generics).unwrap()
        }
 
        // ***********************************
@@ -902,7 +933,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        // ***********************************
 
        fn write_rust_path<W: std::io::Write>(&self, w: &mut W, path: &syn::Path) {
-               if let Some(resolved) = self.maybe_resolve_path(&path) {
+               if let Some(resolved) = self.maybe_resolve_path(&path, None) {
                        if self.is_primitive(&resolved) {
                                write!(w, "{}", path.get_ident().unwrap()).unwrap();
                        } else {
@@ -1013,10 +1044,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
 
        /// Prints a constructor for something which is "uninitialized" (but obviously not actually
        /// unint'd memory).
-       pub fn write_empty_rust_val<W: std::io::Write>(&self, w: &mut W, t: &syn::Type) {
+       pub fn write_empty_rust_val<W: std::io::Write>(&self, generics: Option<&GenericTypes>, w: &mut W, t: &syn::Type) {
                match t {
                        syn::Type::Path(p) => {
-                               let resolved = self.resolve_path(&p.path);
+                               let resolved = self.resolve_path(&p.path, generics);
                                if self.crate_types.opaques.get(&resolved).is_some() {
                                        write!(w, "crate::{} {{ inner: std::ptr::null_mut(), is_owned: true }}", resolved).unwrap();
                                } else {
@@ -1043,23 +1074,23 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                }
        }
 
-       /// Prints a suffix to determine if a variable is empty (ie was set by write_empty_rust_val),
-       /// returning whether we need to dereference the inner value before using it (ie it is a
-       /// pointer).
-       pub fn write_empty_rust_val_check_suffix<W: std::io::Write>(&self, w: &mut W, t: &syn::Type) -> bool {
+       /// Prints a suffix to determine if a variable is empty (ie was set by write_empty_rust_val).
+       /// See EmptyValExpectedTy for information on return types.
+       fn write_empty_rust_val_check_suffix<W: std::io::Write>(&self, generics: Option<&GenericTypes>, w: &mut W, t: &syn::Type) -> EmptyValExpectedTy {
                match t {
                        syn::Type::Path(p) => {
-                               let resolved = self.resolve_path(&p.path);
+                               let resolved = self.resolve_path(&p.path, generics);
                                if self.crate_types.opaques.get(&resolved).is_some() {
                                        write!(w, ".inner.is_null()").unwrap();
-                                       false
+                                       EmptyValExpectedTy::NonPointer
                                } else {
                                        if let Some(suffix) = self.empty_val_check_suffix_from_path(&resolved) {
                                                write!(w, "{}", suffix).unwrap();
-                                               false // We may eventually need to allow empty_val_check_suffix_from_path to specify if we need a deref or not
+                                               // 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, ".is_null()").unwrap();
-                                               false
+                                               write!(w, " == std::ptr::null_mut()").unwrap();
+                                               EmptyValExpectedTy::OwnedPointer
                                        }
                                }
                        },
@@ -1067,26 +1098,26 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                if let syn::Expr::Lit(l) = &a.len {
                                        if let syn::Lit::Int(i) = &l.lit {
                                                write!(w, " == [0; {}]", i.base10_digits()).unwrap();
-                                               false
+                                               EmptyValExpectedTy::NonPointer
                                        } else { unimplemented!(); }
                                } else { unimplemented!(); }
                        },
                        syn::Type::Slice(_) => {
                                // Option<[]> always implies that we want to treat len() == 0 differently from
                                // None, so we always map an Option<[]> into a pointer.
-                               write!(w, ".is_null()").unwrap();
-                               true
+                               write!(w, " == std::ptr::null_mut()").unwrap();
+                               EmptyValExpectedTy::ReferenceAsPointer
                        },
                        _ => unimplemented!(),
                }
        }
 
        /// Prints a suffix to determine if a variable is empty (ie was set by write_empty_rust_val).
-       pub fn write_empty_rust_val_check<W: std::io::Write>(&self, w: &mut W, t: &syn::Type, var_access: &str) {
+       pub fn write_empty_rust_val_check<W: std::io::Write>(&self, generics: Option<&GenericTypes>, w: &mut W, t: &syn::Type, var_access: &str) {
                match t {
                        syn::Type::Path(_) => {
                                write!(w, "{}", var_access).unwrap();
-                               self.write_empty_rust_val_check_suffix(w, t);
+                               self.write_empty_rust_val_check_suffix(generics, w, t);
                        },
                        syn::Type::Array(a) => {
                                if let syn::Expr::Lit(l) = &a.len {
@@ -1098,7 +1129,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                        self.from_c_conversion_prefix_from_path(&arrty, false).unwrap(),
                                                        var_access,
                                                        self.from_c_conversion_suffix_from_path(&arrty, false).unwrap()).unwrap();
-                                               self.write_empty_rust_val_check_suffix(w, t);
+                                               self.write_empty_rust_val_check_suffix(generics, w, t);
                                        } else { unimplemented!(); }
                                } else { unimplemented!(); }
                        }
@@ -1115,12 +1146,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                match t {
                        syn::Type::Path(p) => {
                                if p.qself.is_some() { unimplemented!(); }
-                               if let Some(gen_types) = generics {
-                                       if let Some(resolved) = gen_types.maybe_resolve_path(&p.path) {
-                                               return self.skip_path(resolved.0);
-                                       }
-                               }
-                               if let Some(full_path) = self.maybe_resolve_path(&p.path) {
+                               if let Some(full_path) = self.maybe_resolve_path(&p.path, generics) {
                                        self.skip_path(&full_path)
                                } else { false }
                        },
@@ -1134,13 +1160,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                match t {
                        syn::Type::Path(p) => {
                                if p.qself.is_some() { unimplemented!(); }
-                               if let Some(gen_types) = generics {
-                                       if let Some(resolved) = gen_types.maybe_resolve_path(&p.path) {
-                                               write!(w, "{}", self.no_arg_path_to_rust(resolved.0)).unwrap();
-                                               return;
-                                       }
-                               }
-                               if let Some(full_path) = self.maybe_resolve_path(&p.path) {
+                               if let Some(full_path) = self.maybe_resolve_path(&p.path, generics) {
                                        write!(w, "{}", self.no_arg_path_to_rust(&full_path)).unwrap();
                                }
                        },
@@ -1161,42 +1181,24 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        ptr_for_ref, tupleconv, prefix, sliceconv, path_lookup, decl_lookup);
                        },
                        syn::Type::Path(p) => {
-                               if p.qself.is_some() || p.path.leading_colon.is_some() {
+                               if p.qself.is_some() {
                                        unimplemented!();
                                }
 
-                               if let Some(gen_types) = generics {
-                                       if let Some((_, synpath)) = gen_types.maybe_resolve_path(&p.path) {
-                                               let genpath = self.resolve_path(&synpath);
-                                               assert!(!self.is_known_container(&genpath, is_ref) && !self.is_transparent_container(&genpath, is_ref));
-                                               if let Some(c_type) = path_lookup(&genpath, is_ref, ptr_for_ref) {
-                                                       write!(w, "{}", c_type).unwrap();
-                                                       return;
-                                               } else {
-                                                       let synident = single_ident_generic_path_to_ident(synpath).unwrap();
-                                                       if let Some(t) = self.crate_types.traits.get(&genpath) {
-                                                               decl_lookup(w, &DeclType::Trait(t), &genpath, is_ref, is_mut);
-                                                               return;
-                                                       } else if let Some(_) = self.imports.get(synident) {
-                                                               // crate_types lookup has to have succeeded:
-                                                               panic!("Failed to print inline conversion for {}", synident);
-                                                       } else if let Some(decl_type) = self.declared.get(synident) {
-                                                               decl_lookup(w, decl_type, &self.maybe_resolve_path(synpath).unwrap(), is_ref, is_mut);
-                                                               return;
-                                                       } else { unimplemented!(); }
-                                               }
-                                       }
-                               }
-
-                               let resolved_path = self.resolve_path(&p.path);
-                               if let Some(c_type) = path_lookup(&resolved_path, is_ref, ptr_for_ref) {
+                               let resolved_path = self.resolve_path(&p.path, generics);
+                               if let Some(aliased_type) = self.crate_types.type_aliases.get(&resolved_path) {
+                                       return self.write_conversion_inline_intern(w, aliased_type, None, is_ref, is_mut, ptr_for_ref, tupleconv, prefix, sliceconv, path_lookup, decl_lookup);
+                               } else if let Some(c_type) = path_lookup(&resolved_path, is_ref, ptr_for_ref) {
                                        write!(w, "{}", c_type).unwrap();
                                } else if self.crate_types.opaques.get(&resolved_path).is_some() {
                                        decl_lookup(w, &DeclType::StructImported, &resolved_path, is_ref, is_mut);
                                } else if self.crate_types.mirrored_enums.get(&resolved_path).is_some() {
                                        decl_lookup(w, &DeclType::MirroredEnum, &resolved_path, is_ref, is_mut);
                                } else if let Some(ident) = single_ident_generic_path_to_ident(&p.path) {
-                                       if let Some(_) = self.imports.get(ident) {
+                                       if let Some(t) = self.crate_types.traits.get(&resolved_path) {
+                                               decl_lookup(w, &DeclType::Trait(t), &resolved_path, is_ref, is_mut);
+                                               return;
+                                       } else if let Some(_) = self.imports.get(ident) {
                                                // crate_types lookup has to have succeeded:
                                                panic!("Failed to print inline conversion for {}", ident);
                                        } else if let Some(decl_type) = self.declared.get(ident) {
@@ -1217,13 +1219,40 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                // We assume all slices contain only literals or references.
                                // This may result in some outputs not compiling.
                                if let syn::Type::Path(p) = &*s.elem {
-                                       let resolved = self.resolve_path(&p.path);
+                                       let resolved = self.resolve_path(&p.path, generics);
                                        assert!(self.is_primitive(&resolved));
                                        write!(w, "{}", path_lookup("[u8]", is_ref, ptr_for_ref).unwrap()).unwrap();
                                } 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)))).unwrap();
+                                               write!(w, "{}", sliceconv(self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)))).unwrap();
                                        } else { unimplemented!(); }
+                               } else if let syn::Type::Tuple(t) = &*s.elem {
+                                       assert!(!t.elems.is_empty());
+                                       if prefix {
+                                               write!(w, "&local_").unwrap();
+                                       } else {
+                                               let mut needs_map = false;
+                                               for e in t.elems.iter() {
+                                                       if let syn::Type::Reference(_) = e {
+                                                               needs_map = true;
+                                                       }
+                                               }
+                                               if needs_map {
+                                                       write!(w, ".iter().map(|(").unwrap();
+                                                       for i in 0..t.elems.len() {
+                                                               write!(w, "{}{}", if i != 0 { ", " } else { "" }, ('a' as u8 + i as u8) as char).unwrap();
+                                                       }
+                                                       write!(w, ")| (").unwrap();
+                                                       for (idx, e) in t.elems.iter().enumerate() {
+                                                               if let syn::Type::Reference(_) = e {
+                                                                       write!(w, "{}{}", if idx != 0 { ", " } else { "" }, (idx as u8 + 'a' as u8) as char).unwrap();
+                                                               } else if let syn::Type::Path(_) = e {
+                                                                       write!(w, "{}*{}", if idx != 0 { ", " } else { "" }, (idx as u8 + 'a' as u8) as char).unwrap();
+                                                               } else { unimplemented!(); }
+                                                       }
+                                                       write!(w, ")).collect::<Vec<_>>()[..]").unwrap();
+                                               }
+                                       }
                                } else { unimplemented!(); }
                        },
                        syn::Type::Tuple(t) => {
@@ -1375,10 +1404,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        }
                                        if let syn::Type::Reference(t) = ty {
                                                if let syn::Type::Path(p) = &*t.elem {
-                                                       self.c_type_has_inner_from_path(&self.resolve_path(&p.path))
+                                                       self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics))
                                                } else { false }
                                        } else if let syn::Type::Path(p) = ty {
-                                               self.c_type_has_inner_from_path(&self.resolve_path(&p.path))
+                                               self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics))
                                        } else { false }
                                } else { true };
 
@@ -1467,19 +1496,13 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                }
                        },
                        syn::Type::Path(p) => {
-                               if p.qself.is_some() || p.path.leading_colon.is_some() {
+                               if p.qself.is_some() {
                                        unimplemented!();
                                }
-                               if let Some(gen_types) = generics {
-                                       if let Some(resolved) = gen_types.maybe_resolve_path(&p.path) {
-                                               assert!(!self.is_known_container(&resolved.0, is_ref) && !self.is_transparent_container(&resolved.0, is_ref));
-                                               if let Some((prefix, suffix)) = path_lookup(&resolved.0, is_ref) {
-                                                       write!(w, "let mut local_{} = {}{}{};", ident, prefix, var, suffix).unwrap();
-                                                       return true;
-                                               } else { return false; }
-                                       }
+                               let resolved_path = self.resolve_path(&p.path, generics);
+                               if let Some(aliased_type) = self.crate_types.type_aliases.get(&resolved_path) {
+                                       return self.write_conversion_new_var_intern(w, ident, var, aliased_type, None, is_ref, ptr_for_ref, to_c, path_lookup, container_lookup, var_prefix, var_suffix);
                                }
-                               let resolved_path = self.resolve_path(&p.path);
                                if self.is_known_container(&resolved_path, is_ref) || self.is_transparent_container(&resolved_path, is_ref) {
                                        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| {
@@ -1507,7 +1530,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        },
                        syn::Type::Slice(s) => {
                                if let syn::Type::Path(p) = &*s.elem {
-                                       let resolved = self.resolve_path(&p.path);
+                                       let resolved = self.resolve_path(&p.path, generics);
                                        assert!(self.is_primitive(&resolved));
                                        let slice_path = format!("[{}]", resolved);
                                        if let Some((prefix, suffix)) = path_lookup(&slice_path, true) {
@@ -1519,6 +1542,24 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        is_ref = true;
                                        convert_container!("Slice", 1, || tyref.iter());
                                        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.
+                                       // Thus, we drop any references inside the tuple and convert with non-reference types.
+                                       let mut elems = syn::punctuated::Punctuated::new();
+                                       for elem in t.elems.iter() {
+                                               if let syn::Type::Reference(r) = elem {
+                                                       elems.push((*r.elem).clone());
+                                               } else {
+                                                       elems.push(elem.clone());
+                                               }
+                                       }
+                                       let ty = [syn::Type::Tuple(syn::TypeTuple {
+                                               paren_token: t.paren_token, elems
+                                       })];
+                                       is_ref = false;
+                                       ptr_for_ref = true;
+                                       convert_container!("Slice", 1, || ty.iter());
+                                       unimplemented!("convert_container should return true as container_lookup should succeed for slices");
                                } else { unimplemented!() }
                        },
                        syn::Type::Tuple(t) => {
@@ -1544,7 +1585,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                                // Opaque types with inner pointers shouldn't ever create new stack
                                                                // variables, so we don't handle it and just assert that it doesn't
                                                                // here.
-                                                               assert!(!self.c_type_has_inner_from_path(&self.resolve_path(&p.path)));
+                                                               assert!(!self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics)));
                                                        }
                                                }
                                        }
@@ -1559,10 +1600,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                                }
                                                                if let syn::Type::Reference(t) = elem {
                                                                        if let syn::Type::Path(p) = &*t.elem {
-                                                                               self.c_type_has_inner_from_path(&self.resolve_path(&p.path))
+                                                                               self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics))
                                                                        } else { false }
                                                                } else if let syn::Type::Path(p) = elem {
-                                                                       self.c_type_has_inner_from_path(&self.resolve_path(&p.path))
+                                                                       self.c_type_has_inner_from_path(&self.resolve_path(&p.path, generics))
                                                                } else { false }
                                                        };
                                                if idx != 0 { write!(w, ", ").unwrap(); }
@@ -1591,7 +1632,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        pub fn write_to_c_conversion_new_var_inner<W: std::io::Write>(&self, w: &mut W, ident: &syn::Ident, var_access: &str, t: &syn::Type, generics: Option<&GenericTypes>, ptr_for_ref: bool) -> bool {
                self.write_conversion_new_var_intern(w, ident, var_access, t, generics, false, ptr_for_ref, true,
                        &|a, b| self.to_c_conversion_new_var_from_path(a, b),
-                       &|a, b, c, d, e| self.to_c_conversion_container_new_var(a, b, c, d, e),
+                       &|a, b, c, d, e| self.to_c_conversion_container_new_var(generics, a, b, c, d, e),
                        // We force ptr_for_ref here since we can't generate a ref on one line and use it later
                        &|a, b, c, d, e, f| self.write_to_c_conversion_inline_prefix_inner(a, b, c, d, e, f),
                        &|a, b, c, d, e, f| self.write_to_c_conversion_inline_suffix_inner(a, b, c, d, e, f))
@@ -1602,7 +1643,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        pub fn write_from_c_conversion_new_var<W: std::io::Write>(&self, w: &mut W, ident: &syn::Ident, t: &syn::Type, generics: Option<&GenericTypes>) -> bool {
                self.write_conversion_new_var_intern(w, ident, &format!("{}", ident), t, generics, false, false, false,
                        &|a, b| self.from_c_conversion_new_var_from_path(a, b),
-                       &|a, b, c, d, e| self.from_c_conversion_container_new_var(a, b, c, d, e),
+                       &|a, b, c, d, e| self.from_c_conversion_container_new_var(generics, a, b, c, d, e),
                        // We force ptr_for_ref here since we can't generate a ref on one line and use it later
                        &|a, b, c, d, e, _f| self.write_from_c_conversion_prefix_inner(a, b, c, d, e),
                        &|a, b, c, d, e, _f| self.write_from_c_conversion_suffix_inner(a, b, c, d, e))
@@ -1612,7 +1653,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
        // *** C Container Type Equivalent and alias Printing ***
        // ******************************************************
 
-       fn write_template_constructor<W: std::io::Write>(&mut self, w: &mut W, container_type: &str, mangled_container: &str, args: &Vec<&syn::Type>, is_ref: bool) {
+       fn write_template_constructor<W: std::io::Write>(&mut self, w: &mut W, container_type: &str, mangled_container: &str, args: &Vec<&syn::Type>, generics: Option<&GenericTypes>, is_ref: bool) {
                if container_type == "Result" {
                        assert_eq!(args.len(), 2);
                        macro_rules! write_fn {
@@ -1625,15 +1666,15 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                ($call: expr, $item: expr) => { {
                                        write!(w, "#[no_mangle]\npub static {}_{}: extern \"C\" fn (", mangled_container, $call).unwrap();
                                        if let syn::Type::Path(syn::TypePath { path, .. }) = $item {
-                                               let resolved = self.resolve_path(path);
+                                               let resolved = self.resolve_path(path, generics);
                                                if self.is_known_container(&resolved, is_ref) || self.is_transparent_container(&resolved, is_ref) {
-                                                       self.write_c_mangled_container_path_intern(w, Self::path_to_generic_args(path),
+                                                       self.write_c_mangled_container_path_intern(w, Self::path_to_generic_args(path), generics,
                                                                &format!("{}", single_ident_generic_path_to_ident(path).unwrap()), is_ref, false, false, false);
                                                } else {
                                                        self.write_template_generics(w, &mut [$item].iter().map(|t| *t), is_ref, true);
                                                }
                                        } else if let syn::Type::Tuple(syn::TypeTuple { elems, .. }) = $item {
-                                               self.write_c_mangled_container_path_intern(w, elems.iter().collect(),
+                                               self.write_c_mangled_container_path_intern(w, elems.iter().collect(), generics,
                                                        &format!("{}Tuple", elems.len()), is_ref, false, false, false);
                                        } else { unimplemented!(); }
                                        write!(w, ") -> {} =\n\t{}::CResultTempl::<", mangled_container, Self::container_templ_path()).unwrap();
@@ -1653,14 +1694,14 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        write!(w, "#[no_mangle]\npub extern \"C\" fn {}_new(", mangled_container).unwrap();
                        for (idx, gen) in args.iter().enumerate() {
                                write!(w, "{}{}: ", if idx != 0 { ", " } else { "" }, ('a' as u8 + idx as u8) as char).unwrap();
-                               self.write_c_type_intern(None, w, gen, false, false, false);
+                               assert!(self.write_c_type_intern(w, gen, None, false, false, false));
                        }
                        writeln!(w, ") -> {} {{", mangled_container).unwrap();
-                       writeln!(w, "\t{} {{", mangled_container).unwrap();
+                       write!(w, "\t{} {{ ", mangled_container).unwrap();
                        for idx in 0..args.len() {
-                               writeln!(w, "\t\t{}: Box::into_raw(Box::new({})),", ('a' as u8 + idx as u8) as char, ('a' as u8 + idx as u8) as char).unwrap();
+                               write!(w, "{}, ", ('a' as u8 + idx as u8) as char).unwrap();
                        }
-                       writeln!(w, "\t}}\n}}\n").unwrap();
+                       writeln!(w, "}}\n}}\n").unwrap();
                } else {
                        writeln!(w, "").unwrap();
                }
@@ -1680,7 +1721,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        write!(w, ">").unwrap();
                                }
                        } else if let syn::Type::Path(p_arg) = t {
-                               let resolved_generic = self.resolve_path(&p_arg.path);
+                               let resolved_generic = self.resolve_path(&p_arg.path, None);
                                if self.is_primitive(&resolved_generic) {
                                        write!(w, "{}", resolved_generic).unwrap();
                                } else if let Some(c_type) = self.c_type_from_path(&resolved_generic, is_ref, false) {
@@ -1722,16 +1763,17 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                }
                        } else if let syn::Type::Reference(r_arg) = t {
                                if let syn::Type::Path(p_arg) = &*r_arg.elem {
-                                       let resolved = self.resolve_path(&p_arg.path);
-                                       if single_ident_generic_path_to_ident(&p_arg.path).is_some() {
-                                               if self.crate_types.opaques.get(&resolved).is_some() {
-                                                       write!(w, "crate::{}", resolved).unwrap();
-                                               } else { unimplemented!(); }
-                                       } else { unimplemented!(); }
+                                       let resolved = self.resolve_path(&p_arg.path, None);
+                                       if self.crate_types.opaques.get(&resolved).is_some() {
+                                               write!(w, "crate::{}", resolved).unwrap();
+                                       } else {
+                                               let cty = self.c_type_from_path(&resolved, true, true).expect("Template generics should be opaque or have a predefined mapping");
+                                               w.write(cty.as_bytes()).unwrap();
+                                       }
                                } else { unimplemented!(); }
                        } else if let syn::Type::Array(a_arg) = t {
                                if let syn::Type::Path(p_arg) = &*a_arg.elem {
-                                       let resolved = self.resolve_path(&p_arg.path);
+                                       let resolved = self.resolve_path(&p_arg.path, None);
                                        assert!(self.is_primitive(&resolved));
                                        if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Int(len), .. }) = &a_arg.len {
                                                write!(w, "{}",
@@ -1741,7 +1783,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        }
                }
        }
-       fn check_create_container(&mut self, mangled_container: String, container_type: &str, args: Vec<&syn::Type>, is_ref: bool) {
+       fn check_create_container(&mut self, mangled_container: String, container_type: &str, args: Vec<&syn::Type>, generics: Option<&GenericTypes>, is_ref: bool) {
                if !self.crate_types.templates_defined.get(&mangled_container).is_some() {
                        self.crate_types.templates_defined.insert(mangled_container.clone(), true);
                        let mut created_container: Vec<u8> = Vec::new();
@@ -1756,7 +1798,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        self.write_template_generics(&mut created_container, &mut args.iter().map(|t| *t), is_ref, true);
                        writeln!(&mut created_container, ">;").unwrap();
 
-                       self.write_template_constructor(&mut created_container, container_type, &mangled_container, &args, is_ref);
+                       self.write_template_constructor(&mut created_container, container_type, &mangled_container, &args, generics, is_ref);
 
                        self.crate_types.template_file.write(&created_container).unwrap();
                }
@@ -1767,7 +1809,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                } else { unimplemented!(); }
        }
        fn write_c_mangled_container_path_intern<W: std::io::Write>
-                       (&mut self, w: &mut W, args: Vec<&syn::Type>, ident: &str, is_ref: bool, is_mut: bool, ptr_for_ref: bool, in_type: bool) -> bool {
+                       (&mut 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) {
                        write!(w, "C{}_", ident).unwrap();
@@ -1776,7 +1818,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                for arg in args.iter() {
                        macro_rules! write_path {
                                ($p_arg: expr, $extra_write: expr) => {
-                                       let subtype = self.resolve_path(&$p_arg.path);
+                                       let subtype = self.resolve_path(&$p_arg.path, generics);
                                        if self.is_transparent_container(ident, is_ref) {
                                                // We dont (yet) support primitives or containers inside transparent
                                                // containers, so check for that first:
@@ -1784,9 +1826,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                if self.is_known_container(&subtype, is_ref) { return false; }
                                                if !in_type {
                                                        if self.c_type_has_inner_from_path(&subtype) {
-                                                               if !self.write_c_path_intern(w, &$p_arg.path, is_ref, is_mut, ptr_for_ref) { return false; }
+                                                               if !self.write_c_path_intern(w, &$p_arg.path, generics, is_ref, is_mut, ptr_for_ref) { return false; }
                                                        } else {
-                                                               if !self.write_c_path_intern(w, &$p_arg.path, true, is_mut, true) { return false; }
+                                                               // Option<T> needs to be converted to a *mut T, ie mut ptr-for-ref
+                                                               if !self.write_c_path_intern(w, &$p_arg.path, generics, true, true, true) { return false; }
                                                        }
                                                } else {
                                                        if $p_arg.path.segments.len() == 1 {
@@ -1796,23 +1839,24 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                        }
                                                }
                                        } else if self.is_known_container(&subtype, is_ref) || self.is_transparent_container(&subtype, is_ref) {
-                                               if !self.write_c_mangled_container_path_intern(w, Self::path_to_generic_args(&$p_arg.path),
+                                               if !self.write_c_mangled_container_path_intern(w, Self::path_to_generic_args(&$p_arg.path), generics,
                                                                &subtype, is_ref, is_mut, ptr_for_ref, true) {
                                                        return false;
                                                }
                                                self.write_c_mangled_container_path_intern(&mut mangled_type, Self::path_to_generic_args(&$p_arg.path),
-                                                       &subtype, is_ref, is_mut, ptr_for_ref, true);
+                                                       generics, &subtype, is_ref, is_mut, ptr_for_ref, true);
                                                if let Some(w2) = $extra_write as Option<&mut Vec<u8>> {
                                                        self.write_c_mangled_container_path_intern(w2, Self::path_to_generic_args(&$p_arg.path),
-                                                               &subtype, is_ref, is_mut, ptr_for_ref, true);
+                                                               generics, &subtype, is_ref, is_mut, ptr_for_ref, true);
                                                }
-                                       } else if let Some(id) = single_ident_generic_path_to_ident(&$p_arg.path) {
+                                       } else {
+                                               let id = &&$p_arg.path.segments.iter().rev().next().unwrap().ident;
                                                write!(w, "{}", id).unwrap();
                                                write!(mangled_type, "{}", id).unwrap();
                                                if let Some(w2) = $extra_write as Option<&mut Vec<u8>> {
                                                        write!(w2, "{}", id).unwrap();
                                                }
-                                       } else { return false; }
+                                       }
                                }
                        }
                        if let syn::Type::Tuple(tuple) = arg {
@@ -1832,13 +1876,17 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                        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; }
                                        }
                                        write!(w, "Z").unwrap();
                                        write!(mangled_type, "Z").unwrap();
                                        write!(mangled_tuple_type, "Z").unwrap();
                                        self.check_create_container(String::from_utf8(mangled_tuple_type).unwrap(),
-                                               &format!("{}Tuple", tuple.elems.len()), tuple.elems.iter().collect(), is_ref);
+                                               &format!("{}Tuple", tuple.elems.len()), tuple.elems.iter().collect(), generics, is_ref);
                                }
                        } else if let syn::Type::Path(p_arg) = arg {
                                write_path!(p_arg, None);
@@ -1856,7 +1904,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                } 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);
+                                       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; }
@@ -1872,23 +1920,22 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                write!(mangled_type, "Z").unwrap();
 
                // Make sure the type is actually defined:
-               self.check_create_container(String::from_utf8(mangled_type).unwrap(), ident, args, is_ref);
+               self.check_create_container(String::from_utf8(mangled_type).unwrap(), ident, args, generics, is_ref);
                true
        }
-       fn write_c_mangled_container_path<W: std::io::Write>(&mut self, w: &mut W, args: Vec<&syn::Type>, ident: &str, is_ref: bool, is_mut: bool, ptr_for_ref: bool) -> bool {
+       fn write_c_mangled_container_path<W: std::io::Write>(&mut 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) {
                        write!(w, "{}::", Self::generated_container_path()).unwrap();
                }
-               self.write_c_mangled_container_path_intern(w, args, ident, is_ref, is_mut, ptr_for_ref, false)
+               self.write_c_mangled_container_path_intern(w, args, generics, ident, is_ref, is_mut, ptr_for_ref, false)
        }
 
        // **********************************
        // *** C Type Equivalent Printing ***
        // **********************************
 
-       fn write_c_path_intern<W: std::io::Write>(&self, w: &mut W, path: &syn::Path, is_ref: bool, is_mut: bool, ptr_for_ref: bool) -> bool {
-//eprintln!("pcpi ({} {} {}): {:?}", is_ref, is_mut, ptr_for_ref, path);
-               let full_path = match self.maybe_resolve_path(&path) {
+       fn write_c_path_intern<W: std::io::Write>(&self, w: &mut W, path: &syn::Path, generics: Option<&GenericTypes>, is_ref: bool, is_mut: bool, ptr_for_ref: bool) -> bool {
+               let full_path = match self.maybe_resolve_path(&path, generics) {
                        Some(path) => path, None => return false };
                if let Some(c_type) = self.c_type_from_path(&full_path, is_ref, ptr_for_ref) {
                        write!(w, "{}", c_type).unwrap();
@@ -1919,43 +1966,35 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        false
                }
        }
-       fn write_c_type_intern<W: std::io::Write>(&mut self, generics: Option<&GenericTypes>, w: &mut W, t: &syn::Type, is_ref: bool, is_mut: bool, ptr_for_ref: bool) -> bool {
+       fn write_c_type_intern<W: std::io::Write>(&mut self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, is_ref: bool, is_mut: bool, ptr_for_ref: bool) -> bool {
                match t {
                        syn::Type::Path(p) => {
-                               if p.qself.is_some() || p.path.leading_colon.is_some() {
+                               if p.qself.is_some() {
                                        return false;
                                }
-                               if let Some(gen_types) = generics {
-                                       if let Some(resolved) = gen_types.maybe_resolve_path(&p.path) {
-                                               if self.is_known_container(&resolved.0, is_ref) { return false; }
-                                               if self.is_transparent_container(&resolved.0, is_ref) { return false; }
-                                               return self.write_c_path_intern(w, &resolved.1, is_ref, is_mut, ptr_for_ref);
-                                       }
-                               }
-                               if let Some(full_path) = self.maybe_resolve_path(&p.path) {
+                               if let Some(full_path) = self.maybe_resolve_path(&p.path, generics) {
                                        if self.is_known_container(&full_path, is_ref) || self.is_transparent_container(&full_path, is_ref) {
-                                               return self.write_c_mangled_container_path(w, Self::path_to_generic_args(&p.path), &full_path, is_ref, is_mut, ptr_for_ref);
+                                               return self.write_c_mangled_container_path(w, Self::path_to_generic_args(&p.path), generics, &full_path, is_ref, is_mut, ptr_for_ref);
+                                       }
+                                       if let Some(aliased_type) = self.crate_types.type_aliases.get(&full_path).cloned() {
+                                               return self.write_c_type_intern(w, &aliased_type, None, is_ref, is_mut, ptr_for_ref);
                                        }
                                }
-                               if p.path.leading_colon.is_some() { return false; }
-                               self.write_c_path_intern(w, &p.path, is_ref, is_mut, ptr_for_ref)
+                               self.write_c_path_intern(w, &p.path, generics, is_ref, is_mut, ptr_for_ref)
                        },
                        syn::Type::Reference(r) => {
-                               if let Some(lft) = &r.lifetime {
-                                       if format!("{}", lft.ident) != "static" { return false; }
-                               }
-                               self.write_c_type_intern(generics, w, &*r.elem, true, r.mutability.is_some(), ptr_for_ref)
+                               self.write_c_type_intern(w, &*r.elem, generics, true, r.mutability.is_some(), ptr_for_ref)
                        },
                        syn::Type::Array(a) => {
                                if is_ref && is_mut {
                                        write!(w, "*mut [").unwrap();
-                                       if !self.write_c_type_intern(generics, w, &a.elem, false, false, ptr_for_ref) { return false; }
+                                       if !self.write_c_type_intern(w, &a.elem, generics, false, false, ptr_for_ref) { return false; }
                                } else if is_ref {
                                        write!(w, "*const [").unwrap();
-                                       if !self.write_c_type_intern(generics, w, &a.elem, false, false, ptr_for_ref) { return false; }
+                                       if !self.write_c_type_intern(w, &a.elem, generics, false, false, ptr_for_ref) { return false; }
                                } else {
                                        let mut typecheck = Vec::new();
-                                       if !self.write_c_type_intern(generics, &mut typecheck, &a.elem, false, false, ptr_for_ref) { return false; }
+                                       if !self.write_c_type_intern(&mut typecheck, &a.elem, generics, false, false, ptr_for_ref) { return false; }
                                        if typecheck[..] != ['u' as u8, '8' as u8] { return false; }
                                }
                                if let syn::Expr::Lit(l) = &a.len {
@@ -1975,7 +2014,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                        syn::Type::Slice(s) => {
                                if !is_ref || is_mut { return false; }
                                if let syn::Type::Path(p) = &*s.elem {
-                                       let resolved = self.resolve_path(&p.path);
+                                       let resolved = self.resolve_path(&p.path, generics);
                                        if self.is_primitive(&resolved) {
                                                write!(w, "{}::{}slice", Self::container_templ_path(), resolved).unwrap();
                                                true
@@ -1983,7 +2022,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                } else if let syn::Type::Reference(r) = &*s.elem {
                                        if let syn::Type::Path(p) = &*r.elem {
                                                // Slices with "real types" inside are mapped as the equivalent non-ref Vec
-                                               let resolved = self.resolve_path(&p.path);
+                                               let resolved = self.resolve_path(&p.path, generics);
                                                let mangled_container = if let Some(ident) = self.crate_types.opaques.get(&resolved) {
                                                        format!("CVec_{}Z", ident)
                                                } else if let Some(en) = self.crate_types.mirrored_enums.get(&resolved) {
@@ -1992,16 +2031,27 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                                                        format!("CVec_{}Z", id)
                                                } else { return false; };
                                                write!(w, "{}::{}", Self::generated_container_path(), mangled_container).unwrap();
-                                               self.check_create_container(mangled_container, "Vec", vec![&*r.elem], false);
+                                               self.check_create_container(mangled_container, "Vec", vec![&*r.elem], generics, false);
                                                true
                                        } else { false }
+                               } else if let syn::Type::Tuple(_) = &*s.elem {
+                                       let mut args = syn::punctuated::Punctuated::new();
+                                       args.push(syn::GenericArgument::Type((*s.elem).clone()));
+                                       let mut segments = syn::punctuated::Punctuated::new();
+                                       segments.push(syn::PathSegment {
+                                               ident: syn::Ident::new("Vec", Span::call_site()),
+                                               arguments: syn::PathArguments::AngleBracketed(syn::AngleBracketedGenericArguments {
+                                                       colon2_token: None, lt_token: syn::Token![<](Span::call_site()), args, gt_token: syn::Token![>](Span::call_site()),
+                                               })
+                                       });
+                                       self.write_c_type_intern(w, &syn::Type::Path(syn::TypePath { qself: None, path: syn::Path { leading_colon: None, segments } }), generics, false, is_mut, ptr_for_ref)
                                } else { false }
                        },
                        syn::Type::Tuple(t) => {
                                if t.elems.len() == 0 {
                                        true
                                } else {
-                                       self.write_c_mangled_container_path(w, t.elems.iter().collect(),
+                                       self.write_c_mangled_container_path(w, t.elems.iter().collect(), generics,
                                                &format!("{}Tuple", t.elems.len()), is_ref, is_mut, ptr_for_ref)
                                }
                        },
@@ -2009,13 +2059,13 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> {
                }
        }
        pub fn write_c_type<W: std::io::Write>(&mut self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, ptr_for_ref: bool) {
-               assert!(self.write_c_type_intern(generics, w, t, false, false, ptr_for_ref));
+               assert!(self.write_c_type_intern(w, t, generics, false, false, ptr_for_ref));
        }
        pub fn understood_c_path(&mut self, p: &syn::Path) -> bool {
                if p.leading_colon.is_some() { return false; }
-               self.write_c_path_intern(&mut std::io::sink(), p, false, false, false)
+               self.write_c_path_intern(&mut std::io::sink(), p, None, false, false, false)
        }
        pub fn understood_c_type(&mut self, t: &syn::Type, generics: Option<&GenericTypes>) -> bool {
-               self.write_c_type_intern(generics, &mut std::io::sink(), t, false, false, false)
+               self.write_c_type_intern(&mut std::io::sink(), t, generics, false, false, false)
        }
 }
index 72426bdf334ed0f265cd7a4220c7c4381b1b86c0..0c221c7c6ad44ad4c2d6c4b46b34d176e2a7924d 100644 (file)
@@ -218,6 +218,9 @@ These include:
          ...
    } LDKChannelKeys;
    ```
+ * Private and public keys are asserted valid at the FFI boundary. Thus, before passing any
+   (untrusted) private or public key material across the boundary, ensure that they represent valid
+   (ie in-range) keys.
    
 **It is highly recommended that you test any code which relies on the C (or C++) bindings in
 valgrind, AddressSanitizer, MemorySanitizer, or other similar tools to ensure correctness.**
index 645c95bc4a889c944e3290451226064cd6690ed3..0f8bd102a48189be60b5156a686297a54fd2ac60 100644 (file)
@@ -19,6 +19,7 @@ uint32_t get_fee(const void *this_arg, LDKConfirmationTarget target) {
 
 void broadcast_tx(const void *this_arg, LDKTransaction tx) {
        //TODO
+       Transaction_free(tx);
 }
 
 LDKCResult_NoneChannelMonitorUpdateErrZ add_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
@@ -53,11 +54,11 @@ int main() {
                .free = NULL
        };
 
-       LDKManyChannelMonitor mon = {
+       LDKWatch mon = {
                .this_arg = NULL,
-               .add_monitor = add_channel_monitor,
-               .update_monitor = update_channel_monitor,
-               .get_and_clear_pending_monitor_events = monitors_pending_monitor_events,
+               .watch_channel = add_channel_monitor,
+               .update_channel = update_channel_monitor,
+               .release_pending_monitor_events = monitors_pending_monitor_events,
                .free = NULL,
        };
 
index 7829f0265f3a2b4fc40950d4d252ae46889a74a9..ee1cedf17a12021adfb583425e306198a29568e1 100644 (file)
@@ -48,44 +48,44 @@ const uint8_t valid_node_announcement[] = {
 // A simple block containing only one transaction (which is the channel-open transaction for the
 // channel we'll create). This was originally created by printing additional data in a simple
 // rust-lightning unit test.
-const uint8_t channel_open_block[] = {
+const uint8_t channel_open_header[80] = {
        0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0xa2, 0x47, 0xd2, 0xf8, 0xd4, 0xe0, 0x6a, 0x3f, 0xf9, 0x7a, 0x9a, 0x34,
        0xbb, 0xa9, 0x96, 0xde, 0x63, 0x84, 0x5a, 0xce, 0xcf, 0x98, 0xb8, 0xbb, 0x75, 0x4c, 0x4f, 0x7d,
        0xee, 0x4c, 0xa9, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+const uint8_t channel_open_tx[] = {
+       0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x01, 0x40, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x20, 0x20, 0x12, 0x70,
-       0x44, 0x41, 0x40, 0xaf, 0xc5, 0x72, 0x97, 0xc8, 0x69, 0xba, 0x04, 0xdb, 0x28, 0x7b, 0xd7, 0x32,
-       0x07, 0x33, 0x3a, 0x4a, 0xc2, 0xc5, 0x56, 0x06, 0x05, 0x65, 0xd7, 0xa8, 0xcf, 0x01, 0x00, 0x00,
-       0x00, 0x00, 0x00
+       0x01, 0x40, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x20, 0x20, 0x12, 0x70, 0x44,
+       0x41, 0x40, 0xaf, 0xc5, 0x72, 0x97, 0xc8, 0x69, 0xba, 0x04, 0xdb, 0x28, 0x7b, 0xd7, 0x32, 0x07,
+       0x33, 0x3a, 0x4a, 0xc2, 0xc5, 0x56, 0x06, 0x05, 0x65, 0xd7, 0xa8, 0xcf, 0x01, 0x00, 0x00, 0x00,
+       0x00, 0x00
 };
 
 // The first transaction in the block is header (80 bytes) + transaction count (1 byte) into the block data.
-const uint8_t *channel_open_tx = channel_open_block + 81;
 const uint8_t channel_open_txid[] = {
        0x5f, 0xa9, 0x4c, 0xee, 0x7d, 0x4f, 0x4c, 0x75, 0xbb, 0xb8, 0x98, 0xcf, 0xce, 0x5a, 0x84, 0x63,
        0xde, 0x96, 0xa9, 0xbb, 0x34, 0x9a, 0x7a, 0xf9, 0x3f, 0x6a, 0xe0, 0xd4, 0xf8, 0xd2, 0x47, 0xa2
 };
 
 // Two blocks built on top of channel_open_block:
-const uint8_t block_1[] = {
+const uint8_t header_1[80] = {
        0x01, 0x00, 0x00, 0x00, 0x65, 0x8e, 0xf1, 0x90, 0x88, 0xfa, 0x13, 0x9c, 0x6a, 0xea, 0xf7, 0xc1,
        0x5a, 0xdd, 0x52, 0x4d, 0x3c, 0x48, 0x03, 0xb3, 0x9b, 0x25, 0x4f, 0x02, 0x79, 0x05, 0x90, 0xe0,
        0xc4, 0x8d, 0xa0, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00
 };
-const uint8_t block_2[] = {
+const uint8_t header_2[80] = {
        0x01, 0x00, 0x00, 0x00, 0xf2, 0x08, 0x87, 0x51, 0xcb, 0xb1, 0x1a, 0x51, 0x76, 0x01, 0x6c, 0x5d,
        0x76, 0x26, 0x54, 0x6f, 0xd9, 0xbd, 0xa6, 0xa5, 0xe9, 0x4b, 0x21, 0x6e, 0xda, 0xa3, 0x64, 0x23,
        0xcd, 0xf1, 0xe2, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00
 };
 
 const LDKThirtyTwoBytes payment_preimage_1 = {
@@ -115,18 +115,21 @@ static int num_txs_broadcasted = 0; // Technically a race, but ints are atomic o
 void broadcast_tx(const void *this_arg, LDKTransaction tx) {
        num_txs_broadcasted += 1;
        //TODO
+       Transaction_free(tx);
 }
 
 struct NodeMonitors {
        std::mutex mut;
        std::vector<std::pair<LDK::OutPoint, LDK::ChannelMonitor>> mons;
-       LDKChainWatchInterfaceUtil* watch_util;
        LDKLogger* logger;
+
+       void ConnectBlock(const uint8_t (*header)[80], uint32_t height, LDKCVec_C2Tuple_usizeTransactionZZ tx_data, LDKBroadcasterInterface broadcast, LDKFeeEstimator fee_est) {
+               std::unique_lock<std::mutex> l(mut);
+               for (auto& mon : mons) {
+                       LDK::CVec_C2Tuple_TxidCVec_TxOutZZZ res = ChannelMonitor_block_connected(&mon.second, &header_2, tx_data, height, broadcast, fee_est, *logger);
+               }
+       }
 };
-void NodeMonitors_free(void *this_arg) {
-       NodeMonitors* arg = (NodeMonitors*) this_arg;
-       delete arg;
-}
 
 LDKCResult_NoneChannelMonitorUpdateErrZ add_channel_monitor(const void *this_arg, LDKOutPoint funding_txo_arg, LDKChannelMonitor monitor_arg) {
        // First bind the args to C++ objects so they auto-free
@@ -136,19 +139,6 @@ LDKCResult_NoneChannelMonitorUpdateErrZ add_channel_monitor(const void *this_arg
        NodeMonitors* arg = (NodeMonitors*) this_arg;
        std::unique_lock<std::mutex> l(arg->mut);
 
-       LDK::ChainWatchInterface watch = ChainWatchInterfaceUtil_as_ChainWatchInterface(arg->watch_util);
-       LDK::C2Tuple_OutPointScriptZ funding_info = ChannelMonitor_get_funding_txo(&mon);
-       LDKThirtyTwoBytes funding_txid;
-       memcpy(funding_txid.data, OutPoint_get_txid(funding_info->a), 32);
-       LDK::C2Tuple_Txidu32Z outpoint(C2Tuple_Txidu32Z_new(funding_txid, OutPoint_get_index(funding_info->a)));
-       watch->install_watch_outpoint(watch->this_arg, outpoint, LDKu8slice {
-               .data = funding_info->b->data,
-               .datalen = funding_info->b->datalen,
-       });
-       watch->install_watch_tx(watch->this_arg, &funding_txid.data, LDKu8slice {
-               .data = funding_info->b->data,
-               .datalen = funding_info->b->datalen,
-       });
        arg->mons.push_back(std::make_pair(std::move(funding_txo), std::move(mon)));
        return CResult_NoneChannelMonitorUpdateErrZ_ok();
 }
@@ -254,15 +244,14 @@ int main() {
                .free = NULL,
        };
 
-       LDK::ChainWatchInterfaceUtil chain1 = ChainWatchInterfaceUtil_new(network);
-       LDK::BlockNotifier blocks1 = BlockNotifier_new(ChainWatchInterfaceUtil_as_ChainWatchInterface(&chain1));
-
-       LDKManyChannelMonitor mon1 {
-               .this_arg = new NodeMonitors { .watch_util = &chain1, .logger = &logger1 },
-               .add_monitor = add_channel_monitor,
-               .update_monitor = update_channel_monitor,
-               .get_and_clear_pending_monitor_events = monitors_pending_monitor_events,
-               .free = NodeMonitors_free,
+       NodeMonitors mons1;
+       mons1.logger = &logger1;
+       LDKWatch mon1 {
+               .this_arg = &mons1,
+               .watch_channel = add_channel_monitor,
+               .update_channel = update_channel_monitor,
+               .release_pending_monitor_events = monitors_pending_monitor_events,
+               .free = NULL,
        };
 
        LDK::KeysManager keys1 = KeysManager_new(&node_seed, network, 0, 0);
@@ -270,14 +259,12 @@ int main() {
        LDKSecretKey node_secret1 = keys_source1->get_node_secret(keys_source1->this_arg);
 
        LDK::UserConfig config1 = UserConfig_default();
-
        LDK::ChannelManager cm1 = ChannelManager_new(network, fee_est, mon1, broadcast, logger1, KeysManager_as_KeysInterface(&keys1), config1, 0);
-       BlockNotifier_register_listener(&blocks1, ChannelManager_as_ChainListener(&cm1));
 
        LDK::CVec_ChannelDetailsZ channels = ChannelManager_list_channels(&cm1);
        assert(channels->datalen == 0);
 
-       LDK::NetGraphMsgHandler net_graph1 = NetGraphMsgHandler_new(ChainWatchInterfaceUtil_as_ChainWatchInterface(&chain1), logger1);
+       LDK::NetGraphMsgHandler net_graph1 = NetGraphMsgHandler_new(NULL, logger1);
 
        LDK::MessageHandler msg_handler1 = MessageHandler_new(ChannelManager_as_ChannelMessageHandler(&cm1), NetGraphMsgHandler_as_RoutingMessageHandler(&net_graph1));
 
@@ -298,15 +285,14 @@ int main() {
                .free = NULL,
        };
 
-       LDK::ChainWatchInterfaceUtil chain2 = ChainWatchInterfaceUtil_new(network);
-       LDK::BlockNotifier blocks2 = BlockNotifier_new(ChainWatchInterfaceUtil_as_ChainWatchInterface(&chain2));
-
-       LDKManyChannelMonitor mon2 {
-               .this_arg = new NodeMonitors { .watch_util = &chain2, .logger = &logger2 },
-               .add_monitor = add_channel_monitor,
-               .update_monitor = update_channel_monitor,
-               .get_and_clear_pending_monitor_events = monitors_pending_monitor_events,
-               .free = NodeMonitors_free,
+       NodeMonitors mons2;
+       mons2.logger = &logger2;
+       LDKWatch mon2 {
+               .this_arg = &mons2,
+               .watch_channel = add_channel_monitor,
+               .update_channel = update_channel_monitor,
+               .release_pending_monitor_events = monitors_pending_monitor_events,
+               .free = NULL,
        };
 
        memset(&node_seed, 1, 32);
@@ -320,12 +306,11 @@ int main() {
        UserConfig_set_own_channel_config(&config2, handshake_config2);
 
        LDK::ChannelManager cm2 = ChannelManager_new(network, fee_est, mon2, broadcast, logger2, KeysManager_as_KeysInterface(&keys2), config2, 0);
-       BlockNotifier_register_listener(&blocks2, ChannelManager_as_ChainListener(&cm2));
 
        LDK::CVec_ChannelDetailsZ channels2 = ChannelManager_list_channels(&cm2);
        assert(channels2->datalen == 0);
 
-       LDK::NetGraphMsgHandler net_graph2 = NetGraphMsgHandler_new(ChainWatchInterfaceUtil_as_ChainWatchInterface(&chain2), logger2);
+       LDK::NetGraphMsgHandler net_graph2 = NetGraphMsgHandler_new(NULL, logger2);
        LDK::RoutingMessageHandler net_msgs2 = NetGraphMsgHandler_as_RoutingMessageHandler(&net_graph2);
        LDK::ChannelAnnouncement chan_ann = ChannelAnnouncement_read(LDKu8slice { .data = valid_node_announcement, .datalen = sizeof(valid_node_announcement) });
        LDK::CResult_boolLightningErrorZ ann_res = net_msgs2->handle_channel_announcement(net_msgs2->this_arg, &chan_ann);
@@ -434,14 +419,31 @@ int main() {
                std::this_thread::yield();
        }
 
-       BlockNotifier_block_connected(&blocks1, LDKu8slice { .data = channel_open_block, .datalen = sizeof(channel_open_block) }, 1);
-       BlockNotifier_block_connected(&blocks2, LDKu8slice { .data = channel_open_block, .datalen = sizeof(channel_open_block) }, 1);
+       LDKCVec_C2Tuple_usizeTransactionZZ txdata { .data = (LDKC2TupleTempl_usize__Transaction*)malloc(sizeof(LDKC2Tuple_usizeTransactionZ)), .datalen = 1 };
+       *txdata.data = C2Tuple_usizeTransactionZ_new(0, LDKTransaction { .data = channel_open_tx, .datalen = sizeof(channel_open_tx), .data_is_owned = false });
+       ChannelManager_block_connected(&cm1, &channel_open_header, txdata, 1);
+
+       txdata = LDKCVec_C2Tuple_usizeTransactionZZ { .data = (LDKC2TupleTempl_usize__Transaction*)malloc(sizeof(LDKC2Tuple_usizeTransactionZ)), .datalen = 1 };
+       *txdata.data = C2Tuple_usizeTransactionZ_new(0, LDKTransaction { .data = channel_open_tx, .datalen = sizeof(channel_open_tx), .data_is_owned = false });
+       ChannelManager_block_connected(&cm2, &channel_open_header, txdata, 1);
+
+       txdata = LDKCVec_C2Tuple_usizeTransactionZZ { .data = (LDKC2TupleTempl_usize__Transaction*)malloc(sizeof(LDKC2Tuple_usizeTransactionZ)), .datalen = 1 };
+       *txdata.data = C2Tuple_usizeTransactionZ_new(0, LDKTransaction { .data = channel_open_tx, .datalen = sizeof(channel_open_tx), .data_is_owned = false });
+       mons1.ConnectBlock(&channel_open_header, 1, txdata, broadcast, fee_est);
+
+       txdata = LDKCVec_C2Tuple_usizeTransactionZZ { .data = (LDKC2TupleTempl_usize__Transaction*)malloc(sizeof(LDKC2Tuple_usizeTransactionZ)), .datalen = 1 };
+       *txdata.data = C2Tuple_usizeTransactionZ_new(0, LDKTransaction { .data = channel_open_tx, .datalen = sizeof(channel_open_tx), .data_is_owned = false });
+       mons2.ConnectBlock(&channel_open_header, 1, txdata, broadcast, fee_est);
 
-       BlockNotifier_block_connected(&blocks1, LDKu8slice { .data = block_1, .datalen = sizeof(block_1) }, 2);
-       BlockNotifier_block_connected(&blocks2, LDKu8slice { .data = block_1, .datalen = sizeof(block_1) }, 2);
+       ChannelManager_block_connected(&cm1, &header_1, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, 2);
+       ChannelManager_block_connected(&cm2, &header_1, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, 2);
+       mons1.ConnectBlock(&header_1, 2, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, broadcast, fee_est);
+       mons2.ConnectBlock(&header_1, 2, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, broadcast, fee_est);
 
-       BlockNotifier_block_connected(&blocks1, LDKu8slice { .data = block_2, .datalen = sizeof(block_2) }, 3);
-       BlockNotifier_block_connected(&blocks2, LDKu8slice { .data = block_2, .datalen = sizeof(block_2) }, 3);
+       ChannelManager_block_connected(&cm1, &header_2, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, 3);
+       ChannelManager_block_connected(&cm2, &header_2, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, 3);
+       mons1.ConnectBlock(&header_2, 3, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, broadcast, fee_est);
+       mons2.ConnectBlock(&header_2, 3, LDKCVec_C2Tuple_usizeTransactionZZ { .data = NULL, .datalen = 0 }, broadcast, fee_est);
 
        PeerManager_process_events(&net1);
        PeerManager_process_events(&net2);
@@ -548,9 +550,7 @@ int main() {
        LDKSecretKey sk;
        memset(&sk, 42, 32);
        LDKC2Tuple_u64u64Z kdiv_params;
-       kdiv_params.a = (uint64_t*) malloc(8);
-       kdiv_params.b = (uint64_t*) malloc(8);
-       *kdiv_params.a = 42;
-       *kdiv_params.b = 42;
+       kdiv_params.a = 42;
+       kdiv_params.b = 42;
        LDK::InMemoryChannelKeys keys = InMemoryChannelKeys_new(sk, sk, sk, sk, sk, random_bytes, 42, kdiv_params);
 }
index 7c4be60daa8d749de2c6957bc72758517711818d..cd246f92eafc6881e2c7c966a07d4d318c454092 100644 (file)
 #include <stdlib.h>
 
 /**
- * Used to give chain error details upstream
+ * An error when accessing the chain via [`Access`].
+ *
+ * [`Access`]: trait.Access.html
  */
-typedef enum LDKChainError {
-   /**
-    * Client doesn't support UTXO lookup (but the chain hash matches our genesis block hash)
-    */
-   LDKChainError_NotSupported,
+typedef enum LDKAccessError {
    /**
-    * Chain isn't the one watched
+    * The requested chain is unknown.
     */
-   LDKChainError_NotWatched,
+   LDKAccessError_UnknownChain,
    /**
-    * Tx doesn't exist or is unconfirmed
+    * The requested transaction doesn't exist or hasn't confirmed.
     */
-   LDKChainError_UnknownTx,
+   LDKAccessError_UnknownTx,
    /**
     * Must be last for serialization purposes
     */
-   LDKChainError_Sentinel,
-} LDKChainError;
+   LDKAccessError_Sentinel,
+} LDKAccessError;
 
 /**
  * An error enum representing a failure to persist a channel monitor update.
@@ -88,6 +86,11 @@ typedef enum LDKChannelMonitorUpdateErr {
     * Note that even when you fail a holder commitment transaction update, you must store the
     * update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor
     * broadcasts it (e.g distributed channel-monitor deployment)
+    *
+    * In case of distributed watchtowers deployment, the new version must be written to disk, as
+    * state may have been stored but rejected due to a block forcing a commitment broadcast. This
+    * storage is used to claim outputs of rejected state confirmed onchain by another watchtower,
+    * lagging behind on block processing.
     */
    LDKChannelMonitorUpdateErr_PermanentFailure,
    /**
@@ -179,6 +182,27 @@ typedef enum LDKSecp256k1Error {
    LDKSecp256k1Error_Sentinel,
 } LDKSecp256k1Error;
 
+/**
+ * A serialized transaction, in (pointer, length) form.
+ *
+ * This type optionally owns its own memory, and thus the semantics around access change based on
+ * the `data_is_owned` flag. If `data_is_owned` is set, you must call `Transaction_free` to free
+ * the underlying buffer before the object goes out of scope. If `data_is_owned` is not set, any
+ * access to the buffer after the scope in which the object was provided to you is invalid. eg,
+ * access after you return from the call in which a `!data_is_owned` `Transaction` is provided to
+ * you would be invalid.
+ *
+ * Note that, while it may change in the future, because transactions on the Rust side are stored
+ * in a deserialized form, all `Transaction`s generated on the Rust side will have `data_is_owned`
+ * set. Similarly, while it may change in the future, all `Transaction`s you pass to Rust may have
+ * `data_is_owned` either set or unset at your discretion.
+ */
+typedef struct LDKTransaction {
+   const uint8_t *data;
+   uintptr_t datalen;
+   bool data_is_owned;
+} LDKTransaction;
+
 typedef struct LDKCVecTempl_u8 {
    uint8_t *data;
    uintptr_t datalen;
@@ -195,6 +219,79 @@ typedef struct LDKTxOut {
    uint64_t value;
 } LDKTxOut;
 
+typedef struct LDKC2TupleTempl_usize__Transaction {
+   uintptr_t a;
+   LDKTransaction b;
+} LDKC2TupleTempl_usize__Transaction;
+
+typedef LDKC2TupleTempl_usize__Transaction LDKC2Tuple_usizeTransactionZ;
+
+typedef union LDKCResultPtr_u8__ChannelMonitorUpdateErr {
+   uint8_t *result;
+   LDKChannelMonitorUpdateErr *err;
+} LDKCResultPtr_u8__ChannelMonitorUpdateErr;
+
+typedef struct LDKCResultTempl_u8__ChannelMonitorUpdateErr {
+   LDKCResultPtr_u8__ChannelMonitorUpdateErr contents;
+   bool result_ok;
+} LDKCResultTempl_u8__ChannelMonitorUpdateErr;
+
+typedef LDKCResultTempl_u8__ChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ;
+
+
+
+/**
+ * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
+ * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
+ * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
+ * corrupted.
+ * Contains a human-readable error message.
+ */
+typedef struct MUST_USE_STRUCT LDKMonitorUpdateError {
+   /**
+    * 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.
+    */
+   LDKnativeMonitorUpdateError *inner;
+   bool is_owned;
+} LDKMonitorUpdateError;
+
+typedef union LDKCResultPtr_u8__MonitorUpdateError {
+   uint8_t *result;
+   LDKMonitorUpdateError *err;
+} LDKCResultPtr_u8__MonitorUpdateError;
+
+typedef struct LDKCResultTempl_u8__MonitorUpdateError {
+   LDKCResultPtr_u8__MonitorUpdateError contents;
+   bool result_ok;
+} LDKCResultTempl_u8__MonitorUpdateError;
+
+typedef LDKCResultTempl_u8__MonitorUpdateError LDKCResult_NoneMonitorUpdateErrorZ;
+
+
+
+/**
+ * A reference to a transaction output.
+ *
+ * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
+ * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
+ */
+typedef struct MUST_USE_STRUCT LDKOutPoint {
+   /**
+    * 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.
+    */
+   LDKnativeOutPoint *inner;
+   bool is_owned;
+} LDKOutPoint;
+
+typedef struct LDKC2TupleTempl_OutPoint__CVec_u8Z {
+   LDKOutPoint a;
+   LDKCVec_u8Z b;
+} LDKC2TupleTempl_OutPoint__CVec_u8Z;
+
+typedef LDKC2TupleTempl_OutPoint__CVec_u8Z LDKC2Tuple_OutPointScriptZ;
+
 /**
  * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to
  * look up the corresponding function in rust-lightning's docs.
@@ -203,23 +300,23 @@ typedef struct LDKThirtyTwoBytes {
    uint8_t data[32];
 } LDKThirtyTwoBytes;
 
-typedef struct LDKC2TupleTempl_ThirtyTwoBytes__u32 {
-   LDKThirtyTwoBytes *a;
-   uint32_t *b;
-} LDKC2TupleTempl_ThirtyTwoBytes__u32;
+typedef struct LDKCVecTempl_TxOut {
+   LDKTxOut *data;
+   uintptr_t datalen;
+} LDKCVecTempl_TxOut;
 
-typedef LDKC2TupleTempl_ThirtyTwoBytes__u32 LDKC2Tuple_Txidu32Z;
+typedef struct LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut {
+   LDKThirtyTwoBytes a;
+   LDKCVecTempl_TxOut b;
+} LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut;
 
-typedef struct LDKC2TupleTempl_CVec_u8Z__u64 {
-   LDKCVec_u8Z *a;
-   uint64_t *b;
-} LDKC2TupleTempl_CVec_u8Z__u64;
+typedef LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut LDKC2Tuple_TxidCVec_TxOutZZ;
 
-typedef LDKC2TupleTempl_CVec_u8Z__u64 LDKC2Tuple_Scriptu64Z;
+typedef LDKCVecTempl_TxOut LDKCVec_TxOutZ;
 
 typedef struct LDKC2TupleTempl_u64__u64 {
-   uint64_t *a;
-   uint64_t *b;
+   uint64_t a;
+   uint64_t b;
 } LDKC2TupleTempl_u64__u64;
 
 typedef LDKC2TupleTempl_u64__u64 LDKC2Tuple_u64u64Z;
@@ -234,8 +331,8 @@ typedef struct LDKCVecTempl_Signature {
 } LDKCVecTempl_Signature;
 
 typedef struct LDKC2TupleTempl_Signature__CVecTempl_Signature {
-   LDKSignature *a;
-   LDKCVecTempl_Signature *b;
+   LDKSignature a;
+   LDKCVecTempl_Signature b;
 } LDKC2TupleTempl_Signature__CVecTempl_Signature;
 
 typedef LDKC2TupleTempl_Signature__CVecTempl_Signature LDKC2Tuple_SignatureCVec_SignatureZZ;
@@ -315,7 +412,7 @@ typedef enum LDKAPIError_Tag {
     */
    LDKAPIError_ChannelUnavailable,
    /**
-    * An attempt to call add/update_monitor returned an Err (ie you did this!), causing the
+    * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
     * attempted action to fail.
     */
    LDKAPIError_MonitorUpdateFailed,
@@ -373,7 +470,7 @@ typedef LDKCResultTempl_u8__APIError LDKCResult_NoneAPIErrorZ;
  */
 typedef struct MUST_USE_STRUCT LDKPaymentSendFailure {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativePaymentSendFailure *inner;
@@ -392,72 +489,6 @@ typedef struct LDKCResultTempl_u8__PaymentSendFailure {
 
 typedef LDKCResultTempl_u8__PaymentSendFailure LDKCResult_NonePaymentSendFailureZ;
 
-typedef union LDKCResultPtr_u8__ChannelMonitorUpdateErr {
-   uint8_t *result;
-   LDKChannelMonitorUpdateErr *err;
-} LDKCResultPtr_u8__ChannelMonitorUpdateErr;
-
-typedef struct LDKCResultTempl_u8__ChannelMonitorUpdateErr {
-   LDKCResultPtr_u8__ChannelMonitorUpdateErr contents;
-   bool result_ok;
-} LDKCResultTempl_u8__ChannelMonitorUpdateErr;
-
-typedef LDKCResultTempl_u8__ChannelMonitorUpdateErr LDKCResult_NoneChannelMonitorUpdateErrZ;
-
-
-
-/**
- * General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
- * inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
- * means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
- * corrupted.
- * Contains a human-readable error message.
- */
-typedef struct MUST_USE_STRUCT LDKMonitorUpdateError {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeMonitorUpdateError *inner;
-   bool is_owned;
-} LDKMonitorUpdateError;
-
-typedef union LDKCResultPtr_u8__MonitorUpdateError {
-   uint8_t *result;
-   LDKMonitorUpdateError *err;
-} LDKCResultPtr_u8__MonitorUpdateError;
-
-typedef struct LDKCResultTempl_u8__MonitorUpdateError {
-   LDKCResultPtr_u8__MonitorUpdateError contents;
-   bool result_ok;
-} LDKCResultTempl_u8__MonitorUpdateError;
-
-typedef LDKCResultTempl_u8__MonitorUpdateError LDKCResult_NoneMonitorUpdateErrorZ;
-
-
-
-/**
- * A reference to a transaction output.
- *
- * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
- * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
- */
-typedef struct MUST_USE_STRUCT LDKOutPoint {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeOutPoint *inner;
-   bool is_owned;
-} LDKOutPoint;
-
-typedef struct LDKC2TupleTempl_OutPoint__CVec_u8Z {
-   LDKOutPoint *a;
-   LDKCVec_u8Z *b;
-} LDKC2TupleTempl_OutPoint__CVec_u8Z;
-
-typedef LDKC2TupleTempl_OutPoint__CVec_u8Z LDKC2Tuple_OutPointScriptZ;
-
 
 
 /**
@@ -465,7 +496,7 @@ typedef LDKC2TupleTempl_OutPoint__CVec_u8Z LDKC2Tuple_OutPointScriptZ;
  */
 typedef struct MUST_USE_STRUCT LDKChannelAnnouncement {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelAnnouncement *inner;
@@ -479,7 +510,7 @@ typedef struct MUST_USE_STRUCT LDKChannelAnnouncement {
  */
 typedef struct MUST_USE_STRUCT LDKChannelUpdate {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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;
@@ -487,9 +518,9 @@ typedef struct MUST_USE_STRUCT LDKChannelUpdate {
 } LDKChannelUpdate;
 
 typedef struct LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate {
-   LDKChannelAnnouncement *a;
-   LDKChannelUpdate *b;
-   LDKChannelUpdate *c;
+   LDKChannelAnnouncement a;
+   LDKChannelUpdate b;
+   LDKChannelUpdate c;
 } LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate;
 
 typedef LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ;
@@ -505,7 +536,7 @@ typedef LDKC3TupleTempl_ChannelAnnouncement__ChannelUpdate__ChannelUpdate LDKC3T
  */
 typedef struct MUST_USE_STRUCT LDKPeerHandleError {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativePeerHandleError *inner;
@@ -531,7 +562,7 @@ typedef LDKCResultTempl_u8__PeerHandleError LDKCResult_NonePeerHandleErrorZ;
  */
 typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeHTLCOutputInCommitment *inner;
@@ -539,8 +570,8 @@ typedef struct MUST_USE_STRUCT LDKHTLCOutputInCommitment {
 } LDKHTLCOutputInCommitment;
 
 typedef struct LDKC2TupleTempl_HTLCOutputInCommitment__Signature {
-   LDKHTLCOutputInCommitment *a;
-   LDKSignature *b;
+   LDKHTLCOutputInCommitment a;
+   LDKSignature b;
 } LDKC2TupleTempl_HTLCOutputInCommitment__Signature;
 
 typedef LDKC2TupleTempl_HTLCOutputInCommitment__Signature LDKC2Tuple_HTLCOutputInCommitmentSignatureZ;
@@ -770,7 +801,7 @@ typedef struct LDKEvent {
  */
 typedef struct MUST_USE_STRUCT LDKAcceptChannel {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeAcceptChannel *inner;
@@ -784,7 +815,7 @@ typedef struct MUST_USE_STRUCT LDKAcceptChannel {
  */
 typedef struct MUST_USE_STRUCT LDKOpenChannel {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeOpenChannel *inner;
@@ -798,7 +829,7 @@ typedef struct MUST_USE_STRUCT LDKOpenChannel {
  */
 typedef struct MUST_USE_STRUCT LDKFundingCreated {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeFundingCreated *inner;
@@ -812,7 +843,7 @@ typedef struct MUST_USE_STRUCT LDKFundingCreated {
  */
 typedef struct MUST_USE_STRUCT LDKFundingSigned {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeFundingSigned *inner;
@@ -826,7 +857,7 @@ typedef struct MUST_USE_STRUCT LDKFundingSigned {
  */
 typedef struct MUST_USE_STRUCT LDKFundingLocked {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeFundingLocked *inner;
@@ -840,7 +871,7 @@ typedef struct MUST_USE_STRUCT LDKFundingLocked {
  */
 typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeAnnouncementSignatures *inner;
@@ -855,7 +886,7 @@ typedef struct MUST_USE_STRUCT LDKAnnouncementSignatures {
  */
 typedef struct MUST_USE_STRUCT LDKCommitmentUpdate {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeCommitmentUpdate *inner;
@@ -869,7 +900,7 @@ typedef struct MUST_USE_STRUCT LDKCommitmentUpdate {
  */
 typedef struct MUST_USE_STRUCT LDKRevokeAndACK {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeRevokeAndACK *inner;
@@ -883,7 +914,7 @@ typedef struct MUST_USE_STRUCT LDKRevokeAndACK {
  */
 typedef struct MUST_USE_STRUCT LDKClosingSigned {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeClosingSigned *inner;
@@ -897,7 +928,7 @@ typedef struct MUST_USE_STRUCT LDKClosingSigned {
  */
 typedef struct MUST_USE_STRUCT LDKShutdown {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeShutdown *inner;
@@ -911,7 +942,7 @@ typedef struct MUST_USE_STRUCT LDKShutdown {
  */
 typedef struct MUST_USE_STRUCT LDKChannelReestablish {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelReestablish *inner;
@@ -925,7 +956,7 @@ typedef struct MUST_USE_STRUCT LDKChannelReestablish {
  */
 typedef struct MUST_USE_STRUCT LDKNodeAnnouncement {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeNodeAnnouncement *inner;
@@ -939,7 +970,7 @@ typedef struct MUST_USE_STRUCT LDKNodeAnnouncement {
  */
 typedef struct MUST_USE_STRUCT LDKErrorMessage {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeErrorMessage *inner;
@@ -1278,7 +1309,7 @@ typedef struct LDKLogger {
  */
 typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelHandshakeConfig *inner;
@@ -1302,7 +1333,7 @@ typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig {
  */
 typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelHandshakeLimits *inner;
@@ -1317,7 +1348,7 @@ typedef struct MUST_USE_STRUCT LDKChannelHandshakeLimits {
  */
 typedef struct MUST_USE_STRUCT LDKChannelConfig {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelConfig *inner;
@@ -1339,215 +1370,41 @@ typedef struct LDKu8slice {
  */
 typedef struct MUST_USE_STRUCT LDKUserConfig {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUserConfig *inner;
    bool is_owned;
 } LDKUserConfig;
 
-typedef union LDKCResultPtr_C2TupleTempl_CVec_u8Z__u64_____ChainError {
-   LDKC2TupleTempl_CVec_u8Z__u64 *result;
-   LDKChainError *err;
-} LDKCResultPtr_C2TupleTempl_CVec_u8Z__u64_____ChainError;
+typedef union LDKCResultPtr_TxOut__AccessError {
+   LDKTxOut *result;
+   LDKAccessError *err;
+} LDKCResultPtr_TxOut__AccessError;
 
-typedef struct LDKCResultTempl_C2TupleTempl_CVec_u8Z__u64_____ChainError {
-   LDKCResultPtr_C2TupleTempl_CVec_u8Z__u64_____ChainError contents;
+typedef struct LDKCResultTempl_TxOut__AccessError {
+   LDKCResultPtr_TxOut__AccessError contents;
    bool result_ok;
-} LDKCResultTempl_C2TupleTempl_CVec_u8Z__u64_____ChainError;
-
-typedef LDKCResultTempl_C2TupleTempl_CVec_u8Z__u64_____ChainError LDKCResult_C2Tuple_Scriptu64ZChainErrorZ;
-
-typedef struct LDKCVecTempl_usize {
-   uintptr_t *data;
-   uintptr_t datalen;
-} LDKCVecTempl_usize;
-
-typedef LDKCVecTempl_usize LDKCVec_usizeZ;
-
-/**
- * An interface to request notification of certain scripts as they appear the
- * chain.
- *
- * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
- * called from inside the library in response to ChainListener events, P2P events, or timer
- * events).
- */
-typedef struct LDKChainWatchInterface {
-   void *this_arg;
-   /**
-    * Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
-    */
-   void (*install_watch_tx)(const void *this_arg, const uint8_t (*txid)[32], LDKu8slice script_pub_key);
-   /**
-    * Provides an outpoint which must be watched for, providing any transactions which spend the
-    * given outpoint.
-    */
-   void (*install_watch_outpoint)(const void *this_arg, LDKC2Tuple_Txidu32Z outpoint, LDKu8slice out_script);
-   /**
-    * Indicates that a listener needs to see all transactions.
-    */
-   void (*watch_all_txn)(const void *this_arg);
-   /**
-    * Gets the script and value in satoshis for a given unspent transaction output given a
-    * short_channel_id (aka unspent_tx_output_identier). For BTC/tBTC channels the top three
-    * bytes are the block height, the next 3 the transaction index within the block, and the
-    * final two the output within the transaction.
-    */
-   LDKCResult_C2Tuple_Scriptu64ZChainErrorZ (*get_chain_utxo)(const void *this_arg, LDKThirtyTwoBytes genesis_hash, uint64_t unspent_tx_output_identifier);
-   /**
-    * Gets the list of transaction indices within a given block that the ChainWatchInterface is
-    * watching for.
-    */
-   LDKCVec_usizeZ (*filter_block)(const void *this_arg, LDKu8slice block);
-   /**
-    * Returns a usize that changes when the ChainWatchInterface's watched data is modified.
-    * Users of `filter_block` should pre-save a copy of `reentered`'s return value and use it to
-    * determine whether they need to re-filter a given block.
-    */
-   uintptr_t (*reentered)(const void *this_arg);
-   void (*free)(void *this_arg);
-} LDKChainWatchInterface;
-
-/**
- * A reference to a serialized transaction, in (pointer, length) form.
- * This type does *not* own its own memory, so access to it after, eg, the call in which it was
- * provided to you are invalid.
- */
-typedef struct LDKTransaction {
-   const uint8_t *data;
-   uintptr_t datalen;
-} LDKTransaction;
-
-/**
- * An interface to send a transaction to the Bitcoin network.
- */
-typedef struct LDKBroadcasterInterface {
-   void *this_arg;
-   /**
-    * Sends a transaction out to (hopefully) be mined.
-    */
-   void (*broadcast_transaction)(const void *this_arg, LDKTransaction tx);
-   void (*free)(void *this_arg);
-} LDKBroadcasterInterface;
-
-typedef struct LDKCVecTempl_CVec_u8Z {
-   LDKCVec_u8Z *data;
-   uintptr_t datalen;
-} LDKCVecTempl_CVec_u8Z;
+} LDKCResultTempl_TxOut__AccessError;
 
-typedef LDKCVecTempl_CVec_u8Z LDKCVec_TransactionZ;
-
-typedef struct LDKusizeslice {
-   const uintptr_t *data;
-   uintptr_t datalen;
-} LDKusizeslice;
-
-/**
- * A trait indicating a desire to listen for events from the chain
- */
-typedef struct LDKChainListener {
-   void *this_arg;
-   /**
-    * Notifies a listener that a block was connected.
-    *
-    * The txn_matched array should be set to references to transactions which matched the
-    * relevant installed watch outpoints/txn, or the full set of transactions in the block.
-    *
-    * Note that if txn_matched includes only matched transactions, and a new
-    * transaction/outpoint is watched during a block_connected call, the block *must* be
-    * re-scanned with the new transaction/outpoints and block_connected should be called
-    * again with the same header and (at least) the new transactions.
-    *
-    * Note that if non-new transaction/outpoints are be registered during a call, a second call
-    * *must not* happen.
-    *
-    * This also means those counting confirmations using block_connected callbacks should watch
-    * for duplicate headers and not count them towards confirmations!
-    */
-   void (*block_connected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height, LDKCVec_TransactionZ txn_matched, LDKusizeslice indexes_of_txn_matched);
-   /**
-    * Notifies a listener that a block was disconnected.
-    * Unlike block_connected, this *must* never be called twice for the same disconnect event.
-    * Height must be the one of the block which was disconnected (not new height of the best chain)
-    */
-   void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height);
-   void (*free)(void *this_arg);
-} LDKChainListener;
+typedef LDKCResultTempl_TxOut__AccessError LDKCResult_TxOutAccessErrorZ;
 
 /**
- * A trait which should be implemented to provide feerate information on a number of time
- * horizons.
- *
- * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
- * called from inside the library in response to ChainListener events, P2P events, or timer
- * events).
+ * The `Access` trait defines behavior for accessing chain data and state, such as blocks and
+ * UTXOs.
  */
-typedef struct LDKFeeEstimator {
+typedef struct LDKAccess {
    void *this_arg;
    /**
-    * Gets estimated satoshis of fee required per 1000 Weight-Units.
-    *
-    * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
-    * don't put us below 1 satoshi-per-byte).
+    * 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.
     *
-    * This translates to:
-    *  * satoshis-per-byte * 250
-    *  * ceil(satoshis-per-kbyte / 4)
+    * [`short_channel_id`]: https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#definition-of-short_channel_id
     */
-   uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, LDKConfirmationTarget confirmation_target);
+   LDKCResult_TxOutAccessErrorZ (*get_utxo)(const void *this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id);
    void (*free)(void *this_arg);
-} LDKFeeEstimator;
-
-
-
-/**
- * Utility for tracking registered txn/outpoints and checking for matches
- */
-typedef struct MUST_USE_STRUCT LDKChainWatchedUtil {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeChainWatchedUtil *inner;
-   bool is_owned;
-} LDKChainWatchedUtil;
-
-
-
-/**
- * Utility for notifying listeners about new blocks, and handling block rescans if new watch
- * data is registered.
- *
- * Rather than using a plain BlockNotifier, it is preferable to use either a BlockNotifierArc
- * or a BlockNotifierRef for conciseness. See their documentation for more details, but essentially
- * you should default to using a BlockNotifierRef, and use a BlockNotifierArc instead when you
- * require ChainListeners with static lifetimes, such as when you're using lightning-net-tokio.
- */
-typedef struct MUST_USE_STRUCT LDKBlockNotifier {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeBlockNotifier *inner;
-   bool is_owned;
-} LDKBlockNotifier;
-
-
-
-/**
- * Utility to capture some common parts of ChainWatchInterface implementors.
- *
- * Keeping a local copy of this in a ChainWatchInterface implementor is likely useful.
- */
-typedef struct MUST_USE_STRUCT LDKChainWatchInterfaceUtil {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeChainWatchInterfaceUtil *inner;
-   bool is_owned;
-} LDKChainWatchInterfaceUtil;
+} LDKAccess;
 
 
 
@@ -1556,7 +1413,7 @@ typedef struct MUST_USE_STRUCT LDKChainWatchInterfaceUtil {
  */
 typedef struct MUST_USE_STRUCT LDKChannelPublicKeys {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelPublicKeys *inner;
@@ -1573,7 +1430,7 @@ typedef struct MUST_USE_STRUCT LDKChannelPublicKeys {
  */
 typedef struct MUST_USE_STRUCT LDKPreCalculatedTxCreationKeys {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativePreCalculatedTxCreationKeys *inner;
@@ -1596,7 +1453,7 @@ typedef LDKCVecTempl_HTLCOutputInCommitment LDKCVec_HTLCOutputInCommitmentZ;
  */
 typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeHolderCommitmentTransaction *inner;
@@ -1610,7 +1467,7 @@ typedef struct MUST_USE_STRUCT LDKHolderCommitmentTransaction {
  */
 typedef struct MUST_USE_STRUCT LDKUnsignedChannelAnnouncement {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUnsignedChannelAnnouncement *inner;
@@ -1776,76 +1633,7 @@ typedef struct LDKChannelKeys {
    void (*free)(void *this_arg);
 } LDKChannelKeys;
 
-typedef struct LDKSecretKey {
-   uint8_t bytes[32];
-} LDKSecretKey;
-
-/**
- * A trait to describe an object which can get user secrets and key material.
- */
-typedef struct LDKKeysInterface {
-   void *this_arg;
-   /**
-    * Get node secret key (aka node_id or network_key)
-    */
-   LDKSecretKey (*get_node_secret)(const void *this_arg);
-   /**
-    * Get destination redeemScript to encumber static protocol exit points.
-    */
-   LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
-   /**
-    * Get shutdown_pubkey to use as PublicKey at channel closure
-    */
-   LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg);
-   /**
-    * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
-    * restarted with some stale data!
-    */
-   LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
-   /**
-    * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
-    * onion packets and for temporary channel IDs. There is no requirement that these be
-    * persisted anywhere, though they must be unique across restarts.
-    */
-   LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
-   void (*free)(void *this_arg);
-} LDKKeysInterface;
-
-
-
-/**
- * A simple implementation of ChannelKeys that just keeps the private keys in memory.
- */
-typedef struct MUST_USE_STRUCT LDKInMemoryChannelKeys {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeInMemoryChannelKeys *inner;
-   bool is_owned;
-} LDKInMemoryChannelKeys;
-
-
-
-/**
- * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key
- * and derives keys from that.
- *
- * Your node_id is seed/0'
- * ChannelMonitor closes may use seed/1'
- * Cooperative closes may use seed/2'
- * The two close keys may be needed to claim on-chain funds!
- */
-typedef struct MUST_USE_STRUCT LDKKeysManager {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeKeysManager *inner;
-   bool is_owned;
-} LDKKeysManager;
-
-
+
 
 /**
  * A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
@@ -1861,7 +1649,7 @@ typedef struct MUST_USE_STRUCT LDKKeysManager {
  */
 typedef struct MUST_USE_STRUCT LDKChannelMonitor {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelMonitor *inner;
@@ -1876,7 +1664,7 @@ typedef struct MUST_USE_STRUCT LDKChannelMonitor {
  */
 typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelMonitorUpdate *inner;
@@ -1890,7 +1678,7 @@ typedef struct MUST_USE_STRUCT LDKChannelMonitorUpdate {
  */
 typedef struct MUST_USE_STRUCT LDKMonitorEvent {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeMonitorEvent *inner;
@@ -1905,77 +1693,263 @@ typedef struct LDKCVecTempl_MonitorEvent {
 typedef LDKCVecTempl_MonitorEvent LDKCVec_MonitorEventZ;
 
 /**
- * Simple trait indicating ability to track a set of ChannelMonitors and multiplex events between
- * them. Generally should be implemented by keeping a local SimpleManyChannelMonitor and passing
- * events to it, while also taking any add/update_monitor events and passing them to some remote
- * server(s).
+ * The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
+ * blocks are connected and disconnected.
  *
- * In general, you must always have at least one local copy in memory, which must never fail to
- * update (as it is responsible for broadcasting the latest state in case the channel is closed),
- * and then persist it to various on-disk locations. If, for some reason, the in-memory copy fails
- * to update (eg out-of-memory or some other condition), you must immediately shut down without
- * taking any further action such as writing the current state to disk. This should likely be
- * accomplished via panic!() or abort().
+ * Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
+ * responsible for maintaining a set of monitors such that they can be updated accordingly as
+ * channel state changes and HTLCs are resolved. See method documentation for specific
+ * requirements.
  *
- * Note that any updates to a channel's monitor *must* be applied to each instance of the
- * channel's monitor everywhere (including remote watchtowers) *before* this function returns. If
- * an update occurs and a remote watchtower is left with old state, it may broadcast transactions
- * which we have revoked, allowing our counterparty to claim all funds in the channel!
+ * Implementations **must** ensure that updates are successfully applied and persisted upon method
+ * completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
+ * without taking any further action such as persisting the current state.
  *
- * User needs to notify implementors of ManyChannelMonitor when a new block is connected or
- * disconnected using their `block_connected` and `block_disconnected` methods. However, rather
- * than calling these methods directly, the user should register implementors as listeners to the
- * BlockNotifier and call the BlockNotifier's `block_(dis)connected` methods, which will notify
- * all registered listeners in one go.
+ * If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
+ * backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
+ * could result in a revoked transaction being broadcast, allowing the counterparty to claim all
+ * funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
+ * multiple instances.
+ *
+ * [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html
+ * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+ * [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure
  */
-typedef struct LDKManyChannelMonitor {
+typedef struct LDKWatch {
    void *this_arg;
    /**
-    * Adds a monitor for the given `funding_txo`.
-    *
-    * Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
-    * any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
-    * callbacks with the funding transaction, or any spends of it.
+    * Watches a channel identified by `funding_txo` using `monitor`.
     *
-    * Further, the implementer must also ensure that each output returned in
-    * monitor.get_outputs_to_watch() is registered to ensure that the provided monitor learns about
-    * any spends of any of the outputs.
+    * Implementations are responsible for watching the chain for the funding transaction along
+    * with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
+    * calling [`block_connected`] and [`block_disconnected`] on the monitor.
     *
-    * Any spends of outputs which should have been registered which aren't passed to
-    * ChannelMonitors via block_connected may result in FUNDS LOSS.
+    * [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch
+    * [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected
+    * [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
     */
-   LDKCResult_NoneChannelMonitorUpdateErrZ (*add_monitor)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor);
+   LDKCResult_NoneChannelMonitorUpdateErrZ (*watch_channel)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor);
    /**
-    * Updates a monitor for the given `funding_txo`.
+    * Updates a channel identified by `funding_txo` by applying `update` to its monitor.
     *
-    * Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
-    * any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
-    * callbacks with the funding transaction, or any spends of it.
+    * Implementations must call [`update_monitor`] with the given update. See
+    * [`ChannelMonitorUpdateErr`] for invariants around returning an error.
     *
-    * Further, the implementer must also ensure that each output returned in
-    * monitor.get_watch_outputs() is registered to ensure that the provided monitor learns about
-    * any spends of any of the outputs.
+    * [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor
+    * [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+    */
+   LDKCResult_NoneChannelMonitorUpdateErrZ (*update_channel)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update);
+   /**
+    * Returns any monitor events since the last call. Subsequent calls must only return new
+    * events.
+    */
+   LDKCVec_MonitorEventZ (*release_pending_monitor_events)(const void *this_arg);
+   void (*free)(void *this_arg);
+} LDKWatch;
+
+/**
+ * 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`].
+ *
+ * [`Watch`]: trait.Watch.html
+ * [`TemporaryFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.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 {
+   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], LDKu8slice script_pubkey);
+   /**
+    * Registers interest in spends of a transaction output identified by `outpoint` having
+    * `script_pubkey` as the spending condition.
+    */
+   void (*register_output)(const void *this_arg, const LDKOutPoint *outpoint, LDKu8slice script_pubkey);
+   void (*free)(void *this_arg);
+} LDKFilter;
+
+/**
+ * An interface to send a transaction to the Bitcoin network.
+ */
+typedef struct LDKBroadcasterInterface {
+   void *this_arg;
+   /**
+    * Sends a transaction out to (hopefully) be mined.
+    */
+   void (*broadcast_transaction)(const void *this_arg, LDKTransaction tx);
+   void (*free)(void *this_arg);
+} LDKBroadcasterInterface;
+
+/**
+ * A trait which should be implemented to provide feerate information on a number of time
+ * horizons.
+ *
+ * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
+ * called from inside the library in response to chain events, P2P events, or timer events).
+ */
+typedef struct LDKFeeEstimator {
+   void *this_arg;
+   /**
+    * Gets estimated satoshis of fee required per 1000 Weight-Units.
     *
-    * Any spends of outputs which should have been registered which aren't passed to
-    * ChannelMonitors via block_connected may result in FUNDS LOSS.
+    * Must be no smaller than 253 (ie 1 satoshi-per-byte rounded up to ensure later round-downs
+    * don't put us below 1 satoshi-per-byte).
     *
-    * In case of distributed watchtowers deployment, even if an Err is return, the new version
-    * must be written to disk, as state may have been stored but rejected due to a block forcing
-    * a commitment broadcast. This storage is used to claim outputs of rejected state confirmed
-    * onchain by another watchtower, lagging behind on block processing.
+    * This translates to:
+    *  * satoshis-per-byte * 250
+    *  * ceil(satoshis-per-kbyte / 4)
     */
-   LDKCResult_NoneChannelMonitorUpdateErrZ (*update_monitor)(const void *this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate monitor);
+   uint32_t (*get_est_sat_per_1000_weight)(const void *this_arg, LDKConfirmationTarget confirmation_target);
+   void (*free)(void *this_arg);
+} LDKFeeEstimator;
+
+
+
+/**
+ * An implementation of [`chain::Watch`] for monitoring channels.
+ *
+ * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by
+ * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally
+ * or used independently to monitor channels remotely. See the [module-level documentation] for
+ * details.
+ *
+ * [`chain::Watch`]: ../trait.Watch.html
+ * [`ChannelManager`]: ../../ln/channelmanager/struct.ChannelManager.html
+ * [module-level documentation]: index.html
+ */
+typedef struct MUST_USE_STRUCT LDKChainMonitor {
    /**
-    * Used by ChannelManager to get list of HTLC resolved onchain and which needed to be updated
-    * with success or failure.
-    *
-    * You should probably just call through to
-    * ChannelMonitor::get_and_clear_pending_monitor_events() for each ChannelMonitor and return
-    * the full list.
+    * 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.
     */
-   LDKCVec_MonitorEventZ (*get_and_clear_pending_monitor_events)(const void *this_arg);
+   LDKnativeChainMonitor *inner;
+   bool is_owned;
+} LDKChainMonitor;
+
+typedef struct LDKCVecTempl_C2TupleTempl_usize__Transaction {
+   LDKC2TupleTempl_usize__Transaction *data;
+   uintptr_t datalen;
+} LDKCVecTempl_C2TupleTempl_usize__Transaction;
+
+typedef LDKCVecTempl_C2TupleTempl_usize__Transaction LDKCVec_C2Tuple_usizeTransactionZZ;
+
+
+
+/**
+ * Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
+ * chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
+ * preimage claim backward will lead to loss of funds.
+ *
+ * [`chain::Watch`]: ../trait.Watch.html
+ */
+typedef struct MUST_USE_STRUCT LDKHTLCUpdate {
+   /**
+    * 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.
+    */
+   LDKnativeHTLCUpdate *inner;
+   bool is_owned;
+} LDKHTLCUpdate;
+
+typedef struct LDKCVecTempl_Transaction {
+   LDKTransaction *data;
+   uintptr_t datalen;
+} LDKCVecTempl_Transaction;
+
+typedef LDKCVecTempl_Transaction LDKCVec_TransactionZ;
+
+typedef struct LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut {
+   LDKC2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut *data;
+   uintptr_t datalen;
+} LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut;
+
+typedef LDKCVecTempl_C2TupleTempl_ThirtyTwoBytes__CVecTempl_TxOut LDKCVec_C2Tuple_TxidCVec_TxOutZZZ;
+
+typedef struct LDKSecretKey {
+   uint8_t bytes[32];
+} LDKSecretKey;
+
+/**
+ * A trait to describe an object which can get user secrets and key material.
+ */
+typedef struct LDKKeysInterface {
+   void *this_arg;
+   /**
+    * Get node secret key (aka node_id or network_key)
+    */
+   LDKSecretKey (*get_node_secret)(const void *this_arg);
+   /**
+    * Get destination redeemScript to encumber static protocol exit points.
+    */
+   LDKCVec_u8Z (*get_destination_script)(const void *this_arg);
+   /**
+    * Get shutdown_pubkey to use as PublicKey at channel closure
+    */
+   LDKPublicKey (*get_shutdown_pubkey)(const void *this_arg);
+   /**
+    * Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
+    * restarted with some stale data!
+    */
+   LDKChannelKeys (*get_channel_keys)(const void *this_arg, bool inbound, uint64_t channel_value_satoshis);
+   /**
+    * Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
+    * onion packets and for temporary channel IDs. There is no requirement that these be
+    * persisted anywhere, though they must be unique across restarts.
+    */
+   LDKThirtyTwoBytes (*get_secure_random_bytes)(const void *this_arg);
    void (*free)(void *this_arg);
-} LDKManyChannelMonitor;
+} LDKKeysInterface;
+
+
+
+/**
+ * A simple implementation of ChannelKeys that just keeps the private keys in memory.
+ */
+typedef struct MUST_USE_STRUCT LDKInMemoryChannelKeys {
+   /**
+    * 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.
+    */
+   LDKnativeInMemoryChannelKeys *inner;
+   bool is_owned;
+} LDKInMemoryChannelKeys;
+
+
+
+/**
+ * Simple KeysInterface implementor that takes a 32-byte seed for use as a BIP 32 extended key
+ * and derives keys from that.
+ *
+ * Your node_id is seed/0'
+ * ChannelMonitor closes may use seed/1'
+ * Cooperative closes may use seed/2'
+ * The two close keys may be needed to claim on-chain funds!
+ */
+typedef struct MUST_USE_STRUCT LDKKeysManager {
+   /**
+    * 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.
+    */
+   LDKnativeKeysManager *inner;
+   bool is_owned;
+} LDKKeysManager;
 
 
 
@@ -1993,7 +1967,7 @@ typedef struct LDKManyChannelMonitor {
  *
  * Note that you can be a bit lazier about writing out ChannelManager than you can be with
  * ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
- * returning from ManyChannelMonitor::add_/update_monitor, with ChannelManagers, writing updates
+ * returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
  * happens out-of-band (and will prevent any other ChannelManager operations from occurring during
  * the serialization process). If the deserialized version is out-of-date compared to the
  * ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
@@ -2019,7 +1993,7 @@ typedef struct LDKManyChannelMonitor {
  */
 typedef struct MUST_USE_STRUCT LDKChannelManager {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelManager *inner;
@@ -2033,7 +2007,7 @@ typedef struct MUST_USE_STRUCT LDKChannelManager {
  */
 typedef struct MUST_USE_STRUCT LDKChannelDetails {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelDetails *inner;
@@ -2047,7 +2021,7 @@ typedef struct MUST_USE_STRUCT LDKChannelDetails {
  */
 typedef struct MUST_USE_STRUCT LDKInitFeatures {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeInitFeatures *inner;
@@ -2069,7 +2043,7 @@ typedef LDKCVecTempl_ChannelDetails LDKCVec_ChannelDetailsZ;
  */
 typedef struct MUST_USE_STRUCT LDKRoute {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeRoute *inner;
@@ -2166,7 +2140,7 @@ typedef LDKCVecTempl_NetAddress LDKCVec_NetAddressZ;
  */
 typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUpdateAddHTLC *inner;
@@ -2180,7 +2154,7 @@ typedef struct MUST_USE_STRUCT LDKUpdateAddHTLC {
  */
 typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUpdateFulfillHTLC *inner;
@@ -2194,7 +2168,7 @@ typedef struct MUST_USE_STRUCT LDKUpdateFulfillHTLC {
  */
 typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUpdateFailHTLC *inner;
@@ -2208,7 +2182,7 @@ typedef struct MUST_USE_STRUCT LDKUpdateFailHTLC {
  */
 typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUpdateFailMalformedHTLC *inner;
@@ -2222,7 +2196,7 @@ typedef struct MUST_USE_STRUCT LDKUpdateFailMalformedHTLC {
  */
 typedef struct MUST_USE_STRUCT LDKCommitmentSigned {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeCommitmentSigned *inner;
@@ -2236,7 +2210,7 @@ typedef struct MUST_USE_STRUCT LDKCommitmentSigned {
  */
 typedef struct MUST_USE_STRUCT LDKUpdateFee {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUpdateFee *inner;
@@ -2250,7 +2224,7 @@ typedef struct MUST_USE_STRUCT LDKUpdateFee {
  */
 typedef struct MUST_USE_STRUCT LDKInit {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeInit *inner;
@@ -2361,15 +2335,14 @@ typedef struct LDKChannelMessageHandler {
  *    This may result in closing some Channels if the ChannelMonitor is newer than the stored
  *    ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
  * 3) Register all relevant ChannelMonitor outpoints with your chain watch mechanism using
- *    ChannelMonitor::get_monitored_outpoints and ChannelMonitor::get_funding_txo().
+ *    ChannelMonitor::get_outputs_to_watch() and ChannelMonitor::get_funding_txo().
  * 4) Reconnect blocks on your ChannelMonitors.
- * 5) Move the ChannelMonitors into your local ManyChannelMonitor.
+ * 5) Move the ChannelMonitors into your local chain::Watch.
  * 6) Disconnect/connect blocks on the ChannelManager.
- * 7) Register the new ChannelManager with your ChainWatchInterface.
  */
 typedef struct MUST_USE_STRUCT LDKChannelManagerReadArgs {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelManagerReadArgs *inner;
@@ -2385,27 +2358,12 @@ typedef LDKCVecTempl_ChannelMonitor LDKCVec_ChannelMonitorZ;
 
 
 
-/**
- * Simple structure send back by ManyChannelMonitor in case of HTLC detected onchain from a
- * forward channel and from which info are needed to update HTLC in a backward channel.
- */
-typedef struct MUST_USE_STRUCT LDKHTLCUpdate {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeHTLCUpdate *inner;
-   bool is_owned;
-} LDKHTLCUpdate;
-
-
-
 /**
  * An error in decoding a message or struct.
  */
 typedef struct MUST_USE_STRUCT LDKDecodeError {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeDecodeError *inner;
@@ -2419,7 +2377,7 @@ typedef struct MUST_USE_STRUCT LDKDecodeError {
  */
 typedef struct MUST_USE_STRUCT LDKPing {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativePing *inner;
@@ -2433,7 +2391,7 @@ typedef struct MUST_USE_STRUCT LDKPing {
  */
 typedef struct MUST_USE_STRUCT LDKPong {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativePong *inner;
@@ -2450,7 +2408,7 @@ typedef struct MUST_USE_STRUCT LDKPong {
  */
 typedef struct MUST_USE_STRUCT LDKDataLossProtect {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeDataLossProtect *inner;
@@ -2464,7 +2422,7 @@ typedef struct MUST_USE_STRUCT LDKDataLossProtect {
  */
 typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUnsignedNodeAnnouncement *inner;
@@ -2473,12 +2431,40 @@ typedef struct MUST_USE_STRUCT LDKUnsignedNodeAnnouncement {
 
 
 
+/**
+ * Features used within a `node_announcement` message.
+ */
+typedef struct MUST_USE_STRUCT LDKNodeFeatures {
+   /**
+    * 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.
+    */
+   LDKnativeNodeFeatures *inner;
+   bool is_owned;
+} LDKNodeFeatures;
+
+
+
+/**
+ * Features used within a `channel_announcement` message.
+ */
+typedef struct MUST_USE_STRUCT LDKChannelFeatures {
+   /**
+    * 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.
+    */
+   LDKnativeChannelFeatures *inner;
+   bool is_owned;
+} LDKChannelFeatures;
+
+
+
 /**
  * The unsigned part of a channel_update
  */
 typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeUnsignedChannelUpdate *inner;
@@ -2495,7 +2481,7 @@ typedef struct MUST_USE_STRUCT LDKUnsignedChannelUpdate {
  */
 typedef struct MUST_USE_STRUCT LDKQueryChannelRange {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeQueryChannelRange *inner;
@@ -2515,7 +2501,7 @@ typedef struct MUST_USE_STRUCT LDKQueryChannelRange {
  */
 typedef struct MUST_USE_STRUCT LDKReplyChannelRange {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeReplyChannelRange *inner;
@@ -2543,7 +2529,7 @@ typedef LDKCVecTempl_u64 LDKCVec_u64Z;
  */
 typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeQueryShortChannelIds *inner;
@@ -2560,7 +2546,7 @@ typedef struct MUST_USE_STRUCT LDKQueryShortChannelIds {
  */
 typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeReplyShortChannelIdsEnd *inner;
@@ -2576,7 +2562,7 @@ typedef struct MUST_USE_STRUCT LDKReplyShortChannelIdsEnd {
  */
 typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeGossipTimestampFilter *inner;
@@ -2590,7 +2576,7 @@ typedef struct MUST_USE_STRUCT LDKGossipTimestampFilter {
  */
 typedef struct MUST_USE_STRUCT LDKLightningError {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeLightningError *inner;
@@ -2702,7 +2688,7 @@ typedef struct LDKRoutingMessageHandler {
  */
 typedef struct MUST_USE_STRUCT LDKMessageHandler {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeMessageHandler *inner;
@@ -2769,7 +2755,7 @@ typedef struct LDKSocketDescriptor {
  */
 typedef struct MUST_USE_STRUCT LDKPeerManager {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativePeerManager *inner;
@@ -2848,7 +2834,7 @@ typedef LDKCResultTempl_PublicKey__Secp256k1Error LDKCResult_PublicKeySecpErrorZ
  */
 typedef struct MUST_USE_STRUCT LDKTxCreationKeys {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeTxCreationKeys *inner;
@@ -2863,44 +2849,16 @@ typedef union LDKCResultPtr_TxCreationKeys__Secp256k1Error {
 typedef struct LDKCResultTempl_TxCreationKeys__Secp256k1Error {
    LDKCResultPtr_TxCreationKeys__Secp256k1Error contents;
    bool result_ok;
-} LDKCResultTempl_TxCreationKeys__Secp256k1Error;
-
-typedef LDKCResultTempl_TxCreationKeys__Secp256k1Error LDKCResult_TxCreationKeysSecpErrorZ;
-
-typedef struct LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature {
-   LDKC2TupleTempl_HTLCOutputInCommitment__Signature *data;
-   uintptr_t datalen;
-} LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature;
-
-typedef LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ;
-
-
-
-/**
- * Features used within a `node_announcement` message.
- */
-typedef struct MUST_USE_STRUCT LDKNodeFeatures {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeNodeFeatures *inner;
-   bool is_owned;
-} LDKNodeFeatures;
+} LDKCResultTempl_TxCreationKeys__Secp256k1Error;
 
+typedef LDKCResultTempl_TxCreationKeys__Secp256k1Error LDKCResult_TxCreationKeysSecpErrorZ;
 
+typedef struct LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature {
+   LDKC2TupleTempl_HTLCOutputInCommitment__Signature *data;
+   uintptr_t datalen;
+} LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature;
 
-/**
- * Features used within a `channel_announcement` message.
- */
-typedef struct MUST_USE_STRUCT LDKChannelFeatures {
-   /**
-    * Nearly everyhwere, inner must be non-null, however in places where
-    * the Rust equivalent takes an Option, it may be set to null to indicate None.
-    */
-   LDKnativeChannelFeatures *inner;
-   bool is_owned;
-} LDKChannelFeatures;
+typedef LDKCVecTempl_C2TupleTempl_HTLCOutputInCommitment__Signature LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ;
 
 
 
@@ -2909,7 +2867,7 @@ typedef struct MUST_USE_STRUCT LDKChannelFeatures {
  */
 typedef struct MUST_USE_STRUCT LDKRouteHop {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeRouteHop *inner;
@@ -2935,7 +2893,7 @@ typedef LDKCVecTempl_CVecTempl_RouteHop LDKCVec_CVec_RouteHopZZ;
  */
 typedef struct MUST_USE_STRUCT LDKRouteHint {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeRouteHint *inner;
@@ -2949,7 +2907,7 @@ typedef struct MUST_USE_STRUCT LDKRouteHint {
  */
 typedef struct MUST_USE_STRUCT LDKRoutingFees {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeRoutingFees *inner;
@@ -2975,7 +2933,7 @@ typedef LDKCResultTempl_Route__LightningError LDKCResult_RouteLightningErrorZ;
  */
 typedef struct MUST_USE_STRUCT LDKNetworkGraph {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeNetworkGraph *inner;
@@ -2998,7 +2956,7 @@ typedef LDKCVecTempl_RouteHint LDKCVec_RouteHintZ;
  */
 typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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;
@@ -3016,7 +2974,7 @@ typedef struct MUST_USE_STRUCT LDKLockedNetworkGraph {
  */
 typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeNetGraphMsgHandler *inner;
@@ -3031,7 +2989,7 @@ typedef struct MUST_USE_STRUCT LDKNetGraphMsgHandler {
  */
 typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeDirectionalChannelInfo *inner;
@@ -3046,7 +3004,7 @@ typedef struct MUST_USE_STRUCT LDKDirectionalChannelInfo {
  */
 typedef struct MUST_USE_STRUCT LDKChannelInfo {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeChannelInfo *inner;
@@ -3060,7 +3018,7 @@ typedef struct MUST_USE_STRUCT LDKChannelInfo {
  */
 typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * Nearly everywhere, inner must be non-null, however in places where
     * the Rust equivalent takes an Option, it may be set to null to indicate None.
     */
    LDKnativeNodeAnnouncementInfo *inner;
@@ -3074,7 +3032,7 @@ typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo {
  */
 typedef struct MUST_USE_STRUCT LDKNodeInfo {
    /**
-    * Nearly everyhwere, inner must be non-null, however in places where
+    * 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.
     */
    LDKnativeNodeInfo *inner;
@@ -3087,21 +3045,15 @@ extern const void (*C2Tuple_HTLCOutputInCommitmentSignatureZ_free)(LDKC2Tuple_HT
 
 extern const void (*C2Tuple_OutPointScriptZ_free)(LDKC2Tuple_OutPointScriptZ);
 
-extern const void (*C2Tuple_Scriptu64Z_free)(LDKC2Tuple_Scriptu64Z);
-
 extern const void (*C2Tuple_SignatureCVec_SignatureZZ_free)(LDKC2Tuple_SignatureCVec_SignatureZZ);
 
-extern const void (*C2Tuple_Txidu32Z_free)(LDKC2Tuple_Txidu32Z);
+extern const void (*C2Tuple_TxidCVec_TxOutZZ_free)(LDKC2Tuple_TxidCVec_TxOutZZ);
 
 extern const void (*C2Tuple_u64u64Z_free)(LDKC2Tuple_u64u64Z);
 
-extern const void (*C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free)(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ);
-
-extern const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ (*CResult_C2Tuple_Scriptu64ZChainErrorZ_err)(LDKChainError);
+extern const void (*C2Tuple_usizeTransactionZ_free)(LDKC2Tuple_usizeTransactionZ);
 
-extern const void (*CResult_C2Tuple_Scriptu64ZChainErrorZ_free)(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ);
-
-extern const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ (*CResult_C2Tuple_Scriptu64ZChainErrorZ_ok)(LDKC2Tuple_Scriptu64Z);
+extern const void (*C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free)(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ);
 
 extern const void (*CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free)(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ);
 
@@ -3165,6 +3117,12 @@ extern const void (*CResult_TxCreationKeysSecpErrorZ_free)(LDKCResult_TxCreation
 
 extern const LDKCResult_TxCreationKeysSecpErrorZ (*CResult_TxCreationKeysSecpErrorZ_ok)(LDKTxCreationKeys);
 
+extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_err)(LDKAccessError);
+
+extern const void (*CResult_TxOutAccessErrorZ_free)(LDKCResult_TxOutAccessErrorZ);
+
+extern const LDKCResult_TxOutAccessErrorZ (*CResult_TxOutAccessErrorZ_ok)(LDKTxOut);
+
 extern const LDKCResult_boolLightningErrorZ (*CResult_boolLightningErrorZ_err)(LDKLightningError);
 
 extern const void (*CResult_boolLightningErrorZ_free)(LDKCResult_boolLightningErrorZ);
@@ -3179,6 +3137,10 @@ extern const LDKCResult_boolPeerHandleErrorZ (*CResult_boolPeerHandleErrorZ_ok)(
 
 extern const void (*CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free)(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ);
 
+extern const void (*CVec_C2Tuple_TxidCVec_TxOutZZZ_free)(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ);
+
+extern const void (*CVec_C2Tuple_usizeTransactionZZ_free)(LDKCVec_C2Tuple_usizeTransactionZZ);
+
 extern const void (*CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free)(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ);
 
 extern const void (*CVec_CVec_RouteHopZZ_free)(LDKCVec_CVec_RouteHopZZ);
@@ -3211,6 +3173,8 @@ extern const void (*CVec_SpendableOutputDescriptorZ_free)(LDKCVec_SpendableOutpu
 
 extern const void (*CVec_TransactionZ_free)(LDKCVec_TransactionZ);
 
+extern const void (*CVec_TxOutZ_free)(LDKCVec_TxOutZ);
+
 extern const void (*CVec_UpdateAddHTLCZ_free)(LDKCVec_UpdateAddHTLCZ);
 
 extern const void (*CVec_UpdateFailHTLCZ_free)(LDKCVec_UpdateFailHTLCZ);
@@ -3223,15 +3187,21 @@ extern const void (*CVec_u64Z_free)(LDKCVec_u64Z);
 
 extern const void (*CVec_u8Z_free)(LDKCVec_u8Z);
 
-extern const void (*CVec_usizeZ_free)(LDKCVec_usizeZ);
-
 extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT;
 
+void Transaction_free(LDKTransaction _res);
+
 void TxOut_free(LDKTxOut _res);
 
-LDKC2Tuple_Txidu32Z C2Tuple_Txidu32Z_new(LDKThirtyTwoBytes a, uint32_t b);
+LDKC2Tuple_usizeTransactionZ C2Tuple_usizeTransactionZ_new(uintptr_t a, LDKTransaction b);
+
+LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void);
+
+LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void);
+
+LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(LDKOutPoint a, LDKCVec_u8Z b);
 
-LDKC2Tuple_Scriptu64Z C2Tuple_Scriptu64Z_new(LDKCVec_u8Z a, uint64_t b);
+LDKC2Tuple_TxidCVec_TxOutZZ C2Tuple_TxidCVec_TxOutZZ_new(LDKThirtyTwoBytes a, LDKCVec_TxOutZ b);
 
 LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_new(uint64_t a, uint64_t b);
 
@@ -3247,12 +3217,6 @@ LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void);
 
 LDKCResult_NonePaymentSendFailureZ CResult_NonePaymentSendFailureZ_ok(void);
 
-LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_ok(void);
-
-LDKCResult_NoneMonitorUpdateErrorZ CResult_NoneMonitorUpdateErrorZ_ok(void);
-
-LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_new(LDKOutPoint a, LDKCVec_u8Z b);
-
 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(LDKChannelAnnouncement a, LDKChannelUpdate b, LDKChannelUpdate c);
 
 LDKCResult_NonePeerHandleErrorZ CResult_NonePeerHandleErrorZ_ok(void);
@@ -3682,101 +3646,183 @@ MUST_USE_RES LDKUserConfig UserConfig_default(void);
 /**
  * Calls the free function if one is set
  */
-void ChainWatchInterface_free(LDKChainWatchInterface this_ptr);
+void Access_free(LDKAccess this_ptr);
 
 /**
  * Calls the free function if one is set
  */
-void BroadcasterInterface_free(LDKBroadcasterInterface this_ptr);
+void Watch_free(LDKWatch this_ptr);
+
+/**
+ * Calls the free function if one is set
+ */
+void Filter_free(LDKFilter this_ptr);
 
 /**
  * Calls the free function if one is set
  */
-void ChainListener_free(LDKChainListener this_ptr);
+void BroadcasterInterface_free(LDKBroadcasterInterface this_ptr);
 
 /**
  * Calls the free function if one is set
  */
 void FeeEstimator_free(LDKFeeEstimator this_ptr);
 
-void ChainWatchedUtil_free(LDKChainWatchedUtil this_ptr);
+void ChainMonitor_free(LDKChainMonitor this_ptr);
 
 /**
- * Constructs an empty (watches nothing) ChainWatchedUtil
+ * Dispatches to per-channel monitors, which are responsible for updating their on-chain view
+ * of a channel and reacting accordingly based on transactions in the connected block. See
+ * [`ChannelMonitor::block_connected`] for details. Any HTLCs that were resolved on chain will
+ * be returned by [`chain::Watch::release_pending_monitor_events`].
+ *
+ * Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch. Subsequent
+ * calls must not exclude any transactions matching the new outputs nor any in-block
+ * descendants of such transactions. It is not necessary to re-fetch the block to obtain
+ * updated `txdata`.
+ *
+ * [`ChannelMonitor::block_connected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_connected
+ * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
+ * [`chain::Filter`]: ../trait.Filter.html
  */
-MUST_USE_RES LDKChainWatchedUtil ChainWatchedUtil_new(void);
+void ChainMonitor_block_connected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height);
 
 /**
- * Registers a tx for monitoring, returning true if it was a new tx and false if we'd already
- * been watching for it.
+ * Dispatches to per-channel monitors, which are responsible for updating their on-chain view
+ * of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for
+ * details.
+ *
+ * [`ChannelMonitor::block_disconnected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
  */
-MUST_USE_RES bool ChainWatchedUtil_register_tx(LDKChainWatchedUtil *this_arg, const uint8_t (*txid)[32], LDKu8slice script_pub_key);
+void ChainMonitor_block_disconnected(const LDKChainMonitor *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height);
 
 /**
- * Registers an outpoint for monitoring, returning true if it was a new outpoint and false if
- * we'd already been watching for it
+ * Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels.
+ *
+ * When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor
+ * will call back to it indicating transactions and outputs of interest. This allows clients to
+ * 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.
+ *
+ * [`chain::Filter`]: ../trait.Filter.html
  */
-MUST_USE_RES bool ChainWatchedUtil_register_outpoint(LDKChainWatchedUtil *this_arg, LDKC2Tuple_Txidu32Z outpoint, LDKu8slice _script_pub_key);
+MUST_USE_RES LDKChainMonitor ChainMonitor_new(LDKFilter *chain_source, LDKBroadcasterInterface broadcaster, LDKLogger logger, LDKFeeEstimator feeest);
+
+LDKWatch ChainMonitor_as_Watch(const LDKChainMonitor *this_arg);
+
+LDKEventsProvider ChainMonitor_as_EventsProvider(const LDKChainMonitor *this_arg);
+
+void ChannelMonitorUpdate_free(LDKChannelMonitorUpdate this_ptr);
 
 /**
- * Sets us to match all transactions, returning true if this is a new setting and false if
- * we'd already been set to match everything.
+ * The sequence number of this update. Updates *must* be replayed in-order according to this
+ * sequence number (and updates may panic if they are not). The update_id values are strictly
+ * increasing and increase by one for each new update.
+ *
+ * This sequence number is also used to track up to which points updates which returned
+ * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+ * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
  */
-MUST_USE_RES bool ChainWatchedUtil_watch_all(LDKChainWatchedUtil *this_arg);
+uint64_t ChannelMonitorUpdate_get_update_id(const LDKChannelMonitorUpdate *this_ptr);
 
 /**
- * Checks if a given transaction matches the current filter.
+ * The sequence number of this update. Updates *must* be replayed in-order according to this
+ * sequence number (and updates may panic if they are not). The update_id values are strictly
+ * increasing and increase by one for each new update.
+ *
+ * This sequence number is also used to track up to which points updates which returned
+ * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+ * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
  */
-MUST_USE_RES bool ChainWatchedUtil_does_match_tx(const LDKChainWatchedUtil *this_arg, LDKTransaction tx);
+void ChannelMonitorUpdate_set_update_id(LDKChannelMonitorUpdate *this_ptr, uint64_t val);
+
+LDKCVec_u8Z ChannelMonitorUpdate_write(const LDKChannelMonitorUpdate *obj);
+
+LDKChannelMonitorUpdate ChannelMonitorUpdate_read(LDKu8slice ser);
+
+void MonitorUpdateError_free(LDKMonitorUpdateError this_ptr);
+
+void MonitorEvent_free(LDKMonitorEvent this_ptr);
+
+void HTLCUpdate_free(LDKHTLCUpdate this_ptr);
+
+LDKCVec_u8Z HTLCUpdate_write(const LDKHTLCUpdate *obj);
+
+LDKHTLCUpdate HTLCUpdate_read(LDKu8slice ser);
+
+void ChannelMonitor_free(LDKChannelMonitor this_ptr);
 
-void BlockNotifier_free(LDKBlockNotifier this_ptr);
+/**
+ * Updates a ChannelMonitor on the basis of some new information provided by the Channel
+ * itself.
+ *
+ * panics if the given update is not the next update by update_id.
+ */
+MUST_USE_RES LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(LDKChannelMonitor *this_arg, LDKChannelMonitorUpdate updates, const LDKBroadcasterInterface *broadcaster, const LDKLogger *logger);
 
 /**
- * Constructs a new BlockNotifier without any listeners.
+ * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
+ * ChannelMonitor.
  */
-MUST_USE_RES LDKBlockNotifier BlockNotifier_new(LDKChainWatchInterface chain_monitor);
+MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const LDKChannelMonitor *this_arg);
 
 /**
- * Register the given listener to receive events.
+ * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
  */
-void BlockNotifier_register_listener(const LDKBlockNotifier *this_arg, LDKChainListener listener);
+MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const LDKChannelMonitor *this_arg);
 
 /**
- * Notify listeners that a block was connected given a full, unfiltered block.
+ * Get the list of HTLCs who's status has been updated on chain. This should be called by
+ * ChannelManager via [`chain::Watch::release_pending_monitor_events`].
  *
- * Handles re-scanning the block and calling block_connected again if listeners register new
- * watch data during the callbacks for you (see ChainListener::block_connected for more info).
+ * [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
  */
-void BlockNotifier_block_connected(const LDKBlockNotifier *this_arg, LDKu8slice block, uint32_t height);
+MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(LDKChannelMonitor *this_arg);
 
 /**
- * Notify listeners that a block was connected, given pre-filtered list of transactions in the
- * block which matched the filter (probably using does_match_tx).
+ * Gets the list of pending events which were generated by previous actions, clearing the list
+ * in the process.
  *
- * Returns true if notified listeners registered additional watch data (implying that the
- * block must be re-scanned and this function called again prior to further block_connected
- * calls, see ChainListener::block_connected for more info).
+ * This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to
+ * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
+ * no internal locking in ChannelMonitors.
  */
-MUST_USE_RES bool BlockNotifier_block_connected_checked(const LDKBlockNotifier *this_arg, const uint8_t (*header)[80], uint32_t height, LDKCVec_TransactionZ txn_matched, LDKusizeslice indexes_of_txn_matched);
+MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChannelMonitor *this_arg);
 
 /**
- * Notify listeners that a block was disconnected.
+ * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of
+ * the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of
+ * fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows
+ * a higher revocation secret than the holder commitment number we are aware of. Broadcasting these
+ * transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to
+ * broadcast them if counterparty don't close channel with his higher commitment transaction after a
+ * substantial amount of time (a month or even a year) to get back funds. Best may be to contact
+ * out-of-band the other node operator to coordinate with him if option is available to you.
+ * In any-case, choice is up to the user.
  */
-void BlockNotifier_block_disconnected(const LDKBlockNotifier *this_arg, const uint8_t (*header)[80], uint32_t disconnected_height);
-
-void ChainWatchInterfaceUtil_free(LDKChainWatchInterfaceUtil this_ptr);
-
-LDKChainWatchInterface ChainWatchInterfaceUtil_as_ChainWatchInterface(const LDKChainWatchInterfaceUtil *this_arg);
+MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger);
 
 /**
- * Creates a new ChainWatchInterfaceUtil for the given network
+ * Processes transactions in a newly connected block, which may result in any of the following:
+ * - update the monitor's state against resolved HTLCs
+ * - punish the counterparty in the case of seeing a revoked commitment transaction
+ * - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration
+ * - detect settled outputs for later spending
+ * - schedule and bump any in-flight claims
+ *
+ * Returns any new outputs to watch from `txdata`; after called, these are also included in
+ * [`get_outputs_to_watch`].
+ *
+ * [`get_outputs_to_watch`]: #method.get_outputs_to_watch
  */
-MUST_USE_RES LDKChainWatchInterfaceUtil ChainWatchInterfaceUtil_new(LDKNetwork network);
+MUST_USE_RES LDKCVec_C2Tuple_TxidCVec_TxOutZZZ ChannelMonitor_block_connected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger);
 
 /**
- * Checks if a given transaction matches the current filter.
+ * Determines if the disconnected block contained any transactions of interest and updates
+ * appropriately.
  */
-MUST_USE_RES bool ChainWatchInterfaceUtil_does_match_tx(const LDKChainWatchInterfaceUtil *this_arg, LDKTransaction tx);
+void ChannelMonitor_block_disconnected(LDKChannelMonitor *this_arg, const uint8_t (*header)[80], uint32_t height, LDKBroadcasterInterface broadcaster, LDKFeeEstimator fee_estimator, LDKLogger logger);
 
 void OutPoint_free(LDKOutPoint this_ptr);
 
@@ -4082,12 +4128,8 @@ void PaymentSendFailure_free(LDKPaymentSendFailure this_ptr);
  *
  * Users need to notify the new ChannelManager when a new block is connected or
  * disconnected using its `block_connected` and `block_disconnected` methods.
- * However, rather than calling these methods directly, the user should register
- * the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
- * `block_(dis)connected` methods, which will notify all registered listeners in one
- * go.
  */
-MUST_USE_RES LDKChannelManager ChannelManager_new(LDKNetwork network, LDKFeeEstimator fee_est, LDKManyChannelMonitor monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKKeysInterface keys_manager, LDKUserConfig config, uintptr_t current_blockchain_height);
+MUST_USE_RES LDKChannelManager ChannelManager_new(LDKNetwork network, LDKFeeEstimator fee_est, LDKWatch chain_monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKKeysInterface keys_manager, LDKUserConfig config, uintptr_t current_blockchain_height);
 
 /**
  * Creates a new outbound channel to the given remote node and with the given value.
@@ -4278,7 +4320,7 @@ MUST_USE_RES LDKPublicKey ChannelManager_get_our_node_id(const LDKChannelManager
  * exists largely only to prevent races between this and concurrent update_monitor calls.
  *
  * Thus, the anticipated use is, at a high level:
- *  1) You register a ManyChannelMonitor with this ChannelManager,
+ *  1) You register a chain::Watch with this ChannelManager,
  *  2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
  *     said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
  *     any time it cannot do so instantly,
@@ -4292,7 +4334,18 @@ LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const L
 
 LDKEventsProvider ChannelManager_as_EventsProvider(const LDKChannelManager *this_arg);
 
-LDKChainListener ChannelManager_as_ChainListener(const LDKChannelManager *this_arg);
+/**
+ * Updates channel state based on transactions seen in a connected block.
+ */
+void ChannelManager_block_connected(const LDKChannelManager *this_arg, const uint8_t (*header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height);
+
+/**
+ * Updates channel state based on a disconnected block.
+ *
+ * If necessary, the channel may be force-closed without letting the counterparty participate
+ * in the shutdown.
+ */
+void ChannelManager_block_disconnected(const LDKChannelManager *this_arg, const uint8_t (*header)[80]);
 
 LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const LDKChannelManager *this_arg);
 
@@ -4325,22 +4378,22 @@ const LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const LDKChannel
 void ChannelManagerReadArgs_set_fee_estimator(LDKChannelManagerReadArgs *this_ptr, LDKFeeEstimator val);
 
 /**
- * The ManyChannelMonitor for use in the ChannelManager in the future.
+ * The chain::Watch for use in the ChannelManager in the future.
  *
- * No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+ * No calls to the chain::Watch will be made during deserialization. It is assumed that
  * you have deserialized ChannelMonitors separately and will add them to your
- * ManyChannelMonitor after deserializing this ChannelManager.
+ * chain::Watch after deserializing this ChannelManager.
  */
-const LDKManyChannelMonitor *ChannelManagerReadArgs_get_monitor(const LDKChannelManagerReadArgs *this_ptr);
+const LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const LDKChannelManagerReadArgs *this_ptr);
 
 /**
- * The ManyChannelMonitor for use in the ChannelManager in the future.
+ * The chain::Watch for use in the ChannelManager in the future.
  *
- * No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+ * No calls to the chain::Watch will be made during deserialization. It is assumed that
  * you have deserialized ChannelMonitors separately and will add them to your
- * ManyChannelMonitor after deserializing this ChannelManager.
+ * chain::Watch after deserializing this ChannelManager.
  */
-void ChannelManagerReadArgs_set_monitor(LDKChannelManagerReadArgs *this_ptr, LDKManyChannelMonitor val);
+void ChannelManagerReadArgs_set_chain_monitor(LDKChannelManagerReadArgs *this_ptr, LDKWatch val);
 
 /**
  * The BroadcasterInterface which will be used in the ChannelManager in the future and may be
@@ -4385,100 +4438,7 @@ void ChannelManagerReadArgs_set_default_config(LDKChannelManagerReadArgs *this_p
  * HashMap for you. This is primarily useful for C bindings where it is not practical to
  * populate a HashMap directly from C.
  */
-MUST_USE_RES LDKChannelManagerReadArgs ChannelManagerReadArgs_new(LDKKeysInterface keys_manager, LDKFeeEstimator fee_estimator, LDKManyChannelMonitor monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKUserConfig default_config, LDKCVec_ChannelMonitorZ channel_monitors);
-
-void ChannelMonitorUpdate_free(LDKChannelMonitorUpdate this_ptr);
-
-/**
- * The sequence number of this update. Updates *must* be replayed in-order according to this
- * sequence number (and updates may panic if they are not). The update_id values are strictly
- * increasing and increase by one for each new update.
- *
- * This sequence number is also used to track up to which points updates which returned
- * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
- * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
- */
-uint64_t ChannelMonitorUpdate_get_update_id(const LDKChannelMonitorUpdate *this_ptr);
-
-/**
- * The sequence number of this update. Updates *must* be replayed in-order according to this
- * sequence number (and updates may panic if they are not). The update_id values are strictly
- * increasing and increase by one for each new update.
- *
- * This sequence number is also used to track up to which points updates which returned
- * ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
- * ChannelMonitor when ChannelManager::channel_monitor_updated is called.
- */
-void ChannelMonitorUpdate_set_update_id(LDKChannelMonitorUpdate *this_ptr, uint64_t val);
-
-LDKCVec_u8Z ChannelMonitorUpdate_write(const LDKChannelMonitorUpdate *obj);
-
-LDKChannelMonitorUpdate ChannelMonitorUpdate_read(LDKu8slice ser);
-
-void MonitorUpdateError_free(LDKMonitorUpdateError this_ptr);
-
-void MonitorEvent_free(LDKMonitorEvent this_ptr);
-
-void HTLCUpdate_free(LDKHTLCUpdate this_ptr);
-
-LDKCVec_u8Z HTLCUpdate_write(const LDKHTLCUpdate *obj);
-
-LDKHTLCUpdate HTLCUpdate_read(LDKu8slice ser);
-
-void ChannelMonitor_free(LDKChannelMonitor this_ptr);
-
-/**
- * Calls the free function if one is set
- */
-void ManyChannelMonitor_free(LDKManyChannelMonitor this_ptr);
-
-/**
- * Updates a ChannelMonitor on the basis of some new information provided by the Channel
- * itself.
- *
- * panics if the given update is not the next update by update_id.
- */
-MUST_USE_RES LDKCResult_NoneMonitorUpdateErrorZ ChannelMonitor_update_monitor(LDKChannelMonitor *this_arg, LDKChannelMonitorUpdate updates, const LDKBroadcasterInterface *broadcaster, const LDKLogger *logger);
-
-/**
- * Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
- * ChannelMonitor.
- */
-MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const LDKChannelMonitor *this_arg);
-
-/**
- * Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
- */
-MUST_USE_RES LDKC2Tuple_OutPointScriptZ ChannelMonitor_get_funding_txo(const LDKChannelMonitor *this_arg);
-
-/**
- * Get the list of HTLCs who's status has been updated on chain. This should be called by
- * ChannelManager via ManyChannelMonitor::get_and_clear_pending_monitor_events().
- */
-MUST_USE_RES LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_monitor_events(LDKChannelMonitor *this_arg);
-
-/**
- * Gets the list of pending events which were generated by previous actions, clearing the list
- * in the process.
- *
- * This is called by ManyChannelMonitor::get_and_clear_pending_events() and is equivalent to
- * EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
- * no internal locking in ChannelMonitors.
- */
-MUST_USE_RES LDKCVec_EventZ ChannelMonitor_get_and_clear_pending_events(LDKChannelMonitor *this_arg);
-
-/**
- * Used by ChannelManager deserialization to broadcast the latest holder state if its copy of
- * the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of
- * fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows
- * a higher revocation secret than the holder commitment number we are aware of. Broadcasting these
- * transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to
- * broadcast them if counterparty don't close channel with his higher commitment transaction after a
- * substantial amount of time (a month or even a year) to get back funds. Best may be to contact
- * out-of-band the other node operator to coordinate with him if option is available to you.
- * In any-case, choice is up to the user.
- */
-MUST_USE_RES LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(LDKChannelMonitor *this_arg, const LDKLogger *logger);
+MUST_USE_RES LDKChannelManagerReadArgs ChannelManagerReadArgs_new(LDKKeysInterface keys_manager, LDKFeeEstimator fee_estimator, LDKWatch chain_monitor, LDKBroadcasterInterface tx_broadcaster, LDKLogger logger, LDKUserConfig default_config, LDKCVec_ChannelMonitorZ channel_monitors);
 
 void DecodeError_free(LDKDecodeError this_ptr);
 
@@ -5365,6 +5325,16 @@ void NetAddress_free(LDKNetAddress this_ptr);
 
 void UnsignedNodeAnnouncement_free(LDKUnsignedNodeAnnouncement this_ptr);
 
+/**
+ * The advertised features
+ */
+LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const LDKUnsignedNodeAnnouncement *this_ptr);
+
+/**
+ * The advertised features
+ */
+void UnsignedNodeAnnouncement_set_features(LDKUnsignedNodeAnnouncement *this_ptr, LDKNodeFeatures val);
+
 /**
  * A strictly monotonic announcement counter, with gaps allowed
  */
@@ -5440,6 +5410,16 @@ MUST_USE_RES LDKNodeAnnouncement NodeAnnouncement_new(LDKSignature signature_arg
 
 void UnsignedChannelAnnouncement_free(LDKUnsignedChannelAnnouncement this_ptr);
 
+/**
+ * The advertised channel features
+ */
+LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const LDKUnsignedChannelAnnouncement *this_ptr);
+
+/**
+ * The advertised channel features
+ */
+void UnsignedChannelAnnouncement_set_features(LDKUnsignedChannelAnnouncement *this_ptr, LDKChannelFeatures val);
+
 /**
  * The genesis hash of the blockchain where the channel is to be opened
  */
@@ -6467,19 +6447,19 @@ LDKCVec_u8Z make_funding_redeemscript(LDKPublicKey broadcaster, LDKPublicKey cou
 /**
  * panics if htlc.transaction_output_index.is_none()!
  */
-LDKCVec_u8Z build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const LDKHTLCOutputInCommitment *htlc, LDKPublicKey broadcaster_delayed_payment_key, LDKPublicKey revocation_key);
+LDKTransaction build_htlc_transaction(const uint8_t (*prev_hash)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const LDKHTLCOutputInCommitment *htlc, LDKPublicKey broadcaster_delayed_payment_key, LDKPublicKey revocation_key);
 
 void HolderCommitmentTransaction_free(LDKHolderCommitmentTransaction this_ptr);
 
 /**
  * The commitment transaction itself, in unsigned form.
  */
-LDKCVec_u8Z HolderCommitmentTransaction_get_unsigned_tx(const LDKHolderCommitmentTransaction *this_ptr);
+LDKTransaction HolderCommitmentTransaction_get_unsigned_tx(const LDKHolderCommitmentTransaction *this_ptr);
 
 /**
  * The commitment transaction itself, in unsigned form.
  */
-void HolderCommitmentTransaction_set_unsigned_tx(LDKHolderCommitmentTransaction *this_ptr, LDKCVec_u8Z val);
+void HolderCommitmentTransaction_set_unsigned_tx(LDKHolderCommitmentTransaction *this_ptr, LDKTransaction val);
 
 /**
  * Our counterparty's signature for the transaction, above.
@@ -6522,7 +6502,7 @@ void HolderCommitmentTransaction_set_per_htlc(LDKHolderCommitmentTransaction *th
  * The unsigned transaction outputs must be consistent with htlc_data.  This function
  * only checks that the shape and amounts are consistent, but does not check the scriptPubkey.
  */
-MUST_USE_RES LDKHolderCommitmentTransaction HolderCommitmentTransaction_new_missing_holder_sig(LDKCVec_u8Z unsigned_tx, LDKSignature counterparty_sig, LDKPublicKey holder_funding_key, LDKPublicKey counterparty_funding_key, LDKTxCreationKeys keys, uint32_t feerate_per_kw, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data);
+MUST_USE_RES LDKHolderCommitmentTransaction HolderCommitmentTransaction_new_missing_holder_sig(LDKTransaction unsigned_tx, LDKSignature counterparty_sig, LDKPublicKey holder_funding_key, LDKPublicKey counterparty_funding_key, LDKTxCreationKeys keys, uint32_t feerate_per_kw, LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ htlc_data);
 
 /**
  * The pre-calculated transaction creation public keys.
@@ -6580,6 +6560,18 @@ LDKPublicKey RouteHop_get_pubkey(const LDKRouteHop *this_ptr);
  */
 void RouteHop_set_pubkey(LDKRouteHop *this_ptr, LDKPublicKey val);
 
+/**
+ * The node_announcement features of the node at this hop. For the last hop, these may be
+ * amended to match the features present in the invoice this node generated.
+ */
+LDKNodeFeatures RouteHop_get_node_features(const LDKRouteHop *this_ptr);
+
+/**
+ * The node_announcement features of the node at this hop. For the last hop, these may be
+ * amended to match the features present in the invoice this node generated.
+ */
+void RouteHop_set_node_features(LDKRouteHop *this_ptr, LDKNodeFeatures val);
+
 /**
  * The channel that should be used from the previous hop to reach this node.
  */
@@ -6590,6 +6582,18 @@ uint64_t RouteHop_get_short_channel_id(const LDKRouteHop *this_ptr);
  */
 void RouteHop_set_short_channel_id(LDKRouteHop *this_ptr, uint64_t val);
 
+/**
+ * The channel_announcement features of the channel that should be used from the previous hop
+ * to reach this node.
+ */
+LDKChannelFeatures RouteHop_get_channel_features(const LDKRouteHop *this_ptr);
+
+/**
+ * The channel_announcement features of the channel that should be used from the previous hop
+ * to reach this node.
+ */
+void RouteHop_set_channel_features(LDKRouteHop *this_ptr, LDKChannelFeatures val);
+
 /**
  * The fee taken on this hop. For the last hop, this should be the full value of the payment.
  */
@@ -6612,6 +6616,8 @@ uint32_t RouteHop_get_cltv_expiry_delta(const LDKRouteHop *this_ptr);
  */
 void RouteHop_set_cltv_expiry_delta(LDKRouteHop *this_ptr, uint32_t val);
 
+MUST_USE_RES LDKRouteHop RouteHop_new(LDKPublicKey pubkey_arg, LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg);
+
 void Route_free(LDKRoute this_ptr);
 
 /**
@@ -6717,13 +6723,13 @@ void NetGraphMsgHandler_free(LDKNetGraphMsgHandler this_ptr);
  * channel data is correct, and that the announcement is signed with
  * channel owners' keys.
  */
-MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_new(LDKChainWatchInterface chain_monitor, LDKLogger logger);
+MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_new(LDKAccess *chain_access, LDKLogger logger);
 
 /**
  * Creates a new tracker of the actual state of the network of channels and nodes,
  * assuming an existing Network Graph.
  */
-MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(LDKChainWatchInterface chain_monitor, LDKLogger logger, LDKNetworkGraph network_graph);
+MUST_USE_RES LDKNetGraphMsgHandler NetGraphMsgHandler_from_net_graph(LDKAccess *chain_access, LDKLogger logger, LDKNetworkGraph network_graph);
 
 /**
  * Take a read lock on the network_graph and return it in the C-bindings
@@ -6806,6 +6812,16 @@ LDKDirectionalChannelInfo DirectionalChannelInfo_read(LDKu8slice ser);
 
 void ChannelInfo_free(LDKChannelInfo this_ptr);
 
+/**
+ * Protocol features of a channel communicated during its announcement
+ */
+LDKChannelFeatures ChannelInfo_get_features(const LDKChannelInfo *this_ptr);
+
+/**
+ * Protocol features of a channel communicated during its announcement
+ */
+void ChannelInfo_set_features(LDKChannelInfo *this_ptr, LDKChannelFeatures val);
+
 /**
  * Source node of the first direction of a channel
  */
@@ -6898,6 +6914,16 @@ LDKCVec_u8Z RoutingFees_write(const LDKRoutingFees *obj);
 
 void NodeAnnouncementInfo_free(LDKNodeAnnouncementInfo this_ptr);
 
+/**
+ * Protocol features the node announced support for
+ */
+LDKNodeFeatures NodeAnnouncementInfo_get_features(const LDKNodeAnnouncementInfo *this_ptr);
+
+/**
+ * Protocol features the node announced support for
+ */
+void NodeAnnouncementInfo_set_features(LDKNodeAnnouncementInfo *this_ptr, LDKNodeFeatures val);
+
 /**
  * When the last known update to the node state was issued.
  * Value is opaque, as set in the announcement.
@@ -6955,6 +6981,8 @@ LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const LDKNodeA
  */
 void NodeAnnouncementInfo_set_announcement_message(LDKNodeAnnouncementInfo *this_ptr, LDKNodeAnnouncement val);
 
+MUST_USE_RES LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(LDKNodeFeatures features_arg, uint32_t last_update_arg, LDKThreeBytes rgb_arg, LDKThirtyTwoBytes alias_arg, LDKCVec_NetAddressZ addresses_arg, LDKNodeAnnouncement announcement_message_arg);
+
 LDKCVec_u8Z NodeAnnouncementInfo_write(const LDKNodeAnnouncementInfo *obj);
 
 LDKNodeAnnouncementInfo NodeAnnouncementInfo_read(LDKu8slice ser);
index d14cd5cc40e4c8e49a8a0289482efcc62c35b166..77b587fd8092788288559f55ee80cb9d87f75cea 100644 (file)
@@ -153,33 +153,6 @@ public:
        const LDKUserConfig* operator &() const { return &self; }
        const LDKUserConfig* operator ->() const { return &self; }
 };
-class ChainError {
-private:
-       LDKChainError self;
-public:
-       ChainError(const ChainError&) = delete;
-       ChainError(ChainError&& o) : self(o.self) { memset(&o, 0, sizeof(ChainError)); }
-       ChainError(LDKChainError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainError)); }
-       operator LDKChainError() { LDKChainError res = self; memset(&self, 0, sizeof(LDKChainError)); return res; }
-       LDKChainError* operator &() { return &self; }
-       LDKChainError* operator ->() { return &self; }
-       const LDKChainError* operator &() const { return &self; }
-       const LDKChainError* operator ->() const { return &self; }
-};
-class ChainWatchInterface {
-private:
-       LDKChainWatchInterface self;
-public:
-       ChainWatchInterface(const ChainWatchInterface&) = delete;
-       ~ChainWatchInterface() { ChainWatchInterface_free(self); }
-       ChainWatchInterface(ChainWatchInterface&& o) : self(o.self) { memset(&o, 0, sizeof(ChainWatchInterface)); }
-       ChainWatchInterface(LDKChainWatchInterface&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainWatchInterface)); }
-       operator LDKChainWatchInterface() { LDKChainWatchInterface res = self; memset(&self, 0, sizeof(LDKChainWatchInterface)); return res; }
-       LDKChainWatchInterface* operator &() { return &self; }
-       LDKChainWatchInterface* operator ->() { return &self; }
-       const LDKChainWatchInterface* operator &() const { return &self; }
-       const LDKChainWatchInterface* operator ->() const { return &self; }
-};
 class BroadcasterInterface {
 private:
        LDKBroadcasterInterface self;
@@ -194,20 +167,6 @@ public:
        const LDKBroadcasterInterface* operator &() const { return &self; }
        const LDKBroadcasterInterface* operator ->() const { return &self; }
 };
-class ChainListener {
-private:
-       LDKChainListener self;
-public:
-       ChainListener(const ChainListener&) = delete;
-       ~ChainListener() { ChainListener_free(self); }
-       ChainListener(ChainListener&& o) : self(o.self) { memset(&o, 0, sizeof(ChainListener)); }
-       ChainListener(LDKChainListener&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainListener)); }
-       operator LDKChainListener() { LDKChainListener res = self; memset(&self, 0, sizeof(LDKChainListener)); return res; }
-       LDKChainListener* operator &() { return &self; }
-       LDKChainListener* operator ->() { return &self; }
-       const LDKChainListener* operator &() const { return &self; }
-       const LDKChainListener* operator ->() const { return &self; }
-};
 class ConfirmationTarget {
 private:
        LDKConfirmationTarget self;
@@ -235,47 +194,102 @@ public:
        const LDKFeeEstimator* operator &() const { return &self; }
        const LDKFeeEstimator* operator ->() const { return &self; }
 };
-class ChainWatchedUtil {
+class ChainMonitor {
+private:
+       LDKChainMonitor self;
+public:
+       ChainMonitor(const ChainMonitor&) = delete;
+       ~ChainMonitor() { ChainMonitor_free(self); }
+       ChainMonitor(ChainMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChainMonitor)); }
+       ChainMonitor(LDKChainMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainMonitor)); }
+       operator LDKChainMonitor() { LDKChainMonitor res = self; memset(&self, 0, sizeof(LDKChainMonitor)); return res; }
+       LDKChainMonitor* operator &() { return &self; }
+       LDKChainMonitor* operator ->() { return &self; }
+       const LDKChainMonitor* operator &() const { return &self; }
+       const LDKChainMonitor* operator ->() const { return &self; }
+};
+class ChannelMonitorUpdate {
+private:
+       LDKChannelMonitorUpdate self;
+public:
+       ChannelMonitorUpdate(const ChannelMonitorUpdate&) = delete;
+       ~ChannelMonitorUpdate() { ChannelMonitorUpdate_free(self); }
+       ChannelMonitorUpdate(ChannelMonitorUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdate)); }
+       ChannelMonitorUpdate(LDKChannelMonitorUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdate)); }
+       operator LDKChannelMonitorUpdate() { LDKChannelMonitorUpdate res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdate)); return res; }
+       LDKChannelMonitorUpdate* operator &() { return &self; }
+       LDKChannelMonitorUpdate* operator ->() { return &self; }
+       const LDKChannelMonitorUpdate* operator &() const { return &self; }
+       const LDKChannelMonitorUpdate* operator ->() const { return &self; }
+};
+class ChannelMonitorUpdateErr {
+private:
+       LDKChannelMonitorUpdateErr self;
+public:
+       ChannelMonitorUpdateErr(const ChannelMonitorUpdateErr&) = delete;
+       ChannelMonitorUpdateErr(ChannelMonitorUpdateErr&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdateErr)); }
+       ChannelMonitorUpdateErr(LDKChannelMonitorUpdateErr&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdateErr)); }
+       operator LDKChannelMonitorUpdateErr() { LDKChannelMonitorUpdateErr res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdateErr)); return res; }
+       LDKChannelMonitorUpdateErr* operator &() { return &self; }
+       LDKChannelMonitorUpdateErr* operator ->() { return &self; }
+       const LDKChannelMonitorUpdateErr* operator &() const { return &self; }
+       const LDKChannelMonitorUpdateErr* operator ->() const { return &self; }
+};
+class MonitorUpdateError {
+private:
+       LDKMonitorUpdateError self;
+public:
+       MonitorUpdateError(const MonitorUpdateError&) = delete;
+       ~MonitorUpdateError() { MonitorUpdateError_free(self); }
+       MonitorUpdateError(MonitorUpdateError&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorUpdateError)); }
+       MonitorUpdateError(LDKMonitorUpdateError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorUpdateError)); }
+       operator LDKMonitorUpdateError() { LDKMonitorUpdateError res = self; memset(&self, 0, sizeof(LDKMonitorUpdateError)); return res; }
+       LDKMonitorUpdateError* operator &() { return &self; }
+       LDKMonitorUpdateError* operator ->() { return &self; }
+       const LDKMonitorUpdateError* operator &() const { return &self; }
+       const LDKMonitorUpdateError* operator ->() const { return &self; }
+};
+class MonitorEvent {
 private:
-       LDKChainWatchedUtil self;
+       LDKMonitorEvent self;
 public:
-       ChainWatchedUtil(const ChainWatchedUtil&) = delete;
-       ~ChainWatchedUtil() { ChainWatchedUtil_free(self); }
-       ChainWatchedUtil(ChainWatchedUtil&& o) : self(o.self) { memset(&o, 0, sizeof(ChainWatchedUtil)); }
-       ChainWatchedUtil(LDKChainWatchedUtil&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainWatchedUtil)); }
-       operator LDKChainWatchedUtil() { LDKChainWatchedUtil res = self; memset(&self, 0, sizeof(LDKChainWatchedUtil)); return res; }
-       LDKChainWatchedUtil* operator &() { return &self; }
-       LDKChainWatchedUtil* operator ->() { return &self; }
-       const LDKChainWatchedUtil* operator &() const { return &self; }
-       const LDKChainWatchedUtil* operator ->() const { return &self; }
+       MonitorEvent(const MonitorEvent&) = delete;
+       ~MonitorEvent() { MonitorEvent_free(self); }
+       MonitorEvent(MonitorEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorEvent)); }
+       MonitorEvent(LDKMonitorEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorEvent)); }
+       operator LDKMonitorEvent() { LDKMonitorEvent res = self; memset(&self, 0, sizeof(LDKMonitorEvent)); return res; }
+       LDKMonitorEvent* operator &() { return &self; }
+       LDKMonitorEvent* operator ->() { return &self; }
+       const LDKMonitorEvent* operator &() const { return &self; }
+       const LDKMonitorEvent* operator ->() const { return &self; }
 };
-class BlockNotifier {
+class HTLCUpdate {
 private:
-       LDKBlockNotifier self;
+       LDKHTLCUpdate self;
 public:
-       BlockNotifier(const BlockNotifier&) = delete;
-       ~BlockNotifier() { BlockNotifier_free(self); }
-       BlockNotifier(BlockNotifier&& o) : self(o.self) { memset(&o, 0, sizeof(BlockNotifier)); }
-       BlockNotifier(LDKBlockNotifier&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlockNotifier)); }
-       operator LDKBlockNotifier() { LDKBlockNotifier res = self; memset(&self, 0, sizeof(LDKBlockNotifier)); return res; }
-       LDKBlockNotifier* operator &() { return &self; }
-       LDKBlockNotifier* operator ->() { return &self; }
-       const LDKBlockNotifier* operator &() const { return &self; }
-       const LDKBlockNotifier* operator ->() const { return &self; }
+       HTLCUpdate(const HTLCUpdate&) = delete;
+       ~HTLCUpdate() { HTLCUpdate_free(self); }
+       HTLCUpdate(HTLCUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCUpdate)); }
+       HTLCUpdate(LDKHTLCUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCUpdate)); }
+       operator LDKHTLCUpdate() { LDKHTLCUpdate res = self; memset(&self, 0, sizeof(LDKHTLCUpdate)); return res; }
+       LDKHTLCUpdate* operator &() { return &self; }
+       LDKHTLCUpdate* operator ->() { return &self; }
+       const LDKHTLCUpdate* operator &() const { return &self; }
+       const LDKHTLCUpdate* operator ->() const { return &self; }
 };
-class ChainWatchInterfaceUtil {
+class ChannelMonitor {
 private:
-       LDKChainWatchInterfaceUtil self;
+       LDKChannelMonitor self;
 public:
-       ChainWatchInterfaceUtil(const ChainWatchInterfaceUtil&) = delete;
-       ~ChainWatchInterfaceUtil() { ChainWatchInterfaceUtil_free(self); }
-       ChainWatchInterfaceUtil(ChainWatchInterfaceUtil&& o) : self(o.self) { memset(&o, 0, sizeof(ChainWatchInterfaceUtil)); }
-       ChainWatchInterfaceUtil(LDKChainWatchInterfaceUtil&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChainWatchInterfaceUtil)); }
-       operator LDKChainWatchInterfaceUtil() { LDKChainWatchInterfaceUtil res = self; memset(&self, 0, sizeof(LDKChainWatchInterfaceUtil)); return res; }
-       LDKChainWatchInterfaceUtil* operator &() { return &self; }
-       LDKChainWatchInterfaceUtil* operator ->() { return &self; }
-       const LDKChainWatchInterfaceUtil* operator &() const { return &self; }
-       const LDKChainWatchInterfaceUtil* operator ->() const { return &self; }
+       ChannelMonitor(const ChannelMonitor&) = delete;
+       ~ChannelMonitor() { ChannelMonitor_free(self); }
+       ChannelMonitor(ChannelMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitor)); }
+       ChannelMonitor(LDKChannelMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitor)); }
+       operator LDKChannelMonitor() { LDKChannelMonitor res = self; memset(&self, 0, sizeof(LDKChannelMonitor)); return res; }
+       LDKChannelMonitor* operator &() { return &self; }
+       LDKChannelMonitor* operator ->() { return &self; }
+       const LDKChannelMonitor* operator &() const { return &self; }
+       const LDKChannelMonitor* operator ->() const { return &self; }
 };
 class OutPoint {
 private:
@@ -361,6 +375,61 @@ public:
        const LDKKeysManager* operator &() const { return &self; }
        const LDKKeysManager* operator ->() const { return &self; }
 };
+class AccessError {
+private:
+       LDKAccessError self;
+public:
+       AccessError(const AccessError&) = delete;
+       AccessError(AccessError&& o) : self(o.self) { memset(&o, 0, sizeof(AccessError)); }
+       AccessError(LDKAccessError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAccessError)); }
+       operator LDKAccessError() { LDKAccessError res = self; memset(&self, 0, sizeof(LDKAccessError)); return res; }
+       LDKAccessError* operator &() { return &self; }
+       LDKAccessError* operator ->() { return &self; }
+       const LDKAccessError* operator &() const { return &self; }
+       const LDKAccessError* operator ->() const { return &self; }
+};
+class Access {
+private:
+       LDKAccess self;
+public:
+       Access(const Access&) = delete;
+       ~Access() { Access_free(self); }
+       Access(Access&& o) : self(o.self) { memset(&o, 0, sizeof(Access)); }
+       Access(LDKAccess&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAccess)); }
+       operator LDKAccess() { LDKAccess res = self; memset(&self, 0, sizeof(LDKAccess)); return res; }
+       LDKAccess* operator &() { return &self; }
+       LDKAccess* operator ->() { return &self; }
+       const LDKAccess* operator &() const { return &self; }
+       const LDKAccess* operator ->() const { return &self; }
+};
+class Watch {
+private:
+       LDKWatch self;
+public:
+       Watch(const Watch&) = delete;
+       ~Watch() { Watch_free(self); }
+       Watch(Watch&& o) : self(o.self) { memset(&o, 0, sizeof(Watch)); }
+       Watch(LDKWatch&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWatch)); }
+       operator LDKWatch() { LDKWatch res = self; memset(&self, 0, sizeof(LDKWatch)); return res; }
+       LDKWatch* operator &() { return &self; }
+       LDKWatch* operator ->() { return &self; }
+       const LDKWatch* operator &() const { return &self; }
+       const LDKWatch* operator ->() const { return &self; }
+};
+class Filter {
+private:
+       LDKFilter self;
+public:
+       Filter(const Filter&) = delete;
+       ~Filter() { Filter_free(self); }
+       Filter(Filter&& o) : self(o.self) { memset(&o, 0, sizeof(Filter)); }
+       Filter(LDKFilter&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFilter)); }
+       operator LDKFilter() { LDKFilter res = self; memset(&self, 0, sizeof(LDKFilter)); return res; }
+       LDKFilter* operator &() { return &self; }
+       LDKFilter* operator ->() { return &self; }
+       const LDKFilter* operator &() const { return &self; }
+       const LDKFilter* operator ->() const { return &self; }
+};
 class ChannelManager {
 private:
        LDKChannelManager self;
@@ -417,103 +486,6 @@ public:
        const LDKChannelManagerReadArgs* operator &() const { return &self; }
        const LDKChannelManagerReadArgs* operator ->() const { return &self; }
 };
-class ChannelMonitorUpdate {
-private:
-       LDKChannelMonitorUpdate self;
-public:
-       ChannelMonitorUpdate(const ChannelMonitorUpdate&) = delete;
-       ~ChannelMonitorUpdate() { ChannelMonitorUpdate_free(self); }
-       ChannelMonitorUpdate(ChannelMonitorUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdate)); }
-       ChannelMonitorUpdate(LDKChannelMonitorUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdate)); }
-       operator LDKChannelMonitorUpdate() { LDKChannelMonitorUpdate res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdate)); return res; }
-       LDKChannelMonitorUpdate* operator &() { return &self; }
-       LDKChannelMonitorUpdate* operator ->() { return &self; }
-       const LDKChannelMonitorUpdate* operator &() const { return &self; }
-       const LDKChannelMonitorUpdate* operator ->() const { return &self; }
-};
-class ChannelMonitorUpdateErr {
-private:
-       LDKChannelMonitorUpdateErr self;
-public:
-       ChannelMonitorUpdateErr(const ChannelMonitorUpdateErr&) = delete;
-       ChannelMonitorUpdateErr(ChannelMonitorUpdateErr&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitorUpdateErr)); }
-       ChannelMonitorUpdateErr(LDKChannelMonitorUpdateErr&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitorUpdateErr)); }
-       operator LDKChannelMonitorUpdateErr() { LDKChannelMonitorUpdateErr res = self; memset(&self, 0, sizeof(LDKChannelMonitorUpdateErr)); return res; }
-       LDKChannelMonitorUpdateErr* operator &() { return &self; }
-       LDKChannelMonitorUpdateErr* operator ->() { return &self; }
-       const LDKChannelMonitorUpdateErr* operator &() const { return &self; }
-       const LDKChannelMonitorUpdateErr* operator ->() const { return &self; }
-};
-class MonitorUpdateError {
-private:
-       LDKMonitorUpdateError self;
-public:
-       MonitorUpdateError(const MonitorUpdateError&) = delete;
-       ~MonitorUpdateError() { MonitorUpdateError_free(self); }
-       MonitorUpdateError(MonitorUpdateError&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorUpdateError)); }
-       MonitorUpdateError(LDKMonitorUpdateError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorUpdateError)); }
-       operator LDKMonitorUpdateError() { LDKMonitorUpdateError res = self; memset(&self, 0, sizeof(LDKMonitorUpdateError)); return res; }
-       LDKMonitorUpdateError* operator &() { return &self; }
-       LDKMonitorUpdateError* operator ->() { return &self; }
-       const LDKMonitorUpdateError* operator &() const { return &self; }
-       const LDKMonitorUpdateError* operator ->() const { return &self; }
-};
-class MonitorEvent {
-private:
-       LDKMonitorEvent self;
-public:
-       MonitorEvent(const MonitorEvent&) = delete;
-       ~MonitorEvent() { MonitorEvent_free(self); }
-       MonitorEvent(MonitorEvent&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorEvent)); }
-       MonitorEvent(LDKMonitorEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorEvent)); }
-       operator LDKMonitorEvent() { LDKMonitorEvent res = self; memset(&self, 0, sizeof(LDKMonitorEvent)); return res; }
-       LDKMonitorEvent* operator &() { return &self; }
-       LDKMonitorEvent* operator ->() { return &self; }
-       const LDKMonitorEvent* operator &() const { return &self; }
-       const LDKMonitorEvent* operator ->() const { return &self; }
-};
-class HTLCUpdate {
-private:
-       LDKHTLCUpdate self;
-public:
-       HTLCUpdate(const HTLCUpdate&) = delete;
-       ~HTLCUpdate() { HTLCUpdate_free(self); }
-       HTLCUpdate(HTLCUpdate&& o) : self(o.self) { memset(&o, 0, sizeof(HTLCUpdate)); }
-       HTLCUpdate(LDKHTLCUpdate&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHTLCUpdate)); }
-       operator LDKHTLCUpdate() { LDKHTLCUpdate res = self; memset(&self, 0, sizeof(LDKHTLCUpdate)); return res; }
-       LDKHTLCUpdate* operator &() { return &self; }
-       LDKHTLCUpdate* operator ->() { return &self; }
-       const LDKHTLCUpdate* operator &() const { return &self; }
-       const LDKHTLCUpdate* operator ->() const { return &self; }
-};
-class ChannelMonitor {
-private:
-       LDKChannelMonitor self;
-public:
-       ChannelMonitor(const ChannelMonitor&) = delete;
-       ~ChannelMonitor() { ChannelMonitor_free(self); }
-       ChannelMonitor(ChannelMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelMonitor)); }
-       ChannelMonitor(LDKChannelMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelMonitor)); }
-       operator LDKChannelMonitor() { LDKChannelMonitor res = self; memset(&self, 0, sizeof(LDKChannelMonitor)); return res; }
-       LDKChannelMonitor* operator &() { return &self; }
-       LDKChannelMonitor* operator ->() { return &self; }
-       const LDKChannelMonitor* operator &() const { return &self; }
-       const LDKChannelMonitor* operator ->() const { return &self; }
-};
-class ManyChannelMonitor {
-private:
-       LDKManyChannelMonitor self;
-public:
-       ManyChannelMonitor(const ManyChannelMonitor&) = delete;
-       ~ManyChannelMonitor() { ManyChannelMonitor_free(self); }
-       ManyChannelMonitor(ManyChannelMonitor&& o) : self(o.self) { memset(&o, 0, sizeof(ManyChannelMonitor)); }
-       ManyChannelMonitor(LDKManyChannelMonitor&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKManyChannelMonitor)); }
-       operator LDKManyChannelMonitor() { LDKManyChannelMonitor res = self; memset(&self, 0, sizeof(LDKManyChannelMonitor)); return res; }
-       LDKManyChannelMonitor* operator &() { return &self; }
-       LDKManyChannelMonitor* operator ->() { return &self; }
-       const LDKManyChannelMonitor* operator &() const { return &self; }
-       const LDKManyChannelMonitor* operator ->() const { return &self; }
-};
 class DecodeError {
 private:
        LDKDecodeError self;
@@ -1396,33 +1368,33 @@ public:
        const LDKNodeInfo* operator &() const { return &self; }
        const LDKNodeInfo* operator ->() const { return &self; }
 };
-class CResult_PublicKeySecpErrorZ {
+class CVec_SpendableOutputDescriptorZ {
 private:
-       LDKCResult_PublicKeySecpErrorZ self;
+       LDKCVec_SpendableOutputDescriptorZ self;
 public:
-       CResult_PublicKeySecpErrorZ(const CResult_PublicKeySecpErrorZ&) = delete;
-       ~CResult_PublicKeySecpErrorZ() { CResult_PublicKeySecpErrorZ_free(self); }
-       CResult_PublicKeySecpErrorZ(CResult_PublicKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PublicKeySecpErrorZ)); }
-       CResult_PublicKeySecpErrorZ(LDKCResult_PublicKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); }
-       operator LDKCResult_PublicKeySecpErrorZ() { LDKCResult_PublicKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); return res; }
-       LDKCResult_PublicKeySecpErrorZ* operator &() { return &self; }
-       LDKCResult_PublicKeySecpErrorZ* operator ->() { return &self; }
-       const LDKCResult_PublicKeySecpErrorZ* operator &() const { return &self; }
-       const LDKCResult_PublicKeySecpErrorZ* operator ->() const { return &self; }
+       CVec_SpendableOutputDescriptorZ(const CVec_SpendableOutputDescriptorZ&) = delete;
+       ~CVec_SpendableOutputDescriptorZ() { CVec_SpendableOutputDescriptorZ_free(self); }
+       CVec_SpendableOutputDescriptorZ(CVec_SpendableOutputDescriptorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SpendableOutputDescriptorZ)); }
+       CVec_SpendableOutputDescriptorZ(LDKCVec_SpendableOutputDescriptorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); }
+       operator LDKCVec_SpendableOutputDescriptorZ() { LDKCVec_SpendableOutputDescriptorZ res = self; memset(&self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); return res; }
+       LDKCVec_SpendableOutputDescriptorZ* operator &() { return &self; }
+       LDKCVec_SpendableOutputDescriptorZ* operator ->() { return &self; }
+       const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; }
+       const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; }
 };
-class CVec_u8Z {
+class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
 private:
-       LDKCVec_u8Z self;
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self;
 public:
-       CVec_u8Z(const CVec_u8Z&) = delete;
-       ~CVec_u8Z() { CVec_u8Z_free(self); }
-       CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); }
-       CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); }
-       operator LDKCVec_u8Z() { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; }
-       LDKCVec_u8Z* operator &() { return &self; }
-       LDKCVec_u8Z* operator ->() { return &self; }
-       const LDKCVec_u8Z* operator &() const { return &self; }
-       const LDKCVec_u8Z* operator ->() const { return &self; }
+       CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(const CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&) = delete;
+       ~CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); }
+       CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); }
+       CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); }
+       operator LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return res; }
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() { return &self; }
+       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() { return &self; }
+       const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; }
+       const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; }
 };
 class CResult_NoneMonitorUpdateErrorZ {
 private:
@@ -1438,89 +1410,33 @@ public:
        const LDKCResult_NoneMonitorUpdateErrorZ* operator &() const { return &self; }
        const LDKCResult_NoneMonitorUpdateErrorZ* operator ->() const { return &self; }
 };
-class C2Tuple_OutPointScriptZ {
+class CVec_UpdateFailHTLCZ {
 private:
-       LDKC2Tuple_OutPointScriptZ self;
+       LDKCVec_UpdateFailHTLCZ self;
 public:
-       C2Tuple_OutPointScriptZ(const C2Tuple_OutPointScriptZ&) = delete;
-       ~C2Tuple_OutPointScriptZ() { C2Tuple_OutPointScriptZ_free(self); }
-       C2Tuple_OutPointScriptZ(C2Tuple_OutPointScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointScriptZ)); }
-       C2Tuple_OutPointScriptZ(LDKC2Tuple_OutPointScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); }
-       operator LDKC2Tuple_OutPointScriptZ() { LDKC2Tuple_OutPointScriptZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); return res; }
-       LDKC2Tuple_OutPointScriptZ* operator &() { return &self; }
-       LDKC2Tuple_OutPointScriptZ* operator ->() { return &self; }
-       const LDKC2Tuple_OutPointScriptZ* operator &() const { return &self; }
-       const LDKC2Tuple_OutPointScriptZ* operator ->() const { return &self; }
+       CVec_UpdateFailHTLCZ(const CVec_UpdateFailHTLCZ&) = delete;
+       ~CVec_UpdateFailHTLCZ() { CVec_UpdateFailHTLCZ_free(self); }
+       CVec_UpdateFailHTLCZ(CVec_UpdateFailHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); }
+       CVec_UpdateFailHTLCZ(LDKCVec_UpdateFailHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); }
+       operator LDKCVec_UpdateFailHTLCZ() { LDKCVec_UpdateFailHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); return res; }
+       LDKCVec_UpdateFailHTLCZ* operator &() { return &self; }
+       LDKCVec_UpdateFailHTLCZ* operator ->() { return &self; }
+       const LDKCVec_UpdateFailHTLCZ* operator &() const { return &self; }
+       const LDKCVec_UpdateFailHTLCZ* operator ->() const { return &self; }
 };
-class CVec_u64Z {
+class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
 private:
-       LDKCVec_u64Z self;
+       LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self;
 public:
-       CVec_u64Z(const CVec_u64Z&) = delete;
-       ~CVec_u64Z() { CVec_u64Z_free(self); }
-       CVec_u64Z(CVec_u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u64Z)); }
-       CVec_u64Z(LDKCVec_u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u64Z)); }
-       operator LDKCVec_u64Z() { LDKCVec_u64Z res = self; memset(&self, 0, sizeof(LDKCVec_u64Z)); return res; }
-       LDKCVec_u64Z* operator &() { return &self; }
-       LDKCVec_u64Z* operator ->() { return &self; }
-       const LDKCVec_u64Z* operator &() const { return &self; }
-       const LDKCVec_u64Z* operator ->() const { return &self; }
-};
-class CVec_CVec_RouteHopZZ {
-private:
-       LDKCVec_CVec_RouteHopZZ self;
-public:
-       CVec_CVec_RouteHopZZ(const CVec_CVec_RouteHopZZ&) = delete;
-       ~CVec_CVec_RouteHopZZ() { CVec_CVec_RouteHopZZ_free(self); }
-       CVec_CVec_RouteHopZZ(CVec_CVec_RouteHopZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_CVec_RouteHopZZ)); }
-       CVec_CVec_RouteHopZZ(LDKCVec_CVec_RouteHopZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); }
-       operator LDKCVec_CVec_RouteHopZZ() { LDKCVec_CVec_RouteHopZZ res = self; memset(&self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); return res; }
-       LDKCVec_CVec_RouteHopZZ* operator &() { return &self; }
-       LDKCVec_CVec_RouteHopZZ* operator ->() { return &self; }
-       const LDKCVec_CVec_RouteHopZZ* operator &() const { return &self; }
-       const LDKCVec_CVec_RouteHopZZ* operator ->() const { return &self; }
-};
-class CVec_TransactionZ {
-private:
-       LDKCVec_TransactionZ self;
-public:
-       CVec_TransactionZ(const CVec_TransactionZ&) = delete;
-       ~CVec_TransactionZ() { CVec_TransactionZ_free(self); }
-       CVec_TransactionZ(CVec_TransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TransactionZ)); }
-       CVec_TransactionZ(LDKCVec_TransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TransactionZ)); }
-       operator LDKCVec_TransactionZ() { LDKCVec_TransactionZ res = self; memset(&self, 0, sizeof(LDKCVec_TransactionZ)); return res; }
-       LDKCVec_TransactionZ* operator &() { return &self; }
-       LDKCVec_TransactionZ* operator ->() { return &self; }
-       const LDKCVec_TransactionZ* operator &() const { return &self; }
-       const LDKCVec_TransactionZ* operator ->() const { return &self; }
-};
-class CResult_C2Tuple_Scriptu64ZChainErrorZ {
-private:
-       LDKCResult_C2Tuple_Scriptu64ZChainErrorZ self;
-public:
-       CResult_C2Tuple_Scriptu64ZChainErrorZ(const CResult_C2Tuple_Scriptu64ZChainErrorZ&) = delete;
-       ~CResult_C2Tuple_Scriptu64ZChainErrorZ() { CResult_C2Tuple_Scriptu64ZChainErrorZ_free(self); }
-       CResult_C2Tuple_Scriptu64ZChainErrorZ(CResult_C2Tuple_Scriptu64ZChainErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_Scriptu64ZChainErrorZ)); }
-       CResult_C2Tuple_Scriptu64ZChainErrorZ(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); }
-       operator LDKCResult_C2Tuple_Scriptu64ZChainErrorZ() { LDKCResult_C2Tuple_Scriptu64ZChainErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_Scriptu64ZChainErrorZ)); return res; }
-       LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() { return &self; }
-       LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() { return &self; }
-       const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator &() const { return &self; }
-       const LDKCResult_C2Tuple_Scriptu64ZChainErrorZ* operator ->() const { return &self; }
-};
-class CResult_CVec_SignatureZNoneZ {
-private:
-       LDKCResult_CVec_SignatureZNoneZ self;
-public:
-       CResult_CVec_SignatureZNoneZ(const CResult_CVec_SignatureZNoneZ&) = delete;
-       ~CResult_CVec_SignatureZNoneZ() { CResult_CVec_SignatureZNoneZ_free(self); }
-       CResult_CVec_SignatureZNoneZ(CResult_CVec_SignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_SignatureZNoneZ)); }
-       CResult_CVec_SignatureZNoneZ(LDKCResult_CVec_SignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); }
-       operator LDKCResult_CVec_SignatureZNoneZ() { LDKCResult_CVec_SignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); return res; }
-       LDKCResult_CVec_SignatureZNoneZ* operator &() { return &self; }
-       LDKCResult_CVec_SignatureZNoneZ* operator ->() { return &self; }
-       const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; }
-       const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; }
+       CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(const CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&) = delete;
+       ~CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); }
+       CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
+       CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
+       operator LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return res; }
+       LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() { return &self; }
+       LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() { return &self; }
+       const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; }
+       const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; }
 };
 class CVec_NodeAnnouncementZ {
 private:
@@ -1536,33 +1452,61 @@ public:
        const LDKCVec_NodeAnnouncementZ* operator &() const { return &self; }
        const LDKCVec_NodeAnnouncementZ* operator ->() const { return &self; }
 };
-class CResult_RouteLightningErrorZ {
+class CResult_boolLightningErrorZ {
 private:
-       LDKCResult_RouteLightningErrorZ self;
+       LDKCResult_boolLightningErrorZ self;
 public:
-       CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete;
-       ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); }
-       CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); }
-       CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); }
-       operator LDKCResult_RouteLightningErrorZ() { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; }
-       LDKCResult_RouteLightningErrorZ* operator &() { return &self; }
-       LDKCResult_RouteLightningErrorZ* operator ->() { return &self; }
-       const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; }
-       const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; }
+       CResult_boolLightningErrorZ(const CResult_boolLightningErrorZ&) = delete;
+       ~CResult_boolLightningErrorZ() { CResult_boolLightningErrorZ_free(self); }
+       CResult_boolLightningErrorZ(CResult_boolLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); }
+       CResult_boolLightningErrorZ(LDKCResult_boolLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolLightningErrorZ)); }
+       operator LDKCResult_boolLightningErrorZ() { LDKCResult_boolLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolLightningErrorZ)); return res; }
+       LDKCResult_boolLightningErrorZ* operator &() { return &self; }
+       LDKCResult_boolLightningErrorZ* operator ->() { return &self; }
+       const LDKCResult_boolLightningErrorZ* operator &() const { return &self; }
+       const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; }
 };
-class CResult_boolPeerHandleErrorZ {
+class CVec_PublicKeyZ {
 private:
-       LDKCResult_boolPeerHandleErrorZ self;
+       LDKCVec_PublicKeyZ self;
 public:
-       CResult_boolPeerHandleErrorZ(const CResult_boolPeerHandleErrorZ&) = delete;
-       ~CResult_boolPeerHandleErrorZ() { CResult_boolPeerHandleErrorZ_free(self); }
-       CResult_boolPeerHandleErrorZ(CResult_boolPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); }
-       CResult_boolPeerHandleErrorZ(LDKCResult_boolPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); }
-       operator LDKCResult_boolPeerHandleErrorZ() { LDKCResult_boolPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); return res; }
-       LDKCResult_boolPeerHandleErrorZ* operator &() { return &self; }
-       LDKCResult_boolPeerHandleErrorZ* operator ->() { return &self; }
-       const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; }
-       const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; }
+       CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete;
+       ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); }
+       CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); }
+       CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); }
+       operator LDKCVec_PublicKeyZ() { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; }
+       LDKCVec_PublicKeyZ* operator &() { return &self; }
+       LDKCVec_PublicKeyZ* operator ->() { return &self; }
+       const LDKCVec_PublicKeyZ* operator &() const { return &self; }
+       const LDKCVec_PublicKeyZ* operator ->() const { return &self; }
+};
+class CResult_SecretKeySecpErrorZ {
+private:
+       LDKCResult_SecretKeySecpErrorZ self;
+public:
+       CResult_SecretKeySecpErrorZ(const CResult_SecretKeySecpErrorZ&) = delete;
+       ~CResult_SecretKeySecpErrorZ() { CResult_SecretKeySecpErrorZ_free(self); }
+       CResult_SecretKeySecpErrorZ(CResult_SecretKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SecretKeySecpErrorZ)); }
+       CResult_SecretKeySecpErrorZ(LDKCResult_SecretKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); }
+       operator LDKCResult_SecretKeySecpErrorZ() { LDKCResult_SecretKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); return res; }
+       LDKCResult_SecretKeySecpErrorZ* operator &() { return &self; }
+       LDKCResult_SecretKeySecpErrorZ* operator ->() { return &self; }
+       const LDKCResult_SecretKeySecpErrorZ* operator &() const { return &self; }
+       const LDKCResult_SecretKeySecpErrorZ* operator ->() const { return &self; }
+};
+class CVec_SignatureZ {
+private:
+       LDKCVec_SignatureZ self;
+public:
+       CVec_SignatureZ(const CVec_SignatureZ&) = delete;
+       ~CVec_SignatureZ() { CVec_SignatureZ_free(self); }
+       CVec_SignatureZ(CVec_SignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SignatureZ)); }
+       CVec_SignatureZ(LDKCVec_SignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SignatureZ)); }
+       operator LDKCVec_SignatureZ() { LDKCVec_SignatureZ res = self; memset(&self, 0, sizeof(LDKCVec_SignatureZ)); return res; }
+       LDKCVec_SignatureZ* operator &() { return &self; }
+       LDKCVec_SignatureZ* operator ->() { return &self; }
+       const LDKCVec_SignatureZ* operator &() const { return &self; }
+       const LDKCVec_SignatureZ* operator ->() const { return &self; }
 };
 class C2Tuple_SignatureCVec_SignatureZZ {
 private:
@@ -1578,117 +1522,75 @@ public:
        const LDKC2Tuple_SignatureCVec_SignatureZZ* operator &() const { return &self; }
        const LDKC2Tuple_SignatureCVec_SignatureZZ* operator ->() const { return &self; }
 };
-class CVec_HTLCOutputInCommitmentZ {
-private:
-       LDKCVec_HTLCOutputInCommitmentZ self;
-public:
-       CVec_HTLCOutputInCommitmentZ(const CVec_HTLCOutputInCommitmentZ&) = delete;
-       ~CVec_HTLCOutputInCommitmentZ() { CVec_HTLCOutputInCommitmentZ_free(self); }
-       CVec_HTLCOutputInCommitmentZ(CVec_HTLCOutputInCommitmentZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_HTLCOutputInCommitmentZ)); }
-       CVec_HTLCOutputInCommitmentZ(LDKCVec_HTLCOutputInCommitmentZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); }
-       operator LDKCVec_HTLCOutputInCommitmentZ() { LDKCVec_HTLCOutputInCommitmentZ res = self; memset(&self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); return res; }
-       LDKCVec_HTLCOutputInCommitmentZ* operator &() { return &self; }
-       LDKCVec_HTLCOutputInCommitmentZ* operator ->() { return &self; }
-       const LDKCVec_HTLCOutputInCommitmentZ* operator &() const { return &self; }
-       const LDKCVec_HTLCOutputInCommitmentZ* operator ->() const { return &self; }
-};
-class C2Tuple_Scriptu64Z {
-private:
-       LDKC2Tuple_Scriptu64Z self;
-public:
-       C2Tuple_Scriptu64Z(const C2Tuple_Scriptu64Z&) = delete;
-       ~C2Tuple_Scriptu64Z() { C2Tuple_Scriptu64Z_free(self); }
-       C2Tuple_Scriptu64Z(C2Tuple_Scriptu64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Scriptu64Z)); }
-       C2Tuple_Scriptu64Z(LDKC2Tuple_Scriptu64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); }
-       operator LDKC2Tuple_Scriptu64Z() { LDKC2Tuple_Scriptu64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Scriptu64Z)); return res; }
-       LDKC2Tuple_Scriptu64Z* operator &() { return &self; }
-       LDKC2Tuple_Scriptu64Z* operator ->() { return &self; }
-       const LDKC2Tuple_Scriptu64Z* operator &() const { return &self; }
-       const LDKC2Tuple_Scriptu64Z* operator ->() const { return &self; }
-};
-class CVec_ChannelMonitorZ {
-private:
-       LDKCVec_ChannelMonitorZ self;
-public:
-       CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete;
-       ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); }
-       CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); }
-       CVec_ChannelMonitorZ(LDKCVec_ChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelMonitorZ)); }
-       operator LDKCVec_ChannelMonitorZ() { LDKCVec_ChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelMonitorZ)); return res; }
-       LDKCVec_ChannelMonitorZ* operator &() { return &self; }
-       LDKCVec_ChannelMonitorZ* operator ->() { return &self; }
-       const LDKCVec_ChannelMonitorZ* operator &() const { return &self; }
-       const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; }
-};
-class C2Tuple_Txidu32Z {
+class CVec_u64Z {
 private:
-       LDKC2Tuple_Txidu32Z self;
+       LDKCVec_u64Z self;
 public:
-       C2Tuple_Txidu32Z(const C2Tuple_Txidu32Z&) = delete;
-       ~C2Tuple_Txidu32Z() { C2Tuple_Txidu32Z_free(self); }
-       C2Tuple_Txidu32Z(C2Tuple_Txidu32Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_Txidu32Z)); }
-       C2Tuple_Txidu32Z(LDKC2Tuple_Txidu32Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_Txidu32Z)); }
-       operator LDKC2Tuple_Txidu32Z() { LDKC2Tuple_Txidu32Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_Txidu32Z)); return res; }
-       LDKC2Tuple_Txidu32Z* operator &() { return &self; }
-       LDKC2Tuple_Txidu32Z* operator ->() { return &self; }
-       const LDKC2Tuple_Txidu32Z* operator &() const { return &self; }
-       const LDKC2Tuple_Txidu32Z* operator ->() const { return &self; }
+       CVec_u64Z(const CVec_u64Z&) = delete;
+       ~CVec_u64Z() { CVec_u64Z_free(self); }
+       CVec_u64Z(CVec_u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u64Z)); }
+       CVec_u64Z(LDKCVec_u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u64Z)); }
+       operator LDKCVec_u64Z() { LDKCVec_u64Z res = self; memset(&self, 0, sizeof(LDKCVec_u64Z)); return res; }
+       LDKCVec_u64Z* operator &() { return &self; }
+       LDKCVec_u64Z* operator ->() { return &self; }
+       const LDKCVec_u64Z* operator &() const { return &self; }
+       const LDKCVec_u64Z* operator ->() const { return &self; }
 };
-class CVec_ChannelDetailsZ {
+class CVec_UpdateFailMalformedHTLCZ {
 private:
-       LDKCVec_ChannelDetailsZ self;
+       LDKCVec_UpdateFailMalformedHTLCZ self;
 public:
-       CVec_ChannelDetailsZ(const CVec_ChannelDetailsZ&) = delete;
-       ~CVec_ChannelDetailsZ() { CVec_ChannelDetailsZ_free(self); }
-       CVec_ChannelDetailsZ(CVec_ChannelDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelDetailsZ)); }
-       CVec_ChannelDetailsZ(LDKCVec_ChannelDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelDetailsZ)); }
-       operator LDKCVec_ChannelDetailsZ() { LDKCVec_ChannelDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelDetailsZ)); return res; }
-       LDKCVec_ChannelDetailsZ* operator &() { return &self; }
-       LDKCVec_ChannelDetailsZ* operator ->() { return &self; }
-       const LDKCVec_ChannelDetailsZ* operator &() const { return &self; }
-       const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; }
+       CVec_UpdateFailMalformedHTLCZ(const CVec_UpdateFailMalformedHTLCZ&) = delete;
+       ~CVec_UpdateFailMalformedHTLCZ() { CVec_UpdateFailMalformedHTLCZ_free(self); }
+       CVec_UpdateFailMalformedHTLCZ(CVec_UpdateFailMalformedHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); }
+       CVec_UpdateFailMalformedHTLCZ(LDKCVec_UpdateFailMalformedHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); }
+       operator LDKCVec_UpdateFailMalformedHTLCZ() { LDKCVec_UpdateFailMalformedHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); return res; }
+       LDKCVec_UpdateFailMalformedHTLCZ* operator &() { return &self; }
+       LDKCVec_UpdateFailMalformedHTLCZ* operator ->() { return &self; }
+       const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; }
+       const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; }
 };
-class C2Tuple_u64u64Z {
+class C2Tuple_HTLCOutputInCommitmentSignatureZ {
 private:
-       LDKC2Tuple_u64u64Z self;
+       LDKC2Tuple_HTLCOutputInCommitmentSignatureZ self;
 public:
-       C2Tuple_u64u64Z(const C2Tuple_u64u64Z&) = delete;
-       ~C2Tuple_u64u64Z() { C2Tuple_u64u64Z_free(self); }
-       C2Tuple_u64u64Z(C2Tuple_u64u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_u64u64Z)); }
-       C2Tuple_u64u64Z(LDKC2Tuple_u64u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_u64u64Z)); }
-       operator LDKC2Tuple_u64u64Z() { LDKC2Tuple_u64u64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_u64u64Z)); return res; }
-       LDKC2Tuple_u64u64Z* operator &() { return &self; }
-       LDKC2Tuple_u64u64Z* operator ->() { return &self; }
-       const LDKC2Tuple_u64u64Z* operator &() const { return &self; }
-       const LDKC2Tuple_u64u64Z* operator ->() const { return &self; }
+       C2Tuple_HTLCOutputInCommitmentSignatureZ(const C2Tuple_HTLCOutputInCommitmentSignatureZ&) = delete;
+       ~C2Tuple_HTLCOutputInCommitmentSignatureZ() { C2Tuple_HTLCOutputInCommitmentSignatureZ_free(self); }
+       C2Tuple_HTLCOutputInCommitmentSignatureZ(C2Tuple_HTLCOutputInCommitmentSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_HTLCOutputInCommitmentSignatureZ)); }
+       C2Tuple_HTLCOutputInCommitmentSignatureZ(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); }
+       operator LDKC2Tuple_HTLCOutputInCommitmentSignatureZ() { LDKC2Tuple_HTLCOutputInCommitmentSignatureZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); return res; }
+       LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() { return &self; }
+       LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() { return &self; }
+       const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() const { return &self; }
+       const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() const { return &self; }
 };
-class CResult_NonePaymentSendFailureZ {
+class CVec_EventZ {
 private:
-       LDKCResult_NonePaymentSendFailureZ self;
+       LDKCVec_EventZ self;
 public:
-       CResult_NonePaymentSendFailureZ(const CResult_NonePaymentSendFailureZ&) = delete;
-       ~CResult_NonePaymentSendFailureZ() { CResult_NonePaymentSendFailureZ_free(self); }
-       CResult_NonePaymentSendFailureZ(CResult_NonePaymentSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); }
-       CResult_NonePaymentSendFailureZ(LDKCResult_NonePaymentSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); }
-       operator LDKCResult_NonePaymentSendFailureZ() { LDKCResult_NonePaymentSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); return res; }
-       LDKCResult_NonePaymentSendFailureZ* operator &() { return &self; }
-       LDKCResult_NonePaymentSendFailureZ* operator ->() { return &self; }
-       const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; }
-       const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; }
+       CVec_EventZ(const CVec_EventZ&) = delete;
+       ~CVec_EventZ() { CVec_EventZ_free(self); }
+       CVec_EventZ(CVec_EventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_EventZ)); }
+       CVec_EventZ(LDKCVec_EventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_EventZ)); }
+       operator LDKCVec_EventZ() { LDKCVec_EventZ res = self; memset(&self, 0, sizeof(LDKCVec_EventZ)); return res; }
+       LDKCVec_EventZ* operator &() { return &self; }
+       LDKCVec_EventZ* operator ->() { return &self; }
+       const LDKCVec_EventZ* operator &() const { return &self; }
+       const LDKCVec_EventZ* operator ->() const { return &self; }
 };
-class CResult_NoneChannelMonitorUpdateErrZ {
+class CResult_CVec_u8ZPeerHandleErrorZ {
 private:
-       LDKCResult_NoneChannelMonitorUpdateErrZ self;
+       LDKCResult_CVec_u8ZPeerHandleErrorZ self;
 public:
-       CResult_NoneChannelMonitorUpdateErrZ(const CResult_NoneChannelMonitorUpdateErrZ&) = delete;
-       ~CResult_NoneChannelMonitorUpdateErrZ() { CResult_NoneChannelMonitorUpdateErrZ_free(self); }
-       CResult_NoneChannelMonitorUpdateErrZ(CResult_NoneChannelMonitorUpdateErrZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneChannelMonitorUpdateErrZ)); }
-       CResult_NoneChannelMonitorUpdateErrZ(LDKCResult_NoneChannelMonitorUpdateErrZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ)); }
-       operator LDKCResult_NoneChannelMonitorUpdateErrZ() { LDKCResult_NoneChannelMonitorUpdateErrZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ)); return res; }
-       LDKCResult_NoneChannelMonitorUpdateErrZ* operator &() { return &self; }
-       LDKCResult_NoneChannelMonitorUpdateErrZ* operator ->() { return &self; }
-       const LDKCResult_NoneChannelMonitorUpdateErrZ* operator &() const { return &self; }
-       const LDKCResult_NoneChannelMonitorUpdateErrZ* operator ->() const { return &self; }
+       CResult_CVec_u8ZPeerHandleErrorZ(const CResult_CVec_u8ZPeerHandleErrorZ&) = delete;
+       ~CResult_CVec_u8ZPeerHandleErrorZ() { CResult_CVec_u8ZPeerHandleErrorZ_free(self); }
+       CResult_CVec_u8ZPeerHandleErrorZ(CResult_CVec_u8ZPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_u8ZPeerHandleErrorZ)); }
+       CResult_CVec_u8ZPeerHandleErrorZ(LDKCResult_CVec_u8ZPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); }
+       operator LDKCResult_CVec_u8ZPeerHandleErrorZ() { LDKCResult_CVec_u8ZPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); return res; }
+       LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() { return &self; }
+       LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() { return &self; }
+       const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; }
+       const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; }
 };
 class CVec_MonitorEventZ {
 private:
@@ -1704,79 +1606,9 @@ public:
        const LDKCVec_MonitorEventZ* operator &() const { return &self; }
        const LDKCVec_MonitorEventZ* operator ->() const { return &self; }
 };
-class CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
+class CVec_RouteHopZ {
 private:
-       LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ self;
-public:
-       CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(const CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&) = delete;
-       ~CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(self); }
-       CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
-       CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); }
-       operator LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ() { LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ)); return res; }
-       LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() { return &self; }
-       LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() { return &self; }
-       const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator &() const { return &self; }
-       const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* operator ->() const { return &self; }
-};
-class C2Tuple_HTLCOutputInCommitmentSignatureZ {
-private:
-       LDKC2Tuple_HTLCOutputInCommitmentSignatureZ self;
-public:
-       C2Tuple_HTLCOutputInCommitmentSignatureZ(const C2Tuple_HTLCOutputInCommitmentSignatureZ&) = delete;
-       ~C2Tuple_HTLCOutputInCommitmentSignatureZ() { C2Tuple_HTLCOutputInCommitmentSignatureZ_free(self); }
-       C2Tuple_HTLCOutputInCommitmentSignatureZ(C2Tuple_HTLCOutputInCommitmentSignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_HTLCOutputInCommitmentSignatureZ)); }
-       C2Tuple_HTLCOutputInCommitmentSignatureZ(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); }
-       operator LDKC2Tuple_HTLCOutputInCommitmentSignatureZ() { LDKC2Tuple_HTLCOutputInCommitmentSignatureZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_HTLCOutputInCommitmentSignatureZ)); return res; }
-       LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() { return &self; }
-       LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() { return &self; }
-       const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator &() const { return &self; }
-       const LDKC2Tuple_HTLCOutputInCommitmentSignatureZ* operator ->() const { return &self; }
-};
-class CResult_SecretKeySecpErrorZ {
-private:
-       LDKCResult_SecretKeySecpErrorZ self;
-public:
-       CResult_SecretKeySecpErrorZ(const CResult_SecretKeySecpErrorZ&) = delete;
-       ~CResult_SecretKeySecpErrorZ() { CResult_SecretKeySecpErrorZ_free(self); }
-       CResult_SecretKeySecpErrorZ(CResult_SecretKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SecretKeySecpErrorZ)); }
-       CResult_SecretKeySecpErrorZ(LDKCResult_SecretKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); }
-       operator LDKCResult_SecretKeySecpErrorZ() { LDKCResult_SecretKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SecretKeySecpErrorZ)); return res; }
-       LDKCResult_SecretKeySecpErrorZ* operator &() { return &self; }
-       LDKCResult_SecretKeySecpErrorZ* operator ->() { return &self; }
-       const LDKCResult_SecretKeySecpErrorZ* operator &() const { return &self; }
-       const LDKCResult_SecretKeySecpErrorZ* operator ->() const { return &self; }
-};
-class CVec_RouteHintZ {
-private:
-       LDKCVec_RouteHintZ self;
-public:
-       CVec_RouteHintZ(const CVec_RouteHintZ&) = delete;
-       ~CVec_RouteHintZ() { CVec_RouteHintZ_free(self); }
-       CVec_RouteHintZ(CVec_RouteHintZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHintZ)); }
-       CVec_RouteHintZ(LDKCVec_RouteHintZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHintZ)); }
-       operator LDKCVec_RouteHintZ() { LDKCVec_RouteHintZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHintZ)); return res; }
-       LDKCVec_RouteHintZ* operator &() { return &self; }
-       LDKCVec_RouteHintZ* operator ->() { return &self; }
-       const LDKCVec_RouteHintZ* operator &() const { return &self; }
-       const LDKCVec_RouteHintZ* operator ->() const { return &self; }
-};
-class CVec_UpdateFailMalformedHTLCZ {
-private:
-       LDKCVec_UpdateFailMalformedHTLCZ self;
-public:
-       CVec_UpdateFailMalformedHTLCZ(const CVec_UpdateFailMalformedHTLCZ&) = delete;
-       ~CVec_UpdateFailMalformedHTLCZ() { CVec_UpdateFailMalformedHTLCZ_free(self); }
-       CVec_UpdateFailMalformedHTLCZ(CVec_UpdateFailMalformedHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailMalformedHTLCZ)); }
-       CVec_UpdateFailMalformedHTLCZ(LDKCVec_UpdateFailMalformedHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); }
-       operator LDKCVec_UpdateFailMalformedHTLCZ() { LDKCVec_UpdateFailMalformedHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailMalformedHTLCZ)); return res; }
-       LDKCVec_UpdateFailMalformedHTLCZ* operator &() { return &self; }
-       LDKCVec_UpdateFailMalformedHTLCZ* operator ->() { return &self; }
-       const LDKCVec_UpdateFailMalformedHTLCZ* operator &() const { return &self; }
-       const LDKCVec_UpdateFailMalformedHTLCZ* operator ->() const { return &self; }
-};
-class CVec_RouteHopZ {
-private:
-       LDKCVec_RouteHopZ self;
+       LDKCVec_RouteHopZ self;
 public:
        CVec_RouteHopZ(const CVec_RouteHopZ&) = delete;
        ~CVec_RouteHopZ() { CVec_RouteHopZ_free(self); }
@@ -1788,103 +1620,47 @@ public:
        const LDKCVec_RouteHopZ* operator &() const { return &self; }
        const LDKCVec_RouteHopZ* operator ->() const { return &self; }
 };
-class CVec_SpendableOutputDescriptorZ {
-private:
-       LDKCVec_SpendableOutputDescriptorZ self;
-public:
-       CVec_SpendableOutputDescriptorZ(const CVec_SpendableOutputDescriptorZ&) = delete;
-       ~CVec_SpendableOutputDescriptorZ() { CVec_SpendableOutputDescriptorZ_free(self); }
-       CVec_SpendableOutputDescriptorZ(CVec_SpendableOutputDescriptorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SpendableOutputDescriptorZ)); }
-       CVec_SpendableOutputDescriptorZ(LDKCVec_SpendableOutputDescriptorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); }
-       operator LDKCVec_SpendableOutputDescriptorZ() { LDKCVec_SpendableOutputDescriptorZ res = self; memset(&self, 0, sizeof(LDKCVec_SpendableOutputDescriptorZ)); return res; }
-       LDKCVec_SpendableOutputDescriptorZ* operator &() { return &self; }
-       LDKCVec_SpendableOutputDescriptorZ* operator ->() { return &self; }
-       const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; }
-       const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; }
-};
-class CResult_boolLightningErrorZ {
-private:
-       LDKCResult_boolLightningErrorZ self;
-public:
-       CResult_boolLightningErrorZ(const CResult_boolLightningErrorZ&) = delete;
-       ~CResult_boolLightningErrorZ() { CResult_boolLightningErrorZ_free(self); }
-       CResult_boolLightningErrorZ(CResult_boolLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); }
-       CResult_boolLightningErrorZ(LDKCResult_boolLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolLightningErrorZ)); }
-       operator LDKCResult_boolLightningErrorZ() { LDKCResult_boolLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolLightningErrorZ)); return res; }
-       LDKCResult_boolLightningErrorZ* operator &() { return &self; }
-       LDKCResult_boolLightningErrorZ* operator ->() { return &self; }
-       const LDKCResult_boolLightningErrorZ* operator &() const { return &self; }
-       const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; }
-};
-class CResult_NoneAPIErrorZ {
-private:
-       LDKCResult_NoneAPIErrorZ self;
-public:
-       CResult_NoneAPIErrorZ(const CResult_NoneAPIErrorZ&) = delete;
-       ~CResult_NoneAPIErrorZ() { CResult_NoneAPIErrorZ_free(self); }
-       CResult_NoneAPIErrorZ(CResult_NoneAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneAPIErrorZ)); }
-       CResult_NoneAPIErrorZ(LDKCResult_NoneAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); }
-       operator LDKCResult_NoneAPIErrorZ() { LDKCResult_NoneAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); return res; }
-       LDKCResult_NoneAPIErrorZ* operator &() { return &self; }
-       LDKCResult_NoneAPIErrorZ* operator ->() { return &self; }
-       const LDKCResult_NoneAPIErrorZ* operator &() const { return &self; }
-       const LDKCResult_NoneAPIErrorZ* operator ->() const { return &self; }
-};
-class CVec_NetAddressZ {
-private:
-       LDKCVec_NetAddressZ self;
-public:
-       CVec_NetAddressZ(const CVec_NetAddressZ&) = delete;
-       ~CVec_NetAddressZ() { CVec_NetAddressZ_free(self); }
-       CVec_NetAddressZ(CVec_NetAddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NetAddressZ)); }
-       CVec_NetAddressZ(LDKCVec_NetAddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NetAddressZ)); }
-       operator LDKCVec_NetAddressZ() { LDKCVec_NetAddressZ res = self; memset(&self, 0, sizeof(LDKCVec_NetAddressZ)); return res; }
-       LDKCVec_NetAddressZ* operator &() { return &self; }
-       LDKCVec_NetAddressZ* operator ->() { return &self; }
-       const LDKCVec_NetAddressZ* operator &() const { return &self; }
-       const LDKCVec_NetAddressZ* operator ->() const { return &self; }
-};
-class CResult_CVec_u8ZPeerHandleErrorZ {
+class CResult_TxOutAccessErrorZ {
 private:
-       LDKCResult_CVec_u8ZPeerHandleErrorZ self;
+       LDKCResult_TxOutAccessErrorZ self;
 public:
-       CResult_CVec_u8ZPeerHandleErrorZ(const CResult_CVec_u8ZPeerHandleErrorZ&) = delete;
-       ~CResult_CVec_u8ZPeerHandleErrorZ() { CResult_CVec_u8ZPeerHandleErrorZ_free(self); }
-       CResult_CVec_u8ZPeerHandleErrorZ(CResult_CVec_u8ZPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_u8ZPeerHandleErrorZ)); }
-       CResult_CVec_u8ZPeerHandleErrorZ(LDKCResult_CVec_u8ZPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); }
-       operator LDKCResult_CVec_u8ZPeerHandleErrorZ() { LDKCResult_CVec_u8ZPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ)); return res; }
-       LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() { return &self; }
-       LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() { return &self; }
-       const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; }
-       const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; }
+       CResult_TxOutAccessErrorZ(const CResult_TxOutAccessErrorZ&) = delete;
+       ~CResult_TxOutAccessErrorZ() { CResult_TxOutAccessErrorZ_free(self); }
+       CResult_TxOutAccessErrorZ(CResult_TxOutAccessErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxOutAccessErrorZ)); }
+       CResult_TxOutAccessErrorZ(LDKCResult_TxOutAccessErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxOutAccessErrorZ)); }
+       operator LDKCResult_TxOutAccessErrorZ() { LDKCResult_TxOutAccessErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxOutAccessErrorZ)); return res; }
+       LDKCResult_TxOutAccessErrorZ* operator &() { return &self; }
+       LDKCResult_TxOutAccessErrorZ* operator ->() { return &self; }
+       const LDKCResult_TxOutAccessErrorZ* operator &() const { return &self; }
+       const LDKCResult_TxOutAccessErrorZ* operator ->() const { return &self; }
 };
-class CVec_usizeZ {
+class CResult_NoneChannelMonitorUpdateErrZ {
 private:
-       LDKCVec_usizeZ self;
+       LDKCResult_NoneChannelMonitorUpdateErrZ self;
 public:
-       CVec_usizeZ(const CVec_usizeZ&) = delete;
-       ~CVec_usizeZ() { CVec_usizeZ_free(self); }
-       CVec_usizeZ(CVec_usizeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_usizeZ)); }
-       CVec_usizeZ(LDKCVec_usizeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_usizeZ)); }
-       operator LDKCVec_usizeZ() { LDKCVec_usizeZ res = self; memset(&self, 0, sizeof(LDKCVec_usizeZ)); return res; }
-       LDKCVec_usizeZ* operator &() { return &self; }
-       LDKCVec_usizeZ* operator ->() { return &self; }
-       const LDKCVec_usizeZ* operator &() const { return &self; }
-       const LDKCVec_usizeZ* operator ->() const { return &self; }
+       CResult_NoneChannelMonitorUpdateErrZ(const CResult_NoneChannelMonitorUpdateErrZ&) = delete;
+       ~CResult_NoneChannelMonitorUpdateErrZ() { CResult_NoneChannelMonitorUpdateErrZ_free(self); }
+       CResult_NoneChannelMonitorUpdateErrZ(CResult_NoneChannelMonitorUpdateErrZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneChannelMonitorUpdateErrZ)); }
+       CResult_NoneChannelMonitorUpdateErrZ(LDKCResult_NoneChannelMonitorUpdateErrZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ)); }
+       operator LDKCResult_NoneChannelMonitorUpdateErrZ() { LDKCResult_NoneChannelMonitorUpdateErrZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ)); return res; }
+       LDKCResult_NoneChannelMonitorUpdateErrZ* operator &() { return &self; }
+       LDKCResult_NoneChannelMonitorUpdateErrZ* operator ->() { return &self; }
+       const LDKCResult_NoneChannelMonitorUpdateErrZ* operator &() const { return &self; }
+       const LDKCResult_NoneChannelMonitorUpdateErrZ* operator ->() const { return &self; }
 };
-class CResult_NonePeerHandleErrorZ {
+class CResult_NonePaymentSendFailureZ {
 private:
-       LDKCResult_NonePeerHandleErrorZ self;
+       LDKCResult_NonePaymentSendFailureZ self;
 public:
-       CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete;
-       ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); }
-       CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); }
-       CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); }
-       operator LDKCResult_NonePeerHandleErrorZ() { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; }
-       LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; }
-       LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; }
-       const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; }
-       const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; }
+       CResult_NonePaymentSendFailureZ(const CResult_NonePaymentSendFailureZ&) = delete;
+       ~CResult_NonePaymentSendFailureZ() { CResult_NonePaymentSendFailureZ_free(self); }
+       CResult_NonePaymentSendFailureZ(CResult_NonePaymentSendFailureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePaymentSendFailureZ)); }
+       CResult_NonePaymentSendFailureZ(LDKCResult_NonePaymentSendFailureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); }
+       operator LDKCResult_NonePaymentSendFailureZ() { LDKCResult_NonePaymentSendFailureZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePaymentSendFailureZ)); return res; }
+       LDKCResult_NonePaymentSendFailureZ* operator &() { return &self; }
+       LDKCResult_NonePaymentSendFailureZ* operator ->() { return &self; }
+       const LDKCResult_NonePaymentSendFailureZ* operator &() const { return &self; }
+       const LDKCResult_NonePaymentSendFailureZ* operator ->() const { return &self; }
 };
 class CResult_TxCreationKeysSecpErrorZ {
 private:
@@ -1900,33 +1676,47 @@ public:
        const LDKCResult_TxCreationKeysSecpErrorZ* operator &() const { return &self; }
        const LDKCResult_TxCreationKeysSecpErrorZ* operator ->() const { return &self; }
 };
-class CVec_PublicKeyZ {
+class CVec_u8Z {
 private:
-       LDKCVec_PublicKeyZ self;
+       LDKCVec_u8Z self;
 public:
-       CVec_PublicKeyZ(const CVec_PublicKeyZ&) = delete;
-       ~CVec_PublicKeyZ() { CVec_PublicKeyZ_free(self); }
-       CVec_PublicKeyZ(CVec_PublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PublicKeyZ)); }
-       CVec_PublicKeyZ(LDKCVec_PublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PublicKeyZ)); }
-       operator LDKCVec_PublicKeyZ() { LDKCVec_PublicKeyZ res = self; memset(&self, 0, sizeof(LDKCVec_PublicKeyZ)); return res; }
-       LDKCVec_PublicKeyZ* operator &() { return &self; }
-       LDKCVec_PublicKeyZ* operator ->() { return &self; }
-       const LDKCVec_PublicKeyZ* operator &() const { return &self; }
-       const LDKCVec_PublicKeyZ* operator ->() const { return &self; }
+       CVec_u8Z(const CVec_u8Z&) = delete;
+       ~CVec_u8Z() { CVec_u8Z_free(self); }
+       CVec_u8Z(CVec_u8Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_u8Z)); }
+       CVec_u8Z(LDKCVec_u8Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_u8Z)); }
+       operator LDKCVec_u8Z() { LDKCVec_u8Z res = self; memset(&self, 0, sizeof(LDKCVec_u8Z)); return res; }
+       LDKCVec_u8Z* operator &() { return &self; }
+       LDKCVec_u8Z* operator ->() { return &self; }
+       const LDKCVec_u8Z* operator &() const { return &self; }
+       const LDKCVec_u8Z* operator ->() const { return &self; }
 };
-class CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+class CResult_PublicKeySecpErrorZ {
 private:
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ self;
+       LDKCResult_PublicKeySecpErrorZ self;
 public:
-       CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(const CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&) = delete;
-       ~CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(self); }
-       CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); }
-       CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); }
-       operator LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ() { LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ)); return res; }
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() { return &self; }
-       LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() { return &self; }
-       const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator &() const { return &self; }
-       const LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* operator ->() const { return &self; }
+       CResult_PublicKeySecpErrorZ(const CResult_PublicKeySecpErrorZ&) = delete;
+       ~CResult_PublicKeySecpErrorZ() { CResult_PublicKeySecpErrorZ_free(self); }
+       CResult_PublicKeySecpErrorZ(CResult_PublicKeySecpErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PublicKeySecpErrorZ)); }
+       CResult_PublicKeySecpErrorZ(LDKCResult_PublicKeySecpErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); }
+       operator LDKCResult_PublicKeySecpErrorZ() { LDKCResult_PublicKeySecpErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PublicKeySecpErrorZ)); return res; }
+       LDKCResult_PublicKeySecpErrorZ* operator &() { return &self; }
+       LDKCResult_PublicKeySecpErrorZ* operator ->() { return &self; }
+       const LDKCResult_PublicKeySecpErrorZ* operator &() const { return &self; }
+       const LDKCResult_PublicKeySecpErrorZ* operator ->() const { return &self; }
+};
+class CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ {
+private:
+       LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ self;
+public:
+       CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(const CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&) = delete;
+       ~CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(self); }
+       CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); }
+       CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); }
+       operator LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); return res; }
+       LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() { return &self; }
+       LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() { return &self; }
+       const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() const { return &self; }
+       const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() const { return &self; }
 };
 class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
 private:
@@ -1942,51 +1732,23 @@ public:
        const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; }
        const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; }
 };
-class CVec_MessageSendEventZ {
+class CVec_CVec_RouteHopZZ {
 private:
-       LDKCVec_MessageSendEventZ self;
+       LDKCVec_CVec_RouteHopZZ self;
 public:
-       CVec_MessageSendEventZ(const CVec_MessageSendEventZ&) = delete;
-       ~CVec_MessageSendEventZ() { CVec_MessageSendEventZ_free(self); }
-       CVec_MessageSendEventZ(CVec_MessageSendEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MessageSendEventZ)); }
-       CVec_MessageSendEventZ(LDKCVec_MessageSendEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MessageSendEventZ)); }
-       operator LDKCVec_MessageSendEventZ() { LDKCVec_MessageSendEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MessageSendEventZ)); return res; }
-       LDKCVec_MessageSendEventZ* operator &() { return &self; }
-       LDKCVec_MessageSendEventZ* operator ->() { return &self; }
-       const LDKCVec_MessageSendEventZ* operator &() const { return &self; }
-       const LDKCVec_MessageSendEventZ* operator ->() const { return &self; }
+       CVec_CVec_RouteHopZZ(const CVec_CVec_RouteHopZZ&) = delete;
+       ~CVec_CVec_RouteHopZZ() { CVec_CVec_RouteHopZZ_free(self); }
+       CVec_CVec_RouteHopZZ(CVec_CVec_RouteHopZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_CVec_RouteHopZZ)); }
+       CVec_CVec_RouteHopZZ(LDKCVec_CVec_RouteHopZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); }
+       operator LDKCVec_CVec_RouteHopZZ() { LDKCVec_CVec_RouteHopZZ res = self; memset(&self, 0, sizeof(LDKCVec_CVec_RouteHopZZ)); return res; }
+       LDKCVec_CVec_RouteHopZZ* operator &() { return &self; }
+       LDKCVec_CVec_RouteHopZZ* operator ->() { return &self; }
+       const LDKCVec_CVec_RouteHopZZ* operator &() const { return &self; }
+       const LDKCVec_CVec_RouteHopZZ* operator ->() const { return &self; }
 };
-class CVec_UpdateFailHTLCZ {
+class CVec_UpdateAddHTLCZ {
 private:
-       LDKCVec_UpdateFailHTLCZ self;
-public:
-       CVec_UpdateFailHTLCZ(const CVec_UpdateFailHTLCZ&) = delete;
-       ~CVec_UpdateFailHTLCZ() { CVec_UpdateFailHTLCZ_free(self); }
-       CVec_UpdateFailHTLCZ(CVec_UpdateFailHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFailHTLCZ)); }
-       CVec_UpdateFailHTLCZ(LDKCVec_UpdateFailHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); }
-       operator LDKCVec_UpdateFailHTLCZ() { LDKCVec_UpdateFailHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFailHTLCZ)); return res; }
-       LDKCVec_UpdateFailHTLCZ* operator &() { return &self; }
-       LDKCVec_UpdateFailHTLCZ* operator ->() { return &self; }
-       const LDKCVec_UpdateFailHTLCZ* operator &() const { return &self; }
-       const LDKCVec_UpdateFailHTLCZ* operator ->() const { return &self; }
-};
-class CVec_UpdateFulfillHTLCZ {
-private:
-       LDKCVec_UpdateFulfillHTLCZ self;
-public:
-       CVec_UpdateFulfillHTLCZ(const CVec_UpdateFulfillHTLCZ&) = delete;
-       ~CVec_UpdateFulfillHTLCZ() { CVec_UpdateFulfillHTLCZ_free(self); }
-       CVec_UpdateFulfillHTLCZ(CVec_UpdateFulfillHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFulfillHTLCZ)); }
-       CVec_UpdateFulfillHTLCZ(LDKCVec_UpdateFulfillHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); }
-       operator LDKCVec_UpdateFulfillHTLCZ() { LDKCVec_UpdateFulfillHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); return res; }
-       LDKCVec_UpdateFulfillHTLCZ* operator &() { return &self; }
-       LDKCVec_UpdateFulfillHTLCZ* operator ->() { return &self; }
-       const LDKCVec_UpdateFulfillHTLCZ* operator &() const { return &self; }
-       const LDKCVec_UpdateFulfillHTLCZ* operator ->() const { return &self; }
-};
-class CVec_UpdateAddHTLCZ {
-private:
-       LDKCVec_UpdateAddHTLCZ self;
+       LDKCVec_UpdateAddHTLCZ self;
 public:
        CVec_UpdateAddHTLCZ(const CVec_UpdateAddHTLCZ&) = delete;
        ~CVec_UpdateAddHTLCZ() { CVec_UpdateAddHTLCZ_free(self); }
@@ -1998,47 +1760,89 @@ public:
        const LDKCVec_UpdateAddHTLCZ* operator &() const { return &self; }
        const LDKCVec_UpdateAddHTLCZ* operator ->() const { return &self; }
 };
-class CVec_EventZ {
+class CResult_NonePeerHandleErrorZ {
 private:
-       LDKCVec_EventZ self;
+       LDKCResult_NonePeerHandleErrorZ self;
 public:
-       CVec_EventZ(const CVec_EventZ&) = delete;
-       ~CVec_EventZ() { CVec_EventZ_free(self); }
-       CVec_EventZ(CVec_EventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_EventZ)); }
-       CVec_EventZ(LDKCVec_EventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_EventZ)); }
-       operator LDKCVec_EventZ() { LDKCVec_EventZ res = self; memset(&self, 0, sizeof(LDKCVec_EventZ)); return res; }
-       LDKCVec_EventZ* operator &() { return &self; }
-       LDKCVec_EventZ* operator ->() { return &self; }
-       const LDKCVec_EventZ* operator &() const { return &self; }
-       const LDKCVec_EventZ* operator ->() const { return &self; }
+       CResult_NonePeerHandleErrorZ(const CResult_NonePeerHandleErrorZ&) = delete;
+       ~CResult_NonePeerHandleErrorZ() { CResult_NonePeerHandleErrorZ_free(self); }
+       CResult_NonePeerHandleErrorZ(CResult_NonePeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonePeerHandleErrorZ)); }
+       CResult_NonePeerHandleErrorZ(LDKCResult_NonePeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); }
+       operator LDKCResult_NonePeerHandleErrorZ() { LDKCResult_NonePeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonePeerHandleErrorZ)); return res; }
+       LDKCResult_NonePeerHandleErrorZ* operator &() { return &self; }
+       LDKCResult_NonePeerHandleErrorZ* operator ->() { return &self; }
+       const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; }
+       const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; }
 };
-class CVec_SignatureZ {
+class CResult_boolPeerHandleErrorZ {
 private:
-       LDKCVec_SignatureZ self;
+       LDKCResult_boolPeerHandleErrorZ self;
 public:
-       CVec_SignatureZ(const CVec_SignatureZ&) = delete;
-       ~CVec_SignatureZ() { CVec_SignatureZ_free(self); }
-       CVec_SignatureZ(CVec_SignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_SignatureZ)); }
-       CVec_SignatureZ(LDKCVec_SignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_SignatureZ)); }
-       operator LDKCVec_SignatureZ() { LDKCVec_SignatureZ res = self; memset(&self, 0, sizeof(LDKCVec_SignatureZ)); return res; }
-       LDKCVec_SignatureZ* operator &() { return &self; }
-       LDKCVec_SignatureZ* operator ->() { return &self; }
-       const LDKCVec_SignatureZ* operator &() const { return &self; }
-       const LDKCVec_SignatureZ* operator ->() const { return &self; }
+       CResult_boolPeerHandleErrorZ(const CResult_boolPeerHandleErrorZ&) = delete;
+       ~CResult_boolPeerHandleErrorZ() { CResult_boolPeerHandleErrorZ_free(self); }
+       CResult_boolPeerHandleErrorZ(CResult_boolPeerHandleErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolPeerHandleErrorZ)); }
+       CResult_boolPeerHandleErrorZ(LDKCResult_boolPeerHandleErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); }
+       operator LDKCResult_boolPeerHandleErrorZ() { LDKCResult_boolPeerHandleErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolPeerHandleErrorZ)); return res; }
+       LDKCResult_boolPeerHandleErrorZ* operator &() { return &self; }
+       LDKCResult_boolPeerHandleErrorZ* operator ->() { return &self; }
+       const LDKCResult_boolPeerHandleErrorZ* operator &() const { return &self; }
+       const LDKCResult_boolPeerHandleErrorZ* operator ->() const { return &self; }
 };
-class CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ {
+class CVec_RouteHintZ {
 private:
-       LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ self;
+       LDKCVec_RouteHintZ self;
 public:
-       CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(const CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&) = delete;
-       ~CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ_free(self); }
-       CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); }
-       CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); }
-       operator LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ() { LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ)); return res; }
-       LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() { return &self; }
-       LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() { return &self; }
-       const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator &() const { return &self; }
-       const LDKCVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ* operator ->() const { return &self; }
+       CVec_RouteHintZ(const CVec_RouteHintZ&) = delete;
+       ~CVec_RouteHintZ() { CVec_RouteHintZ_free(self); }
+       CVec_RouteHintZ(CVec_RouteHintZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_RouteHintZ)); }
+       CVec_RouteHintZ(LDKCVec_RouteHintZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_RouteHintZ)); }
+       operator LDKCVec_RouteHintZ() { LDKCVec_RouteHintZ res = self; memset(&self, 0, sizeof(LDKCVec_RouteHintZ)); return res; }
+       LDKCVec_RouteHintZ* operator &() { return &self; }
+       LDKCVec_RouteHintZ* operator ->() { return &self; }
+       const LDKCVec_RouteHintZ* operator &() const { return &self; }
+       const LDKCVec_RouteHintZ* operator ->() const { return &self; }
+};
+class CResult_RouteLightningErrorZ {
+private:
+       LDKCResult_RouteLightningErrorZ self;
+public:
+       CResult_RouteLightningErrorZ(const CResult_RouteLightningErrorZ&) = delete;
+       ~CResult_RouteLightningErrorZ() { CResult_RouteLightningErrorZ_free(self); }
+       CResult_RouteLightningErrorZ(CResult_RouteLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RouteLightningErrorZ)); }
+       CResult_RouteLightningErrorZ(LDKCResult_RouteLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); }
+       operator LDKCResult_RouteLightningErrorZ() { LDKCResult_RouteLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RouteLightningErrorZ)); return res; }
+       LDKCResult_RouteLightningErrorZ* operator &() { return &self; }
+       LDKCResult_RouteLightningErrorZ* operator ->() { return &self; }
+       const LDKCResult_RouteLightningErrorZ* operator &() const { return &self; }
+       const LDKCResult_RouteLightningErrorZ* operator ->() const { return &self; }
+};
+class CResult_CVec_SignatureZNoneZ {
+private:
+       LDKCResult_CVec_SignatureZNoneZ self;
+public:
+       CResult_CVec_SignatureZNoneZ(const CResult_CVec_SignatureZNoneZ&) = delete;
+       ~CResult_CVec_SignatureZNoneZ() { CResult_CVec_SignatureZNoneZ_free(self); }
+       CResult_CVec_SignatureZNoneZ(CResult_CVec_SignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_SignatureZNoneZ)); }
+       CResult_CVec_SignatureZNoneZ(LDKCResult_CVec_SignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); }
+       operator LDKCResult_CVec_SignatureZNoneZ() { LDKCResult_CVec_SignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_SignatureZNoneZ)); return res; }
+       LDKCResult_CVec_SignatureZNoneZ* operator &() { return &self; }
+       LDKCResult_CVec_SignatureZNoneZ* operator ->() { return &self; }
+       const LDKCResult_CVec_SignatureZNoneZ* operator &() const { return &self; }
+       const LDKCResult_CVec_SignatureZNoneZ* operator ->() const { return &self; }
+};
+class CVec_UpdateFulfillHTLCZ {
+private:
+       LDKCVec_UpdateFulfillHTLCZ self;
+public:
+       CVec_UpdateFulfillHTLCZ(const CVec_UpdateFulfillHTLCZ&) = delete;
+       ~CVec_UpdateFulfillHTLCZ() { CVec_UpdateFulfillHTLCZ_free(self); }
+       CVec_UpdateFulfillHTLCZ(CVec_UpdateFulfillHTLCZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_UpdateFulfillHTLCZ)); }
+       CVec_UpdateFulfillHTLCZ(LDKCVec_UpdateFulfillHTLCZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); }
+       operator LDKCVec_UpdateFulfillHTLCZ() { LDKCVec_UpdateFulfillHTLCZ res = self; memset(&self, 0, sizeof(LDKCVec_UpdateFulfillHTLCZ)); return res; }
+       LDKCVec_UpdateFulfillHTLCZ* operator &() { return &self; }
+       LDKCVec_UpdateFulfillHTLCZ* operator ->() { return &self; }
+       const LDKCVec_UpdateFulfillHTLCZ* operator &() const { return &self; }
+       const LDKCVec_UpdateFulfillHTLCZ* operator ->() const { return &self; }
 };
 class CResult_SignatureNoneZ {
 private:
@@ -2054,4 +1858,200 @@ public:
        const LDKCResult_SignatureNoneZ* operator &() const { return &self; }
        const LDKCResult_SignatureNoneZ* operator ->() const { return &self; }
 };
+class C2Tuple_TxidCVec_TxOutZZ {
+private:
+       LDKC2Tuple_TxidCVec_TxOutZZ self;
+public:
+       C2Tuple_TxidCVec_TxOutZZ(const C2Tuple_TxidCVec_TxOutZZ&) = delete;
+       ~C2Tuple_TxidCVec_TxOutZZ() { C2Tuple_TxidCVec_TxOutZZ_free(self); }
+       C2Tuple_TxidCVec_TxOutZZ(C2Tuple_TxidCVec_TxOutZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_TxidCVec_TxOutZZ)); }
+       C2Tuple_TxidCVec_TxOutZZ(LDKC2Tuple_TxidCVec_TxOutZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_TxidCVec_TxOutZZ)); }
+       operator LDKC2Tuple_TxidCVec_TxOutZZ() { LDKC2Tuple_TxidCVec_TxOutZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_TxidCVec_TxOutZZ)); return res; }
+       LDKC2Tuple_TxidCVec_TxOutZZ* operator &() { return &self; }
+       LDKC2Tuple_TxidCVec_TxOutZZ* operator ->() { return &self; }
+       const LDKC2Tuple_TxidCVec_TxOutZZ* operator &() const { return &self; }
+       const LDKC2Tuple_TxidCVec_TxOutZZ* operator ->() const { return &self; }
+};
+class CVec_ChannelDetailsZ {
+private:
+       LDKCVec_ChannelDetailsZ self;
+public:
+       CVec_ChannelDetailsZ(const CVec_ChannelDetailsZ&) = delete;
+       ~CVec_ChannelDetailsZ() { CVec_ChannelDetailsZ_free(self); }
+       CVec_ChannelDetailsZ(CVec_ChannelDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelDetailsZ)); }
+       CVec_ChannelDetailsZ(LDKCVec_ChannelDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelDetailsZ)); }
+       operator LDKCVec_ChannelDetailsZ() { LDKCVec_ChannelDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelDetailsZ)); return res; }
+       LDKCVec_ChannelDetailsZ* operator &() { return &self; }
+       LDKCVec_ChannelDetailsZ* operator ->() { return &self; }
+       const LDKCVec_ChannelDetailsZ* operator &() const { return &self; }
+       const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; }
+};
+class CVec_MessageSendEventZ {
+private:
+       LDKCVec_MessageSendEventZ self;
+public:
+       CVec_MessageSendEventZ(const CVec_MessageSendEventZ&) = delete;
+       ~CVec_MessageSendEventZ() { CVec_MessageSendEventZ_free(self); }
+       CVec_MessageSendEventZ(CVec_MessageSendEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MessageSendEventZ)); }
+       CVec_MessageSendEventZ(LDKCVec_MessageSendEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MessageSendEventZ)); }
+       operator LDKCVec_MessageSendEventZ() { LDKCVec_MessageSendEventZ res = self; memset(&self, 0, sizeof(LDKCVec_MessageSendEventZ)); return res; }
+       LDKCVec_MessageSendEventZ* operator &() { return &self; }
+       LDKCVec_MessageSendEventZ* operator ->() { return &self; }
+       const LDKCVec_MessageSendEventZ* operator &() const { return &self; }
+       const LDKCVec_MessageSendEventZ* operator ->() const { return &self; }
+};
+class CResult_NoneAPIErrorZ {
+private:
+       LDKCResult_NoneAPIErrorZ self;
+public:
+       CResult_NoneAPIErrorZ(const CResult_NoneAPIErrorZ&) = delete;
+       ~CResult_NoneAPIErrorZ() { CResult_NoneAPIErrorZ_free(self); }
+       CResult_NoneAPIErrorZ(CResult_NoneAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneAPIErrorZ)); }
+       CResult_NoneAPIErrorZ(LDKCResult_NoneAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); }
+       operator LDKCResult_NoneAPIErrorZ() { LDKCResult_NoneAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneAPIErrorZ)); return res; }
+       LDKCResult_NoneAPIErrorZ* operator &() { return &self; }
+       LDKCResult_NoneAPIErrorZ* operator ->() { return &self; }
+       const LDKCResult_NoneAPIErrorZ* operator &() const { return &self; }
+       const LDKCResult_NoneAPIErrorZ* operator ->() const { return &self; }
+};
+class C2Tuple_OutPointScriptZ {
+private:
+       LDKC2Tuple_OutPointScriptZ self;
+public:
+       C2Tuple_OutPointScriptZ(const C2Tuple_OutPointScriptZ&) = delete;
+       ~C2Tuple_OutPointScriptZ() { C2Tuple_OutPointScriptZ_free(self); }
+       C2Tuple_OutPointScriptZ(C2Tuple_OutPointScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointScriptZ)); }
+       C2Tuple_OutPointScriptZ(LDKC2Tuple_OutPointScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); }
+       operator LDKC2Tuple_OutPointScriptZ() { LDKC2Tuple_OutPointScriptZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointScriptZ)); return res; }
+       LDKC2Tuple_OutPointScriptZ* operator &() { return &self; }
+       LDKC2Tuple_OutPointScriptZ* operator ->() { return &self; }
+       const LDKC2Tuple_OutPointScriptZ* operator &() const { return &self; }
+       const LDKC2Tuple_OutPointScriptZ* operator ->() const { return &self; }
+};
+class CVec_NetAddressZ {
+private:
+       LDKCVec_NetAddressZ self;
+public:
+       CVec_NetAddressZ(const CVec_NetAddressZ&) = delete;
+       ~CVec_NetAddressZ() { CVec_NetAddressZ_free(self); }
+       CVec_NetAddressZ(CVec_NetAddressZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_NetAddressZ)); }
+       CVec_NetAddressZ(LDKCVec_NetAddressZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_NetAddressZ)); }
+       operator LDKCVec_NetAddressZ() { LDKCVec_NetAddressZ res = self; memset(&self, 0, sizeof(LDKCVec_NetAddressZ)); return res; }
+       LDKCVec_NetAddressZ* operator &() { return &self; }
+       LDKCVec_NetAddressZ* operator ->() { return &self; }
+       const LDKCVec_NetAddressZ* operator &() const { return &self; }
+       const LDKCVec_NetAddressZ* operator ->() const { return &self; }
+};
+class CVec_TxOutZ {
+private:
+       LDKCVec_TxOutZ self;
+public:
+       CVec_TxOutZ(const CVec_TxOutZ&) = delete;
+       ~CVec_TxOutZ() { CVec_TxOutZ_free(self); }
+       CVec_TxOutZ(CVec_TxOutZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TxOutZ)); }
+       CVec_TxOutZ(LDKCVec_TxOutZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TxOutZ)); }
+       operator LDKCVec_TxOutZ() { LDKCVec_TxOutZ res = self; memset(&self, 0, sizeof(LDKCVec_TxOutZ)); return res; }
+       LDKCVec_TxOutZ* operator &() { return &self; }
+       LDKCVec_TxOutZ* operator ->() { return &self; }
+       const LDKCVec_TxOutZ* operator &() const { return &self; }
+       const LDKCVec_TxOutZ* operator ->() const { return &self; }
+};
+class C2Tuple_usizeTransactionZ {
+private:
+       LDKC2Tuple_usizeTransactionZ self;
+public:
+       C2Tuple_usizeTransactionZ(const C2Tuple_usizeTransactionZ&) = delete;
+       ~C2Tuple_usizeTransactionZ() { C2Tuple_usizeTransactionZ_free(self); }
+       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; }
+       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 CVec_C2Tuple_usizeTransactionZZ {
+private:
+       LDKCVec_C2Tuple_usizeTransactionZZ self;
+public:
+       CVec_C2Tuple_usizeTransactionZZ(const CVec_C2Tuple_usizeTransactionZZ&) = delete;
+       ~CVec_C2Tuple_usizeTransactionZZ() { CVec_C2Tuple_usizeTransactionZZ_free(self); }
+       CVec_C2Tuple_usizeTransactionZZ(CVec_C2Tuple_usizeTransactionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_usizeTransactionZZ)); }
+       CVec_C2Tuple_usizeTransactionZZ(LDKCVec_C2Tuple_usizeTransactionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_usizeTransactionZZ)); }
+       operator LDKCVec_C2Tuple_usizeTransactionZZ() { LDKCVec_C2Tuple_usizeTransactionZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_usizeTransactionZZ)); return res; }
+       LDKCVec_C2Tuple_usizeTransactionZZ* operator &() { return &self; }
+       LDKCVec_C2Tuple_usizeTransactionZZ* operator ->() { return &self; }
+       const LDKCVec_C2Tuple_usizeTransactionZZ* operator &() const { return &self; }
+       const LDKCVec_C2Tuple_usizeTransactionZZ* operator ->() const { return &self; }
+};
+class CVec_ChannelMonitorZ {
+private:
+       LDKCVec_ChannelMonitorZ self;
+public:
+       CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete;
+       ~CVec_ChannelMonitorZ() { CVec_ChannelMonitorZ_free(self); }
+       CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); }
+       CVec_ChannelMonitorZ(LDKCVec_ChannelMonitorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelMonitorZ)); }
+       operator LDKCVec_ChannelMonitorZ() { LDKCVec_ChannelMonitorZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelMonitorZ)); return res; }
+       LDKCVec_ChannelMonitorZ* operator &() { return &self; }
+       LDKCVec_ChannelMonitorZ* operator ->() { return &self; }
+       const LDKCVec_ChannelMonitorZ* operator &() const { return &self; }
+       const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; }
+};
+class CVec_TransactionZ {
+private:
+       LDKCVec_TransactionZ self;
+public:
+       CVec_TransactionZ(const CVec_TransactionZ&) = delete;
+       ~CVec_TransactionZ() { CVec_TransactionZ_free(self); }
+       CVec_TransactionZ(CVec_TransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TransactionZ)); }
+       CVec_TransactionZ(LDKCVec_TransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TransactionZ)); }
+       operator LDKCVec_TransactionZ() { LDKCVec_TransactionZ res = self; memset(&self, 0, sizeof(LDKCVec_TransactionZ)); return res; }
+       LDKCVec_TransactionZ* operator &() { return &self; }
+       LDKCVec_TransactionZ* operator ->() { return &self; }
+       const LDKCVec_TransactionZ* operator &() const { return &self; }
+       const LDKCVec_TransactionZ* operator ->() const { return &self; }
+};
+class CVec_C2Tuple_TxidCVec_TxOutZZZ {
+private:
+       LDKCVec_C2Tuple_TxidCVec_TxOutZZZ self;
+public:
+       CVec_C2Tuple_TxidCVec_TxOutZZZ(const CVec_C2Tuple_TxidCVec_TxOutZZZ&) = delete;
+       ~CVec_C2Tuple_TxidCVec_TxOutZZZ() { CVec_C2Tuple_TxidCVec_TxOutZZZ_free(self); }
+       CVec_C2Tuple_TxidCVec_TxOutZZZ(CVec_C2Tuple_TxidCVec_TxOutZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_TxidCVec_TxOutZZZ)); }
+       CVec_C2Tuple_TxidCVec_TxOutZZZ(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ)); }
+       operator LDKCVec_C2Tuple_TxidCVec_TxOutZZZ() { LDKCVec_C2Tuple_TxidCVec_TxOutZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_TxidCVec_TxOutZZZ)); return res; }
+       LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* operator &() { return &self; }
+       LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* operator ->() { return &self; }
+       const LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* operator &() const { return &self; }
+       const LDKCVec_C2Tuple_TxidCVec_TxOutZZZ* operator ->() const { return &self; }
+};
+class C2Tuple_u64u64Z {
+private:
+       LDKC2Tuple_u64u64Z self;
+public:
+       C2Tuple_u64u64Z(const C2Tuple_u64u64Z&) = delete;
+       ~C2Tuple_u64u64Z() { C2Tuple_u64u64Z_free(self); }
+       C2Tuple_u64u64Z(C2Tuple_u64u64Z&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_u64u64Z)); }
+       C2Tuple_u64u64Z(LDKC2Tuple_u64u64Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_u64u64Z)); }
+       operator LDKC2Tuple_u64u64Z() { LDKC2Tuple_u64u64Z res = self; memset(&self, 0, sizeof(LDKC2Tuple_u64u64Z)); return res; }
+       LDKC2Tuple_u64u64Z* operator &() { return &self; }
+       LDKC2Tuple_u64u64Z* operator ->() { return &self; }
+       const LDKC2Tuple_u64u64Z* operator &() const { return &self; }
+       const LDKC2Tuple_u64u64Z* operator ->() const { return &self; }
+};
+class CVec_HTLCOutputInCommitmentZ {
+private:
+       LDKCVec_HTLCOutputInCommitmentZ self;
+public:
+       CVec_HTLCOutputInCommitmentZ(const CVec_HTLCOutputInCommitmentZ&) = delete;
+       ~CVec_HTLCOutputInCommitmentZ() { CVec_HTLCOutputInCommitmentZ_free(self); }
+       CVec_HTLCOutputInCommitmentZ(CVec_HTLCOutputInCommitmentZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_HTLCOutputInCommitmentZ)); }
+       CVec_HTLCOutputInCommitmentZ(LDKCVec_HTLCOutputInCommitmentZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); }
+       operator LDKCVec_HTLCOutputInCommitmentZ() { LDKCVec_HTLCOutputInCommitmentZ res = self; memset(&self, 0, sizeof(LDKCVec_HTLCOutputInCommitmentZ)); return res; }
+       LDKCVec_HTLCOutputInCommitmentZ* operator &() { return &self; }
+       LDKCVec_HTLCOutputInCommitmentZ* operator ->() { return &self; }
+       const LDKCVec_HTLCOutputInCommitmentZ* operator &() const { return &self; }
+       const LDKCVec_HTLCOutputInCommitmentZ* operator ->() const { return &self; }
+};
 }
index e328836e1bc7416abc4c795b2402054632ace747..ca6cdc69fa95cc4fa20ce4223797bfe6025071da 100644 (file)
@@ -16,12 +16,18 @@ struct nativeChannelConfigOpaque;
 typedef struct nativeChannelConfigOpaque LDKnativeChannelConfig;
 struct nativeUserConfigOpaque;
 typedef struct nativeUserConfigOpaque LDKnativeUserConfig;
-struct nativeChainWatchedUtilOpaque;
-typedef struct nativeChainWatchedUtilOpaque LDKnativeChainWatchedUtil;
-struct nativeBlockNotifierOpaque;
-typedef struct nativeBlockNotifierOpaque LDKnativeBlockNotifier;
-struct nativeChainWatchInterfaceUtilOpaque;
-typedef struct nativeChainWatchInterfaceUtilOpaque LDKnativeChainWatchInterfaceUtil;
+struct nativeChainMonitorOpaque;
+typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor;
+struct nativeChannelMonitorUpdateOpaque;
+typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate;
+struct nativeMonitorUpdateErrorOpaque;
+typedef struct nativeMonitorUpdateErrorOpaque LDKnativeMonitorUpdateError;
+struct nativeMonitorEventOpaque;
+typedef struct nativeMonitorEventOpaque LDKnativeMonitorEvent;
+struct nativeHTLCUpdateOpaque;
+typedef struct nativeHTLCUpdateOpaque LDKnativeHTLCUpdate;
+struct nativeChannelMonitorOpaque;
+typedef struct nativeChannelMonitorOpaque LDKnativeChannelMonitor;
 struct nativeOutPointOpaque;
 typedef struct nativeOutPointOpaque LDKnativeOutPoint;
 struct LDKChannelKeys;
@@ -38,16 +44,6 @@ struct nativePaymentSendFailureOpaque;
 typedef struct nativePaymentSendFailureOpaque LDKnativePaymentSendFailure;
 struct nativeChannelManagerReadArgsOpaque;
 typedef struct nativeChannelManagerReadArgsOpaque LDKnativeChannelManagerReadArgs;
-struct nativeChannelMonitorUpdateOpaque;
-typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate;
-struct nativeMonitorUpdateErrorOpaque;
-typedef struct nativeMonitorUpdateErrorOpaque LDKnativeMonitorUpdateError;
-struct nativeMonitorEventOpaque;
-typedef struct nativeMonitorEventOpaque LDKnativeMonitorEvent;
-struct nativeHTLCUpdateOpaque;
-typedef struct nativeHTLCUpdateOpaque LDKnativeHTLCUpdate;
-struct nativeChannelMonitorOpaque;
-typedef struct nativeChannelMonitorOpaque LDKnativeChannelMonitor;
 struct nativeDecodeErrorOpaque;
 typedef struct nativeDecodeErrorOpaque LDKnativeDecodeError;
 struct nativeInitOpaque;
index 16463a1894e33c13db7da4467ece14a4512ba0bc..d084a1562274f26f865d1ce0a499fb97631631ee 100644 (file)
@@ -14,50 +14,82 @@ pub type CVec_EventZ = crate::c_types::CVecTempl<crate::util::events::Event>;
 pub static CVec_EventZ_free: extern "C" fn(CVec_EventZ) = crate::c_types::CVecTempl_free::<crate::util::events::Event>;
 
 #[no_mangle]
-pub type C2Tuple_Txidu32Z = crate::c_types::C2TupleTempl<crate::c_types::ThirtyTwoBytes, u32>;
+pub type C2Tuple_usizeTransactionZ = crate::c_types::C2TupleTempl<usize, crate::c_types::Transaction>;
 #[no_mangle]
-pub static C2Tuple_Txidu32Z_free: extern "C" fn(C2Tuple_Txidu32Z) = crate::c_types::C2TupleTempl_free::<crate::c_types::ThirtyTwoBytes, u32>;
+pub static C2Tuple_usizeTransactionZ_free: extern "C" fn(C2Tuple_usizeTransactionZ) = crate::c_types::C2TupleTempl_free::<usize, crate::c_types::Transaction>;
 #[no_mangle]
-pub extern "C" fn C2Tuple_Txidu32Z_new(a: crate::c_types::ThirtyTwoBytes, b: u32) -> C2Tuple_Txidu32Z {
-       C2Tuple_Txidu32Z {
-               a: Box::into_raw(Box::new(a)),
-               b: Box::into_raw(Box::new(b)),
-       }
+pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ {
+       C2Tuple_usizeTransactionZ { a, b, }
 }
 
 #[no_mangle]
-pub type C2Tuple_Scriptu64Z = crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>;
+pub type CVec_C2Tuple_usizeTransactionZZ = crate::c_types::CVecTempl<crate::c_types::C2TupleTempl<usize, crate::c_types::Transaction>>;
 #[no_mangle]
-pub static C2Tuple_Scriptu64Z_free: extern "C" fn(C2Tuple_Scriptu64Z) = crate::c_types::C2TupleTempl_free::<crate::c_types::derived::CVec_u8Z, u64>;
+pub static CVec_C2Tuple_usizeTransactionZZ_free: extern "C" fn(CVec_C2Tuple_usizeTransactionZZ) = crate::c_types::CVecTempl_free::<crate::c_types::C2TupleTempl<usize, crate::c_types::Transaction>>;
+
+#[no_mangle]
+pub type CResult_NoneChannelMonitorUpdateErrZ = crate::c_types::CResultTempl<u8, crate::chain::channelmonitor::ChannelMonitorUpdateErr>;
+#[no_mangle]
+pub static CResult_NoneChannelMonitorUpdateErrZ_free: extern "C" fn(CResult_NoneChannelMonitorUpdateErrZ) = crate::c_types::CResultTempl_free::<u8, crate::chain::channelmonitor::ChannelMonitorUpdateErr>;
+#[no_mangle]
+pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChannelMonitorUpdateErrZ {
+       crate::c_types::CResultTempl::ok(0)
+}
+
 #[no_mangle]
-pub extern "C" fn C2Tuple_Scriptu64Z_new(a: crate::c_types::derived::CVec_u8Z, b: u64) -> C2Tuple_Scriptu64Z {
-       C2Tuple_Scriptu64Z {
-               a: Box::into_raw(Box::new(a)),
-               b: Box::into_raw(Box::new(b)),
-       }
+pub static CResult_NoneChannelMonitorUpdateErrZ_err: extern "C" fn (crate::chain::channelmonitor::ChannelMonitorUpdateErr) -> CResult_NoneChannelMonitorUpdateErrZ =
+       crate::c_types::CResultTempl::<u8, crate::chain::channelmonitor::ChannelMonitorUpdateErr>::err;
+
+#[no_mangle]
+pub type CVec_MonitorEventZ = crate::c_types::CVecTempl<crate::chain::channelmonitor::MonitorEvent>;
+#[no_mangle]
+pub static CVec_MonitorEventZ_free: extern "C" fn(CVec_MonitorEventZ) = crate::c_types::CVecTempl_free::<crate::chain::channelmonitor::MonitorEvent>;
+
+#[no_mangle]
+pub type CResult_NoneMonitorUpdateErrorZ = crate::c_types::CResultTempl<u8, crate::chain::channelmonitor::MonitorUpdateError>;
+#[no_mangle]
+pub static CResult_NoneMonitorUpdateErrorZ_free: extern "C" fn(CResult_NoneMonitorUpdateErrorZ) = crate::c_types::CResultTempl_free::<u8, crate::chain::channelmonitor::MonitorUpdateError>;
+#[no_mangle]
+pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_ok() -> CResult_NoneMonitorUpdateErrorZ {
+       crate::c_types::CResultTempl::ok(0)
 }
 
 #[no_mangle]
-pub type CResult_C2Tuple_Scriptu64ZChainErrorZ = crate::c_types::CResultTempl<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>;
+pub static CResult_NoneMonitorUpdateErrorZ_err: extern "C" fn (crate::chain::channelmonitor::MonitorUpdateError) -> CResult_NoneMonitorUpdateErrorZ =
+       crate::c_types::CResultTempl::<u8, crate::chain::channelmonitor::MonitorUpdateError>::err;
+
+#[no_mangle]
+pub type C2Tuple_OutPointScriptZ = crate::c_types::C2TupleTempl<crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z>;
+#[no_mangle]
+pub static C2Tuple_OutPointScriptZ_free: extern "C" fn(C2Tuple_OutPointScriptZ) = crate::c_types::C2TupleTempl_free::<crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z>;
+#[no_mangle]
+pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ {
+       C2Tuple_OutPointScriptZ { a, b, }
+}
+
 #[no_mangle]
-pub static CResult_C2Tuple_Scriptu64ZChainErrorZ_free: extern "C" fn(CResult_C2Tuple_Scriptu64ZChainErrorZ) = crate::c_types::CResultTempl_free::<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>;
+pub type CVec_TransactionZ = crate::c_types::CVecTempl<crate::c_types::Transaction>;
 #[no_mangle]
-pub static CResult_C2Tuple_Scriptu64ZChainErrorZ_ok: extern "C" fn (C2Tuple_Scriptu64Z) -> CResult_C2Tuple_Scriptu64ZChainErrorZ =
-       crate::c_types::CResultTempl::<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>::ok;
+pub static CVec_TransactionZ_free: extern "C" fn(CVec_TransactionZ) = crate::c_types::CVecTempl_free::<crate::c_types::Transaction>;
 
 #[no_mangle]
-pub static CResult_C2Tuple_Scriptu64ZChainErrorZ_err: extern "C" fn (crate::chain::chaininterface::ChainError) -> CResult_C2Tuple_Scriptu64ZChainErrorZ =
-       crate::c_types::CResultTempl::<crate::c_types::C2TupleTempl<crate::c_types::derived::CVec_u8Z, u64>, crate::chain::chaininterface::ChainError>::err;
+pub type CVec_TxOutZ = crate::c_types::CVecTempl<crate::c_types::TxOut>;
+#[no_mangle]
+pub static CVec_TxOutZ_free: extern "C" fn(CVec_TxOutZ) = crate::c_types::CVecTempl_free::<crate::c_types::TxOut>;
 
 #[no_mangle]
-pub type CVec_usizeZ = crate::c_types::CVecTempl<usize>;
+pub type C2Tuple_TxidCVec_TxOutZZ = crate::c_types::C2TupleTempl<crate::c_types::ThirtyTwoBytes, crate::c_types::CVecTempl<crate::c_types::TxOut>>;
+#[no_mangle]
+pub static C2Tuple_TxidCVec_TxOutZZ_free: extern "C" fn(C2Tuple_TxidCVec_TxOutZZ) = crate::c_types::C2TupleTempl_free::<crate::c_types::ThirtyTwoBytes, crate::c_types::CVecTempl<crate::c_types::TxOut>>;
 #[no_mangle]
-pub static CVec_usizeZ_free: extern "C" fn(CVec_usizeZ) = crate::c_types::CVecTempl_free::<usize>;
+pub extern "C" fn C2Tuple_TxidCVec_TxOutZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_TxOutZ) -> C2Tuple_TxidCVec_TxOutZZ {
+       C2Tuple_TxidCVec_TxOutZZ { a, b, }
+}
 
 #[no_mangle]
-pub type CVec_TransactionZ = crate::c_types::CVecTempl<crate::c_types::derived::CVec_u8Z>;
+pub type CVec_C2Tuple_TxidCVec_TxOutZZZ = crate::c_types::CVecTempl<crate::c_types::C2TupleTempl<crate::c_types::ThirtyTwoBytes, crate::c_types::CVecTempl<crate::c_types::TxOut>>>;
 #[no_mangle]
-pub static CVec_TransactionZ_free: extern "C" fn(CVec_TransactionZ) = crate::c_types::CVecTempl_free::<crate::c_types::derived::CVec_u8Z>;
+pub static CVec_C2Tuple_TxidCVec_TxOutZZZ_free: extern "C" fn(CVec_C2Tuple_TxidCVec_TxOutZZZ) = crate::c_types::CVecTempl_free::<crate::c_types::C2TupleTempl<crate::c_types::ThirtyTwoBytes, crate::c_types::CVecTempl<crate::c_types::TxOut>>>;
 
 #[no_mangle]
 pub type C2Tuple_u64u64Z = crate::c_types::C2TupleTempl<u64, u64>;
@@ -65,10 +97,7 @@ pub type C2Tuple_u64u64Z = crate::c_types::C2TupleTempl<u64, u64>;
 pub static C2Tuple_u64u64Z_free: extern "C" fn(C2Tuple_u64u64Z) = crate::c_types::C2TupleTempl_free::<u64, u64>;
 #[no_mangle]
 pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z {
-       C2Tuple_u64u64Z {
-               a: Box::into_raw(Box::new(a)),
-               b: Box::into_raw(Box::new(b)),
-       }
+       C2Tuple_u64u64Z { a, b, }
 }
 
 #[no_mangle]
@@ -87,10 +116,7 @@ pub type C2Tuple_SignatureCVec_SignatureZZ = crate::c_types::C2TupleTempl<crate:
 pub static C2Tuple_SignatureCVec_SignatureZZ_free: extern "C" fn(C2Tuple_SignatureCVec_SignatureZZ) = crate::c_types::C2TupleTempl_free::<crate::c_types::Signature, crate::c_types::CVecTempl<crate::c_types::Signature>>;
 #[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 {
-       C2Tuple_SignatureCVec_SignatureZZ {
-               a: Box::into_raw(Box::new(a)),
-               b: Box::into_raw(Box::new(b)),
-       }
+       C2Tuple_SignatureCVec_SignatureZZ { a, b, }
 }
 
 #[no_mangle]
@@ -132,6 +158,18 @@ pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZN
        crate::c_types::CResultTempl::err(0)
 }
 
+#[no_mangle]
+pub type CResult_TxOutAccessErrorZ = crate::c_types::CResultTempl<crate::c_types::TxOut, crate::chain::AccessError>;
+#[no_mangle]
+pub static CResult_TxOutAccessErrorZ_free: extern "C" fn(CResult_TxOutAccessErrorZ) = crate::c_types::CResultTempl_free::<crate::c_types::TxOut, crate::chain::AccessError>;
+#[no_mangle]
+pub static CResult_TxOutAccessErrorZ_ok: extern "C" fn (crate::c_types::TxOut) -> CResult_TxOutAccessErrorZ =
+       crate::c_types::CResultTempl::<crate::c_types::TxOut, crate::chain::AccessError>::ok;
+
+#[no_mangle]
+pub static CResult_TxOutAccessErrorZ_err: extern "C" fn (crate::chain::AccessError) -> CResult_TxOutAccessErrorZ =
+       crate::c_types::CResultTempl::<crate::c_types::TxOut, crate::chain::AccessError>::err;
+
 #[no_mangle]
 pub type CResult_NoneAPIErrorZ = crate::c_types::CResultTempl<u8, crate::util::errors::APIError>;
 #[no_mangle]
@@ -169,52 +207,9 @@ pub type CVec_NetAddressZ = crate::c_types::CVecTempl<crate::ln::msgs::NetAddres
 pub static CVec_NetAddressZ_free: extern "C" fn(CVec_NetAddressZ) = crate::c_types::CVecTempl_free::<crate::ln::msgs::NetAddress>;
 
 #[no_mangle]
-pub type CVec_ChannelMonitorZ = crate::c_types::CVecTempl<crate::ln::channelmonitor::ChannelMonitor>;
-#[no_mangle]
-pub static CVec_ChannelMonitorZ_free: extern "C" fn(CVec_ChannelMonitorZ) = crate::c_types::CVecTempl_free::<crate::ln::channelmonitor::ChannelMonitor>;
-
-#[no_mangle]
-pub type CResult_NoneChannelMonitorUpdateErrZ = crate::c_types::CResultTempl<u8, crate::ln::channelmonitor::ChannelMonitorUpdateErr>;
-#[no_mangle]
-pub static CResult_NoneChannelMonitorUpdateErrZ_free: extern "C" fn(CResult_NoneChannelMonitorUpdateErrZ) = crate::c_types::CResultTempl_free::<u8, crate::ln::channelmonitor::ChannelMonitorUpdateErr>;
-#[no_mangle]
-pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChannelMonitorUpdateErrZ {
-       crate::c_types::CResultTempl::ok(0)
-}
-
-#[no_mangle]
-pub static CResult_NoneChannelMonitorUpdateErrZ_err: extern "C" fn (crate::ln::channelmonitor::ChannelMonitorUpdateErr) -> CResult_NoneChannelMonitorUpdateErrZ =
-       crate::c_types::CResultTempl::<u8, crate::ln::channelmonitor::ChannelMonitorUpdateErr>::err;
-
-#[no_mangle]
-pub type CVec_MonitorEventZ = crate::c_types::CVecTempl<crate::ln::channelmonitor::MonitorEvent>;
-#[no_mangle]
-pub static CVec_MonitorEventZ_free: extern "C" fn(CVec_MonitorEventZ) = crate::c_types::CVecTempl_free::<crate::ln::channelmonitor::MonitorEvent>;
-
-#[no_mangle]
-pub type CResult_NoneMonitorUpdateErrorZ = crate::c_types::CResultTempl<u8, crate::ln::channelmonitor::MonitorUpdateError>;
-#[no_mangle]
-pub static CResult_NoneMonitorUpdateErrorZ_free: extern "C" fn(CResult_NoneMonitorUpdateErrorZ) = crate::c_types::CResultTempl_free::<u8, crate::ln::channelmonitor::MonitorUpdateError>;
-#[no_mangle]
-pub extern "C" fn CResult_NoneMonitorUpdateErrorZ_ok() -> CResult_NoneMonitorUpdateErrorZ {
-       crate::c_types::CResultTempl::ok(0)
-}
-
-#[no_mangle]
-pub static CResult_NoneMonitorUpdateErrorZ_err: extern "C" fn (crate::ln::channelmonitor::MonitorUpdateError) -> CResult_NoneMonitorUpdateErrorZ =
-       crate::c_types::CResultTempl::<u8, crate::ln::channelmonitor::MonitorUpdateError>::err;
-
-#[no_mangle]
-pub type C2Tuple_OutPointScriptZ = crate::c_types::C2TupleTempl<crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z>;
-#[no_mangle]
-pub static C2Tuple_OutPointScriptZ_free: extern "C" fn(C2Tuple_OutPointScriptZ) = crate::c_types::C2TupleTempl_free::<crate::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z>;
+pub type CVec_ChannelMonitorZ = crate::c_types::CVecTempl<crate::chain::channelmonitor::ChannelMonitor>;
 #[no_mangle]
-pub extern "C" fn C2Tuple_OutPointScriptZ_new(a: crate::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointScriptZ {
-       C2Tuple_OutPointScriptZ {
-               a: Box::into_raw(Box::new(a)),
-               b: Box::into_raw(Box::new(b)),
-       }
-}
+pub static CVec_ChannelMonitorZ_free: extern "C" fn(CVec_ChannelMonitorZ) = crate::c_types::CVecTempl_free::<crate::chain::channelmonitor::ChannelMonitor>;
 
 #[no_mangle]
 pub type CVec_u64Z = crate::c_types::CVecTempl<u64>;
@@ -259,11 +254,7 @@ pub type C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ = crate::c_types
 pub static C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free: extern "C" fn(C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) = crate::c_types::C3TupleTempl_free::<crate::ln::msgs::ChannelAnnouncement, crate::ln::msgs::ChannelUpdate, crate::ln::msgs::ChannelUpdate>;
 #[no_mangle]
 pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a: crate::ln::msgs::ChannelAnnouncement, b: crate::ln::msgs::ChannelUpdate, c: crate::ln::msgs::ChannelUpdate) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
-       C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ {
-               a: Box::into_raw(Box::new(a)),
-               b: Box::into_raw(Box::new(b)),
-               c: Box::into_raw(Box::new(c)),
-       }
+       C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { a, b, c, }
 }
 
 #[no_mangle]
@@ -365,10 +356,7 @@ pub type C2Tuple_HTLCOutputInCommitmentSignatureZ = crate::c_types::C2TupleTempl
 pub static C2Tuple_HTLCOutputInCommitmentSignatureZ_free: extern "C" fn(C2Tuple_HTLCOutputInCommitmentSignatureZ) = crate::c_types::C2TupleTempl_free::<crate::ln::chan_utils::HTLCOutputInCommitment, crate::c_types::Signature>;
 #[no_mangle]
 pub extern "C" fn C2Tuple_HTLCOutputInCommitmentSignatureZ_new(a: crate::ln::chan_utils::HTLCOutputInCommitment, b: crate::c_types::Signature) -> C2Tuple_HTLCOutputInCommitmentSignatureZ {
-       C2Tuple_HTLCOutputInCommitmentSignatureZ {
-               a: Box::into_raw(Box::new(a)),
-               b: Box::into_raw(Box::new(b)),
-       }
+       C2Tuple_HTLCOutputInCommitmentSignatureZ { a, b, }
 }
 
 #[no_mangle]
index be697d49639d2650b1e4dd9ee2ae57ad730f4128..d14fe6fc792df937f914aae656e8b61dfd52e773 100644 (file)
@@ -86,25 +86,48 @@ impl Secp256k1Error {
 }
 
 #[repr(C)]
-/// A reference to a serialized transaction, in (pointer, length) form.
-/// This type does *not* own its own memory, so access to it after, eg, the call in which it was
-/// provided to you are invalid.
+/// A serialized transaction, in (pointer, length) form.
+///
+/// This type optionally owns its own memory, and thus the semantics around access change based on
+/// the `data_is_owned` flag. If `data_is_owned` is set, you must call `Transaction_free` to free
+/// the underlying buffer before the object goes out of scope. If `data_is_owned` is not set, any
+/// access to the buffer after the scope in which the object was provided to you is invalid. eg,
+/// access after you return from the call in which a `!data_is_owned` `Transaction` is provided to
+/// you would be invalid.
+///
+/// Note that, while it may change in the future, because transactions on the Rust side are stored
+/// in a deserialized form, all `Transaction`s generated on the Rust side will have `data_is_owned`
+/// set. Similarly, while it may change in the future, all `Transaction`s you pass to Rust may have
+/// `data_is_owned` either set or unset at your discretion.
 pub struct Transaction {
        pub data: *const u8,
        pub datalen: usize,
+       pub data_is_owned: bool,
 }
 impl Transaction {
        pub(crate) fn into_bitcoin(&self) -> BitcoinTransaction {
                if self.datalen == 0 { panic!("0-length buffer can never represent a valid Transaction"); }
                ::bitcoin::consensus::encode::deserialize(unsafe { std::slice::from_raw_parts(self.data, self.datalen) }).unwrap()
        }
-       pub(crate) fn from_slice(s: &[u8]) -> Self {
+       pub(crate) fn from_vec(v: Vec<u8>) -> Self {
+               let datalen = v.len();
+               let data = Box::into_raw(v.into_boxed_slice());
                Self {
-                       data: s.as_ptr(),
-                       datalen: s.len(),
+                       data: unsafe { (*data).as_mut_ptr() },
+                       datalen,
+                       data_is_owned: true,
+               }
+       }
+}
+impl Drop for Transaction {
+       fn drop(&mut self) {
+               if self.data_is_owned && self.datalen != 0 {
+                       let _ = CVecTempl { data: self.data as *mut u8, datalen: self.datalen };
                }
        }
 }
+#[no_mangle]
+pub extern "C" fn Transaction_free(_res: Transaction) { }
 
 #[repr(C)]
 #[derive(Clone)]
@@ -150,24 +173,6 @@ impl u8slice {
        }
 }
 
-#[repr(C)]
-pub struct usizeslice {
-       pub data: *const usize,
-       pub datalen: usize
-}
-impl usizeslice {
-       pub(crate) fn from_slice(s: &[usize]) -> Self {
-               Self {
-                       data: s.as_ptr(),
-                       datalen: s.len(),
-               }
-       }
-       pub(crate) fn to_slice(&self) -> &[usize] {
-               if self.datalen == 0 { return &[]; }
-               unsafe { std::slice::from_raw_parts(self.data, self.datalen) }
-       }
-}
-
 #[repr(C)]
 #[derive(Copy, Clone)]
 /// Arbitrary 32 bytes, which could represent one of a few different things. You probably want to
@@ -321,83 +326,53 @@ impl<T: Clone> Clone for CVecTempl<T> {
 
 #[repr(C)]
 pub struct C2TupleTempl<A, B> {
-       pub a: *mut A,
-       pub b: *mut B,
+       pub a: A,
+       pub b: B,
 }
 impl<A, B> From<(A, B)> for C2TupleTempl<A, B> {
        fn from(tup: (A, B)) -> Self {
                Self {
-                       a: Box::into_raw(Box::new(tup.0)),
-                       b: Box::into_raw(Box::new(tup.1)),
+                       a: tup.0,
+                       b: tup.1,
                }
        }
 }
 impl<A, B> C2TupleTempl<A, B> {
        pub(crate) fn to_rust(mut self) -> (A, B) {
-               let res = (unsafe { *Box::from_raw(self.a) }, unsafe { *Box::from_raw(self.b) });
-               self.a = std::ptr::null_mut();
-               self.b = std::ptr::null_mut();
-               res
+               (self.a, self.b)
        }
 }
 pub extern "C" fn C2TupleTempl_free<A, B>(_res: C2TupleTempl<A, B>) { }
-impl<A, B> Drop for C2TupleTempl<A, B> {
-       fn drop(&mut self) {
-               if !self.a.is_null() {
-                       unsafe { Box::from_raw(self.a) };
-               }
-               if !self.b.is_null() {
-                       unsafe { Box::from_raw(self.b) };
-               }
-       }
-}
 impl <A: Clone, B: Clone> Clone for C2TupleTempl<A, B> {
        fn clone(&self) -> Self {
                Self {
-                       a: Box::into_raw(Box::new(unsafe { &*self.a }.clone())),
-                       b: Box::into_raw(Box::new(unsafe { &*self.b }.clone()))
+                       a: self.a.clone(),
+                       b: self.b.clone()
                }
        }
 }
 
 #[repr(C)]
 pub struct C3TupleTempl<A, B, C> {
-       pub a: *mut A,
-       pub b: *mut B,
-       pub c: *mut C,
+       pub a: A,
+       pub b: B,
+       pub c: C,
 }
 impl<A, B, C> From<(A, B, C)> for C3TupleTempl<A, B, C> {
        fn from(tup: (A, B, C)) -> Self {
                Self {
-                       a: Box::into_raw(Box::new(tup.0)),
-                       b: Box::into_raw(Box::new(tup.1)),
-                       c: Box::into_raw(Box::new(tup.2)),
+                       a: tup.0,
+                       b: tup.1,
+                       c: tup.2,
                }
        }
 }
 impl<A, B, C> C3TupleTempl<A, B, C> {
        pub(crate) fn to_rust(mut self) -> (A, B, C) {
-               let res = (unsafe { *Box::from_raw(self.a) }, unsafe { *Box::from_raw(self.b) }, unsafe { *Box::from_raw(self.c) });
-               self.a = std::ptr::null_mut();
-               self.b = std::ptr::null_mut();
-               self.c = std::ptr::null_mut();
-               res
+               (self.a, self.b, self.c)
        }
 }
 pub extern "C" fn C3TupleTempl_free<A, B, C>(_res: C3TupleTempl<A, B, C>) { }
-impl<A, B, C> Drop for C3TupleTempl<A, B, C> {
-       fn drop(&mut self) {
-               if !self.a.is_null() {
-                       unsafe { Box::from_raw(self.a) };
-               }
-               if !self.b.is_null() {
-                       unsafe { Box::from_raw(self.b) };
-               }
-               if !self.c.is_null() {
-                       unsafe { Box::from_raw(self.c) };
-               }
-       }
-}
 
 /// Utility to make it easy to set a pointer to null and get its original value in line.
 pub(crate) trait TakePointer<T> {
index 5a08dddb850dafd2670ccdef9835858a51d72c09..ef524b568de24cbdaf1d2c880171bd1c8be71c81 100644 (file)
@@ -8,136 +8,6 @@ use std::ffi::c_void;
 use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
-/// Used to give chain error details upstream
-#[must_use]
-#[derive(Clone)]
-#[repr(C)]
-pub enum ChainError {
-       /// Client doesn't support UTXO lookup (but the chain hash matches our genesis block hash)
-       NotSupported,
-       /// Chain isn't the one watched
-       NotWatched,
-       /// Tx doesn't exist or is unconfirmed
-       UnknownTx,
-}
-use lightning::chain::chaininterface::ChainError as nativeChainError;
-impl ChainError {
-       #[allow(unused)]
-       pub(crate) fn to_native(&self) -> nativeChainError {
-               match self {
-                       ChainError::NotSupported => nativeChainError::NotSupported,
-                       ChainError::NotWatched => nativeChainError::NotWatched,
-                       ChainError::UnknownTx => nativeChainError::UnknownTx,
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn into_native(self) -> nativeChainError {
-               match self {
-                       ChainError::NotSupported => nativeChainError::NotSupported,
-                       ChainError::NotWatched => nativeChainError::NotWatched,
-                       ChainError::UnknownTx => nativeChainError::UnknownTx,
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn from_native(native: &nativeChainError) -> Self {
-               match native {
-                       nativeChainError::NotSupported => ChainError::NotSupported,
-                       nativeChainError::NotWatched => ChainError::NotWatched,
-                       nativeChainError::UnknownTx => ChainError::UnknownTx,
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn native_into(native: nativeChainError) -> Self {
-               match native {
-                       nativeChainError::NotSupported => ChainError::NotSupported,
-                       nativeChainError::NotWatched => ChainError::NotWatched,
-                       nativeChainError::UnknownTx => ChainError::UnknownTx,
-               }
-       }
-}
-/// An interface to request notification of certain scripts as they appear the
-/// chain.
-///
-/// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
-/// called from inside the library in response to ChainListener events, P2P events, or timer
-/// events).
-#[repr(C)]
-pub struct ChainWatchInterface {
-       pub this_arg: *mut c_void,
-       /// Provides a txid/random-scriptPubKey-in-the-tx which much be watched for.
-       pub install_watch_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pub_key: crate::c_types::u8slice),
-       /// Provides an outpoint which must be watched for, providing any transactions which spend the
-       /// given outpoint.
-       pub install_watch_outpoint: extern "C" fn (this_arg: *const c_void, outpoint: crate::c_types::derived::C2Tuple_Txidu32Z, out_script: crate::c_types::u8slice),
-       /// Indicates that a listener needs to see all transactions.
-       pub watch_all_txn: extern "C" fn (this_arg: *const c_void),
-       /// Gets the script and value in satoshis for a given unspent transaction output given a
-       /// short_channel_id (aka unspent_tx_output_identier). For BTC/tBTC channels the top three
-       /// bytes are the block height, the next 3 the transaction index within the block, and the
-       /// final two the output within the transaction.
-       #[must_use]
-       pub get_chain_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: crate::c_types::ThirtyTwoBytes, unspent_tx_output_identifier: u64) -> crate::c_types::derived::CResult_C2Tuple_Scriptu64ZChainErrorZ,
-       /// Gets the list of transaction indices within a given block that the ChainWatchInterface is
-       /// watching for.
-       #[must_use]
-       pub filter_block: extern "C" fn (this_arg: *const c_void, block: crate::c_types::u8slice) -> crate::c_types::derived::CVec_usizeZ,
-       /// Returns a usize that changes when the ChainWatchInterface's watched data is modified.
-       /// Users of `filter_block` should pre-save a copy of `reentered`'s return value and use it to
-       /// determine whether they need to re-filter a given block.
-       #[must_use]
-       pub reentered: extern "C" fn (this_arg: *const c_void) -> usize,
-       pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
-}
-unsafe impl Sync for ChainWatchInterface {}
-unsafe impl Send for ChainWatchInterface {}
-
-use lightning::chain::chaininterface::ChainWatchInterface as rustChainWatchInterface;
-impl rustChainWatchInterface for ChainWatchInterface {
-       fn install_watch_tx(&self, txid: &bitcoin::hash_types::Txid, script_pub_key: &bitcoin::blockdata::script::Script) {
-               (self.install_watch_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pub_key[..]))
-       }
-       fn install_watch_outpoint(&self, outpoint: (bitcoin::hash_types::Txid, u32), out_script: &bitcoin::blockdata::script::Script) {
-               let (mut orig_outpoint_0, mut orig_outpoint_1) = outpoint; let mut local_outpoint = (crate::c_types::ThirtyTwoBytes { data: orig_outpoint_0.into_inner() }, orig_outpoint_1).into();
-               (self.install_watch_outpoint)(self.this_arg, local_outpoint, crate::c_types::u8slice::from_slice(&out_script[..]))
-       }
-       fn watch_all_txn(&self) {
-               (self.watch_all_txn)(self.this_arg)
-       }
-       fn get_chain_utxo(&self, genesis_hash: bitcoin::hash_types::BlockHash, unspent_tx_output_identifier: u64) -> Result<(bitcoin::blockdata::script::Script, u64), lightning::chain::chaininterface::ChainError> {
-               let mut ret = (self.get_chain_utxo)(self.this_arg, crate::c_types::ThirtyTwoBytes { data: genesis_hash.into_inner() }, unspent_tx_output_identifier);
-               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(ret.contents.result.take_ptr()) }).to_rust(); let mut local_ret_0 = (::bitcoin::blockdata::script::Script::from(orig_ret_0_0.into_rust()), orig_ret_0_1); local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
-               local_ret
-       }
-       fn filter_block(&self, block: &bitcoin::blockdata::block::Block) -> Vec<usize> {
-               let mut local_block = ::bitcoin::consensus::encode::serialize(block);
-               let mut ret = (self.filter_block)(self.this_arg, crate::c_types::u8slice::from_slice(&local_block));
-               let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item }); };
-               local_ret
-       }
-       fn reentered(&self) -> usize {
-               let mut ret = (self.reentered)(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 ChainWatchInterface {
-       type Target = Self;
-       fn deref(&self) -> &Self {
-               self
-       }
-}
-/// Calls the free function if one is set
-#[no_mangle]
-pub extern "C" fn ChainWatchInterface_free(this_ptr: ChainWatchInterface) { }
-impl Drop for ChainWatchInterface {
-       fn drop(&mut self) {
-               if let Some(f) = self.free {
-                       f(self.this_arg);
-               }
-       }
-}
 /// An interface to send a transaction to the Bitcoin network.
 #[repr(C)]
 pub struct BroadcasterInterface {
@@ -153,7 +23,7 @@ use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInt
 impl rustBroadcasterInterface for BroadcasterInterface {
        fn broadcast_transaction(&self, tx: &bitcoin::blockdata::transaction::Transaction) {
                let mut local_tx = ::bitcoin::consensus::encode::serialize(tx);
-               (self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_tx))
+               (self.broadcast_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_tx))
        }
 }
 
@@ -175,67 +45,6 @@ impl Drop for BroadcasterInterface {
                }
        }
 }
-/// A trait indicating a desire to listen for events from the chain
-#[repr(C)]
-pub struct ChainListener {
-       pub this_arg: *mut c_void,
-       /// Notifies a listener that a block was connected.
-       ///
-       /// The txn_matched array should be set to references to transactions which matched the
-       /// relevant installed watch outpoints/txn, or the full set of transactions in the block.
-       ///
-       /// Note that if txn_matched includes only matched transactions, and a new
-       /// transaction/outpoint is watched during a block_connected call, the block *must* be
-       /// re-scanned with the new transaction/outpoints and block_connected should be called
-       /// again with the same header and (at least) the new transactions.
-       ///
-       /// Note that if non-new transaction/outpoints are be registered during a call, a second call
-       /// *must not* happen.
-       ///
-       /// This also means those counting confirmations using block_connected callbacks should watch
-       /// for duplicate headers and not count them towards confirmations!
-       pub block_connected: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], height: u32, txn_matched: crate::c_types::derived::CVec_TransactionZ, indexes_of_txn_matched: crate::c_types::usizeslice),
-       /// Notifies a listener that a block was disconnected.
-       /// Unlike block_connected, this *must* never be called twice for the same disconnect event.
-       /// Height must be the one of the block which was disconnected (not new height of the best chain)
-       pub block_disconnected: extern "C" fn (this_arg: *const c_void, header: *const [u8; 80], disconnected_height: u32),
-       pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
-}
-unsafe impl Sync for ChainListener {}
-unsafe impl Send for ChainListener {}
-
-use lightning::chain::chaininterface::ChainListener as rustChainListener;
-impl rustChainListener for ChainListener {
-       fn block_connected(&self, header: &bitcoin::blockdata::block::BlockHeader, height: u32, txn_matched: &[&bitcoin::blockdata::transaction::Transaction], indexes_of_txn_matched: &[usize]) {
-               let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s };
-               let mut local_txn_matched = Vec::new(); for item in txn_matched.iter() { local_txn_matched.push( { let mut local_txn_matched_0 = ::bitcoin::consensus::encode::serialize(&**item); local_txn_matched_0.into() }); };
-               let mut local_indexes_of_txn_matched = crate::c_types::usizeslice::from_slice(indexes_of_txn_matched);
-               (self.block_connected)(self.this_arg, &local_header, height, local_txn_matched.into(), local_indexes_of_txn_matched)
-       }
-       fn block_disconnected(&self, header: &bitcoin::blockdata::block::BlockHeader, disconnected_height: u32) {
-               let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s };
-               (self.block_disconnected)(self.this_arg, &local_header, disconnected_height)
-       }
-}
-
-// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
-// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for ChainListener {
-       type Target = Self;
-       fn deref(&self) -> &Self {
-               self
-       }
-}
-/// Calls the free function if one is set
-#[no_mangle]
-pub extern "C" fn ChainListener_free(this_ptr: ChainListener) { }
-impl Drop for ChainListener {
-       fn drop(&mut self) {
-               if let Some(f) = self.free {
-                       f(self.this_arg);
-               }
-       }
-}
 /// An enum that represents the speed at which we want a transaction to confirm used for feerate
 /// estimation.
 #[must_use]
@@ -288,8 +97,7 @@ impl ConfirmationTarget {
 /// horizons.
 ///
 /// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're
-/// called from inside the library in response to ChainListener events, P2P events, or timer
-/// events).
+/// called from inside the library in response to chain events, P2P events, or timer events).
 #[repr(C)]
 pub struct FeeEstimator {
        pub this_arg: *mut c_void,
@@ -337,270 +145,3 @@ impl Drop for FeeEstimator {
 
 #[no_mangle]
 pub static MIN_RELAY_FEE_SAT_PER_1000_WEIGHT: u64 = lightning::chain::chaininterface::MIN_RELAY_FEE_SAT_PER_1000_WEIGHT;
-
-use lightning::chain::chaininterface::ChainWatchedUtil as nativeChainWatchedUtilImport;
-type nativeChainWatchedUtil = nativeChainWatchedUtilImport;
-
-/// Utility for tracking registered txn/outpoints and checking for matches
-#[must_use]
-#[repr(C)]
-pub struct ChainWatchedUtil {
-       /// Nearly everyhwere, 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 nativeChainWatchedUtil,
-       pub is_owned: bool,
-}
-
-impl Drop for ChainWatchedUtil {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn ChainWatchedUtil_free(this_ptr: ChainWatchedUtil) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChainWatchedUtil_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainWatchedUtil); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl ChainWatchedUtil {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeChainWatchedUtil {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-/// Constructs an empty (watches nothing) ChainWatchedUtil
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChainWatchedUtil_new() -> ChainWatchedUtil {
-       let mut ret = lightning::chain::chaininterface::ChainWatchedUtil::new();
-       ChainWatchedUtil { inner: Box::into_raw(Box::new(ret)), is_owned: true }
-}
-
-/// Registers a tx for monitoring, returning true if it was a new tx and false if we'd already
-/// been watching for it.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChainWatchedUtil_register_tx(this_arg: &mut ChainWatchedUtil, txid: *const [u8; 32], script_pub_key: crate::c_types::u8slice) -> bool {
-       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChainWatchedUtil)) }.register_tx(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(script_pub_key.to_slice())));
-       ret
-}
-
-/// Registers an outpoint for monitoring, returning true if it was a new outpoint and false if
-/// we'd already been watching for it
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChainWatchedUtil_register_outpoint(this_arg: &mut ChainWatchedUtil, mut outpoint: crate::c_types::derived::C2Tuple_Txidu32Z, _script_pub_key: crate::c_types::u8slice) -> bool {
-       let (mut orig_outpoint_0, mut orig_outpoint_1) = outpoint.to_rust(); let mut local_outpoint = (::bitcoin::hash_types::Txid::from_slice(&orig_outpoint_0.data[..]).unwrap(), orig_outpoint_1);
-       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChainWatchedUtil)) }.register_outpoint(local_outpoint, &::bitcoin::blockdata::script::Script::from(Vec::from(_script_pub_key.to_slice())));
-       ret
-}
-
-/// Sets us to match all transactions, returning true if this is a new setting and false if
-/// we'd already been set to match everything.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChainWatchedUtil_watch_all(this_arg: &mut ChainWatchedUtil) -> bool {
-       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChainWatchedUtil)) }.watch_all();
-       ret
-}
-
-/// Checks if a given transaction matches the current filter.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChainWatchedUtil_does_match_tx(this_arg: &ChainWatchedUtil, tx: crate::c_types::Transaction) -> bool {
-       let mut ret = unsafe { &*this_arg.inner }.does_match_tx(&tx.into_bitcoin());
-       ret
-}
-
-
-use lightning::chain::chaininterface::BlockNotifier as nativeBlockNotifierImport;
-type nativeBlockNotifier = nativeBlockNotifierImport<'static, crate::chain::chaininterface::ChainListener, crate::chain::chaininterface::ChainWatchInterface>;
-
-/// Utility for notifying listeners about new blocks, and handling block rescans if new watch
-/// data is registered.
-///
-/// Rather than using a plain BlockNotifier, it is preferable to use either a BlockNotifierArc
-/// or a BlockNotifierRef for conciseness. See their documentation for more details, but essentially
-/// you should default to using a BlockNotifierRef, and use a BlockNotifierArc instead when you
-/// require ChainListeners with static lifetimes, such as when you're using lightning-net-tokio.
-#[must_use]
-#[repr(C)]
-pub struct BlockNotifier {
-       /// Nearly everyhwere, 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 nativeBlockNotifier,
-       pub is_owned: bool,
-}
-
-impl Drop for BlockNotifier {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn BlockNotifier_free(this_ptr: BlockNotifier) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn BlockNotifier_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeBlockNotifier); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl BlockNotifier {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeBlockNotifier {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-/// Constructs a new BlockNotifier without any listeners.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn BlockNotifier_new(mut chain_monitor: crate::chain::chaininterface::ChainWatchInterface) -> crate::chain::chaininterface::BlockNotifier {
-       let mut ret = lightning::chain::chaininterface::BlockNotifier::new(chain_monitor);
-       crate::chain::chaininterface::BlockNotifier { inner: Box::into_raw(Box::new(ret)), is_owned: true }
-}
-
-/// Register the given listener to receive events.
-#[no_mangle]
-pub extern "C" fn BlockNotifier_register_listener(this_arg: &BlockNotifier, mut listener: crate::chain::chaininterface::ChainListener) {
-       unsafe { &*this_arg.inner }.register_listener(listener)
-}
-
-/// Notify listeners that a block was connected given a full, unfiltered block.
-///
-/// Handles re-scanning the block and calling block_connected again if listeners register new
-/// watch data during the callbacks for you (see ChainListener::block_connected for more info).
-#[no_mangle]
-pub extern "C" fn BlockNotifier_block_connected(this_arg: &BlockNotifier, block: crate::c_types::u8slice, mut height: u32) {
-       unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height)
-}
-
-/// Notify listeners that a block was connected, given pre-filtered list of transactions in the
-/// block which matched the filter (probably using does_match_tx).
-///
-/// Returns true if notified listeners registered additional watch data (implying that the
-/// block must be re-scanned and this function called again prior to further block_connected
-/// calls, see ChainListener::block_connected for more info).
-#[must_use]
-#[no_mangle]
-pub extern "C" fn BlockNotifier_block_connected_checked(this_arg: &BlockNotifier, header: *const [u8; 80], mut height: u32, mut txn_matched: crate::c_types::derived::CVec_TransactionZ, mut indexes_of_txn_matched: crate::c_types::usizeslice) -> bool {
-       let mut local_txn_matched = Vec::new(); for mut item in txn_matched.into_rust().drain(..) { local_txn_matched.push( { ::bitcoin::consensus::encode::deserialize(&item.into_rust()[..]).unwrap() }); };
-       let mut ret = unsafe { &*this_arg.inner }.block_connected_checked(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, &local_txn_matched.iter().collect::<Vec<_>>()[..], indexes_of_txn_matched.to_slice());
-       ret
-}
-
-/// Notify listeners that a block was disconnected.
-#[no_mangle]
-pub extern "C" fn BlockNotifier_block_disconnected(this_arg: &BlockNotifier, header: *const [u8; 80], mut disconnected_height: u32) {
-       unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), disconnected_height)
-}
-
-
-use lightning::chain::chaininterface::ChainWatchInterfaceUtil as nativeChainWatchInterfaceUtilImport;
-type nativeChainWatchInterfaceUtil = nativeChainWatchInterfaceUtilImport;
-
-/// Utility to capture some common parts of ChainWatchInterface implementors.
-///
-/// Keeping a local copy of this in a ChainWatchInterface implementor is likely useful.
-#[must_use]
-#[repr(C)]
-pub struct ChainWatchInterfaceUtil {
-       /// Nearly everyhwere, 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 nativeChainWatchInterfaceUtil,
-       pub is_owned: bool,
-}
-
-impl Drop for ChainWatchInterfaceUtil {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn ChainWatchInterfaceUtil_free(this_ptr: ChainWatchInterfaceUtil) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChainWatchInterfaceUtil_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainWatchInterfaceUtil); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl ChainWatchInterfaceUtil {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeChainWatchInterfaceUtil {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-#[no_mangle]
-pub extern "C" fn ChainWatchInterfaceUtil_as_ChainWatchInterface(this_arg: *const ChainWatchInterfaceUtil) -> crate::chain::chaininterface::ChainWatchInterface {
-       crate::chain::chaininterface::ChainWatchInterface {
-               this_arg: unsafe { (*this_arg).inner as *mut c_void },
-               free: None,
-               install_watch_tx: ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_tx,
-               install_watch_outpoint: ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_outpoint,
-               watch_all_txn: ChainWatchInterfaceUtil_ChainWatchInterface_watch_all_txn,
-               get_chain_utxo: ChainWatchInterfaceUtil_ChainWatchInterface_get_chain_utxo,
-               filter_block: ChainWatchInterfaceUtil_ChainWatchInterface_filter_block,
-               reentered: ChainWatchInterfaceUtil_ChainWatchInterface_reentered,
-       }
-}
-use lightning::chain::chaininterface::ChainWatchInterface as ChainWatchInterfaceTraitImport;
-extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_tx(this_arg: *const c_void, txid: *const [u8; 32], script_pub_key: crate::c_types::u8slice) {
-       unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.install_watch_tx(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(script_pub_key.to_slice())))
-}
-extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_install_watch_outpoint(this_arg: *const c_void, mut outpoint: crate::c_types::derived::C2Tuple_Txidu32Z, out_script: crate::c_types::u8slice) {
-       let (mut orig_outpoint_0, mut orig_outpoint_1) = outpoint.to_rust(); let mut local_outpoint = (::bitcoin::hash_types::Txid::from_slice(&orig_outpoint_0.data[..]).unwrap(), orig_outpoint_1);
-       unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.install_watch_outpoint(local_outpoint, &::bitcoin::blockdata::script::Script::from(Vec::from(out_script.to_slice())))
-}
-extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_watch_all_txn(this_arg: *const c_void) {
-       unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.watch_all_txn()
-}
-#[must_use]
-extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_get_chain_utxo(this_arg: *const c_void, mut genesis_hash: crate::c_types::ThirtyTwoBytes, mut _unspent_tx_output_identifier: u64) -> crate::c_types::derived::CResult_C2Tuple_Scriptu64ZChainErrorZ {
-       let mut ret = unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.get_chain_utxo(::bitcoin::hash_types::BlockHash::from_slice(&genesis_hash.data[..]).unwrap(), _unspent_tx_output_identifier);
-       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (orig_ret_0_0.into_bytes().into(), orig_ret_0_1).into(); local_ret_0 }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::chaininterface::ChainError::native_into(e) }) };
-       local_ret
-}
-#[must_use]
-extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_filter_block(this_arg: *const c_void, block: crate::c_types::u8slice) -> crate::c_types::derived::CVec_usizeZ {
-       let mut ret = unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.filter_block(&::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap());
-       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { item }); };
-       local_ret.into()
-}
-#[must_use]
-extern "C" fn ChainWatchInterfaceUtil_ChainWatchInterface_reentered(this_arg: *const c_void) -> usize {
-       let mut ret = unsafe { &mut *(this_arg as *mut nativeChainWatchInterfaceUtil) }.reentered();
-       ret
-}
-
-/// Creates a new ChainWatchInterfaceUtil for the given network
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChainWatchInterfaceUtil_new(mut network: crate::bitcoin::network::Network) -> crate::chain::chaininterface::ChainWatchInterfaceUtil {
-       let mut ret = lightning::chain::chaininterface::ChainWatchInterfaceUtil::new(network.into_bitcoin());
-       crate::chain::chaininterface::ChainWatchInterfaceUtil { inner: Box::into_raw(Box::new(ret)), is_owned: true }
-}
-
-/// Checks if a given transaction matches the current filter.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChainWatchInterfaceUtil_does_match_tx(this_arg: &ChainWatchInterfaceUtil, tx: crate::c_types::Transaction) -> bool {
-       let mut ret = unsafe { &*this_arg.inner }.does_match_tx(&tx.into_bitcoin());
-       ret
-}
-
diff --git a/lightning-c-bindings/src/chain/chainmonitor.rs b/lightning-c-bindings/src/chain/chainmonitor.rs
new file mode 100644 (file)
index 0000000..539b845
--- /dev/null
@@ -0,0 +1,165 @@
+//! Logic to connect off-chain channel management with on-chain transaction monitoring.
+//!
+//! [`ChainMonitor`] is an implementation of [`chain::Watch`] used both to process blocks and to
+//! update [`ChannelMonitor`]s accordingly. If any on-chain events need further processing, it will
+//! make those available as [`MonitorEvent`]s to be consumed.
+//!
+//! `ChainMonitor` is parameterized by an optional chain source, which must implement the
+//! [`chain::Filter`] trait. This provides a mechanism to signal new relevant outputs back to light
+//! clients, such that transactions spending those outputs are included in block data.
+//!
+//! `ChainMonitor` may be used directly to monitor channels locally or as a part of a distributed
+//! setup to monitor channels remotely. In the latter case, a custom `chain::Watch` implementation
+//! would be responsible for routing each update to a remote server and for retrieving monitor
+//! events. The remote server would make use of `ChainMonitor` for block processing and for
+//! servicing `ChannelMonitor` updates from the client.
+//!
+//! [`ChainMonitor`]: struct.ChainMonitor.html
+//! [`chain::Filter`]: ../trait.Filter.html
+//! [`chain::Watch`]: ../trait.Watch.html
+//! [`ChannelMonitor`]: ../channelmonitor/struct.ChannelMonitor.html
+//! [`MonitorEvent`]: ../channelmonitor/enum.MonitorEvent.html
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport;
+type nativeChainMonitor = nativeChainMonitorImport<crate::chain::keysinterface::ChannelKeys, crate::chain::Filter, crate::chain::chaininterface::BroadcasterInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>;
+
+/// An implementation of [`chain::Watch`] for monitoring channels.
+///
+/// Connected and disconnected blocks must be provided to `ChainMonitor` as documented by
+/// [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally
+/// or used independently to monitor channels remotely. See the [module-level documentation] for
+/// details.
+///
+/// [`chain::Watch`]: ../trait.Watch.html
+/// [`ChannelManager`]: ../../ln/channelmanager/struct.ChannelManager.html
+/// [module-level documentation]: index.html
+#[must_use]
+#[repr(C)]
+pub struct ChainMonitor {
+       /// 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 nativeChainMonitor,
+       pub is_owned: bool,
+}
+
+impl Drop for ChainMonitor {
+       fn drop(&mut self) {
+               if self.is_owned && !self.inner.is_null() {
+                       let _ = unsafe { Box::from_raw(self.inner) };
+               }
+       }
+}
+#[no_mangle]
+pub extern "C" fn ChainMonitor_free(this_ptr: ChainMonitor) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChainMonitor_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChainMonitor); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChainMonitor {
+       pub(crate) fn take_ptr(mut self) -> *mut nativeChainMonitor {
+               assert!(self.is_owned);
+               let ret = self.inner;
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view
+/// of a channel and reacting accordingly based on transactions in the connected block. See
+/// [`ChannelMonitor::block_connected`] for details. Any HTLCs that were resolved on chain will
+/// be returned by [`chain::Watch::release_pending_monitor_events`].
+///
+/// Calls back to [`chain::Filter`] if any monitor indicated new outputs to watch. Subsequent
+/// calls must not exclude any transactions matching the new outputs nor any in-block
+/// descendants of such transactions. It is not necessary to re-fetch the block to obtain
+/// updated `txdata`.
+///
+/// [`ChannelMonitor::block_connected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_connected
+/// [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
+/// [`chain::Filter`]: ../trait.Filter.html
+#[no_mangle]
+pub extern "C" fn ChainMonitor_block_connected(this_arg: &ChainMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) {
+       let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); };
+       unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height)
+}
+
+/// Dispatches to per-channel monitors, which are responsible for updating their on-chain view
+/// of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for
+/// details.
+///
+/// [`ChannelMonitor::block_disconnected`]: ../channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
+#[no_mangle]
+pub extern "C" fn ChainMonitor_block_disconnected(this_arg: &ChainMonitor, header: *const [u8; 80], mut disconnected_height: u32) {
+       unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), disconnected_height)
+}
+
+/// Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels.
+///
+/// When an optional chain source implementing [`chain::Filter`] is provided, the chain monitor
+/// will call back to it indicating transactions and outputs of interest. This allows clients to
+/// 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.
+///
+/// [`chain::Filter`]: ../trait.Filter.html
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChainMonitor_new(chain_source: *mut crate::chain::Filter, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut feeest: crate::chain::chaininterface::FeeEstimator) -> ChainMonitor {
+       let mut local_chain_source = if chain_source == std::ptr::null_mut() { None } else { Some( { unsafe { *Box::from_raw(chain_source) } }) };
+       let mut ret = lightning::chain::chainmonitor::ChainMonitor::new(local_chain_source, broadcaster, logger, feeest);
+       ChainMonitor { inner: Box::into_raw(Box::new(ret)), is_owned: true }
+}
+
+#[no_mangle]
+pub extern "C" fn ChainMonitor_as_Watch(this_arg: *const ChainMonitor) -> crate::chain::Watch {
+       crate::chain::Watch {
+               this_arg: unsafe { (*this_arg).inner as *mut c_void },
+               free: None,
+               watch_channel: ChainMonitor_Watch_watch_channel,
+               update_channel: ChainMonitor_Watch_update_channel,
+               release_pending_monitor_events: ChainMonitor_Watch_release_pending_monitor_events,
+       }
+}
+use lightning::chain::Watch as WatchTraitImport;
+#[must_use]
+extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_txo: crate::chain::transaction::OutPoint, mut monitor: crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ {
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.watch_channel(*unsafe { Box::from_raw(funding_txo.take_ptr()) }, *unsafe { Box::from_raw(monitor.take_ptr()) });
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }) };
+       local_ret
+}
+#[must_use]
+extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut funding_txo: crate::chain::transaction::OutPoint, mut update: crate::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ {
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.update_channel(*unsafe { Box::from_raw(funding_txo.take_ptr()) }, *unsafe { Box::from_raw(update.take_ptr()) });
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::ChannelMonitorUpdateErr::native_into(e) }) };
+       local_ret
+}
+#[must_use]
+extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ {
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.release_pending_monitor_events();
+       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
+       local_ret.into()
+}
+
+#[no_mangle]
+pub extern "C" fn ChainMonitor_as_EventsProvider(this_arg: *const ChainMonitor) -> crate::util::events::EventsProvider {
+       crate::util::events::EventsProvider {
+               this_arg: unsafe { (*this_arg).inner as *mut c_void },
+               free: None,
+               get_and_clear_pending_events: ChainMonitor_EventsProvider_get_and_clear_pending_events,
+       }
+}
+use lightning::util::events::EventsProvider as EventsProviderTraitImport;
+#[must_use]
+extern "C" fn ChainMonitor_EventsProvider_get_and_clear_pending_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_EventZ {
+       let mut ret = unsafe { &mut *(this_arg as *mut nativeChainMonitor) }.get_and_clear_pending_events();
+       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
+       local_ret.into()
+}
+
diff --git a/lightning-c-bindings/src/chain/channelmonitor.rs b/lightning-c-bindings/src/chain/channelmonitor.rs
new file mode 100644 (file)
index 0000000..79c84d5
--- /dev/null
@@ -0,0 +1,493 @@
+//! The logic to monitor for on-chain transactions and create the relevant claim responses lives
+//! here.
+//!
+//! ChannelMonitor objects are generated by ChannelManager in response to relevant
+//! messages/actions, and MUST be persisted to disk (and, preferably, remotely) before progress can
+//! be made in responding to certain messages, see [`chain::Watch`] for more.
+//!
+//! Note that ChannelMonitors are an important part of the lightning trust model and a copy of the
+//! latest ChannelMonitor must always be actively monitoring for chain updates (and no out-of-date
+//! ChannelMonitors should do so). Thus, if you're building rust-lightning into an HSM or other
+//! security-domain-separated system design, you should consider having multiple paths for
+//! ChannelMonitors to get out of the HSM and onto monitoring devices.
+//!
+//! [`chain::Watch`]: ../trait.Watch.html
+
+use std::ffi::c_void;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+
+
+use lightning::chain::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
+type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
+
+/// An update generated by the underlying Channel itself which contains some new information the
+/// ChannelMonitor should be made aware of.
+#[must_use]
+#[repr(C)]
+pub struct ChannelMonitorUpdate {
+       /// 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 nativeChannelMonitorUpdate,
+       pub is_owned: bool,
+}
+
+impl Drop for ChannelMonitorUpdate {
+       fn drop(&mut self) {
+               if self.is_owned && !self.inner.is_null() {
+                       let _ = unsafe { Box::from_raw(self.inner) };
+               }
+       }
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_free(this_ptr: ChannelMonitorUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitorUpdate); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelMonitorUpdate {
+       pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitorUpdate {
+               assert!(self.is_owned);
+               let ret = self.inner;
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+impl Clone for ChannelMonitorUpdate {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: Box::into_raw(Box::new(unsafe { &*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 ChannelMonitorUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitorUpdate)).clone() })) as *mut c_void
+}
+/// The sequence number of this update. Updates *must* be replayed in-order according to this
+/// sequence number (and updates may panic if they are not). The update_id values are strictly
+/// increasing and increase by one for each new update.
+///
+/// This sequence number is also used to track up to which points updates which returned
+/// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+/// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUpdate) -> u64 {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_id;
+       (*inner_val)
+}
+/// The sequence number of this update. Updates *must* be replayed in-order according to this
+/// sequence number (and updates may panic if they are not). The update_id values are strictly
+/// increasing and increase by one for each new update.
+///
+/// This sequence number is also used to track up to which points updates which returned
+/// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
+/// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) {
+       unsafe { &mut *this_ptr.inner }.update_id = val;
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_write(obj: *const ChannelMonitorUpdate) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> ChannelMonitorUpdate {
+       if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+               ChannelMonitorUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
+       } else {
+               ChannelMonitorUpdate { inner: std::ptr::null_mut(), is_owned: true }
+       }
+}
+/// An error enum representing a failure to persist a channel monitor update.
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum ChannelMonitorUpdateErr {
+       /// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
+       /// our state failed, but is expected to succeed at some point in the future).
+       ///
+       /// Such a failure will \"freeze\" a channel, preventing us from revoking old states or
+       /// submitting new commitment transactions to the counterparty. Once the update(s) which failed
+       /// have been successfully applied, ChannelManager::channel_monitor_updated can be used to
+       /// restore the channel to an operational state.
+       ///
+       /// Note that a given ChannelManager will *never* re-generate a given ChannelMonitorUpdate. If
+       /// you return a TemporaryFailure you must ensure that it is written to disk safely before
+       /// writing out the latest ChannelManager state.
+       ///
+       /// Even when a channel has been \"frozen\" updates to the ChannelMonitor can continue to occur
+       /// (eg if an inbound HTLC which we forwarded was claimed upstream resulting in us attempting
+       /// to claim it on this channel) and those updates must be applied wherever they can be. At
+       /// least one such updated ChannelMonitor must be persisted otherwise PermanentFailure should
+       /// be returned to get things on-chain ASAP using only the in-memory copy. Obviously updates to
+       /// the channel which would invalidate previous ChannelMonitors are not made when a channel has
+       /// been \"frozen\".
+       ///
+       /// Note that even if updates made after TemporaryFailure succeed you must still call
+       /// channel_monitor_updated to ensure you have the latest monitor and re-enable normal channel
+       /// operation.
+       ///
+       /// Note that the update being processed here will not be replayed for you when you call
+       /// ChannelManager::channel_monitor_updated, so you must store the update itself along
+       /// with the persisted ChannelMonitor on your own local disk prior to returning a
+       /// TemporaryFailure. You may, of course, employ a journaling approach, storing only the
+       /// ChannelMonitorUpdate on disk without updating the monitor itself, replaying the journal at
+       /// reload-time.
+       ///
+       /// For deployments where a copy of ChannelMonitors and other local state are backed up in a
+       /// remote location (with local copies persisted immediately), it is anticipated that all
+       /// updates will return TemporaryFailure until the remote copies could be updated.
+       TemporaryFailure,
+       /// Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a
+       /// different watchtower and cannot update with all watchtowers that were previously informed
+       /// of this channel).
+       ///
+       /// At reception of this error, ChannelManager will force-close the channel and return at
+       /// least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at
+       /// least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel
+       /// update must be rejected.
+       ///
+       /// This failure may also signal a failure to update the local persisted copy of one of
+       /// the channel monitor instance.
+       ///
+       /// Note that even when you fail a holder commitment transaction update, you must store the
+       /// update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor
+       /// broadcasts it (e.g distributed channel-monitor deployment)
+       ///
+       /// In case of distributed watchtowers deployment, the new version must be written to disk, as
+       /// state may have been stored but rejected due to a block forcing a commitment broadcast. This
+       /// storage is used to claim outputs of rejected state confirmed onchain by another watchtower,
+       /// lagging behind on block processing.
+       PermanentFailure,
+}
+use lightning::chain::channelmonitor::ChannelMonitorUpdateErr as nativeChannelMonitorUpdateErr;
+impl ChannelMonitorUpdateErr {
+       #[allow(unused)]
+       pub(crate) fn to_native(&self) -> nativeChannelMonitorUpdateErr {
+               match self {
+                       ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
+                       ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn into_native(self) -> nativeChannelMonitorUpdateErr {
+               match self {
+                       ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
+                       ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn from_native(native: &nativeChannelMonitorUpdateErr) -> Self {
+               match native {
+                       nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
+                       nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn native_into(native: nativeChannelMonitorUpdateErr) -> Self {
+               match native {
+                       nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
+                       nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
+               }
+       }
+}
+
+use lightning::chain::channelmonitor::MonitorUpdateError as nativeMonitorUpdateErrorImport;
+type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
+
+/// General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
+/// inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
+/// means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
+/// corrupted.
+/// Contains a human-readable error message.
+#[must_use]
+#[repr(C)]
+pub struct MonitorUpdateError {
+       /// 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 nativeMonitorUpdateError,
+       pub is_owned: bool,
+}
+
+impl Drop for MonitorUpdateError {
+       fn drop(&mut self) {
+               if self.is_owned && !self.inner.is_null() {
+                       let _ = unsafe { Box::from_raw(self.inner) };
+               }
+       }
+}
+#[no_mangle]
+pub extern "C" fn MonitorUpdateError_free(this_ptr: MonitorUpdateError) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorUpdateError); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl MonitorUpdateError {
+       pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorUpdateError {
+               assert!(self.is_owned);
+               let ret = self.inner;
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+
+use lightning::chain::channelmonitor::MonitorEvent as nativeMonitorEventImport;
+type nativeMonitorEvent = nativeMonitorEventImport;
+
+/// An event to be processed by the ChannelManager.
+#[must_use]
+#[repr(C)]
+pub struct MonitorEvent {
+       /// 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 nativeMonitorEvent,
+       pub is_owned: bool,
+}
+
+impl Drop for MonitorEvent {
+       fn drop(&mut self) {
+               if self.is_owned && !self.inner.is_null() {
+                       let _ = unsafe { Box::from_raw(self.inner) };
+               }
+       }
+}
+#[no_mangle]
+pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorEvent); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl MonitorEvent {
+       pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorEvent {
+               assert!(self.is_owned);
+               let ret = self.inner;
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+
+use lightning::chain::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
+type nativeHTLCUpdate = nativeHTLCUpdateImport;
+
+/// Simple structure sent back by `chain::Watch` when an HTLC from a forward channel is detected on
+/// chain. Used to update the corresponding HTLC in the backward channel. Failing to pass the
+/// preimage claim backward will lead to loss of funds.
+///
+/// [`chain::Watch`]: ../trait.Watch.html
+#[must_use]
+#[repr(C)]
+pub struct HTLCUpdate {
+       /// 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 nativeHTLCUpdate,
+       pub is_owned: bool,
+}
+
+impl Drop for HTLCUpdate {
+       fn drop(&mut self) {
+               if self.is_owned && !self.inner.is_null() {
+                       let _ = unsafe { Box::from_raw(self.inner) };
+               }
+       }
+}
+#[no_mangle]
+pub extern "C" fn HTLCUpdate_free(this_ptr: HTLCUpdate) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCUpdate); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl HTLCUpdate {
+       pub(crate) fn take_ptr(mut self) -> *mut nativeHTLCUpdate {
+               assert!(self.is_owned);
+               let ret = self.inner;
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+impl Clone for HTLCUpdate {
+       fn clone(&self) -> Self {
+               Self {
+                       inner: Box::into_raw(Box::new(unsafe { &*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 HTLCUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
+       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCUpdate)).clone() })) as *mut c_void
+}
+#[no_mangle]
+pub extern "C" fn HTLCUpdate_write(obj: *const HTLCUpdate) -> crate::c_types::derived::CVec_u8Z {
+       crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
+}
+#[no_mangle]
+pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> HTLCUpdate {
+       if let Ok(res) = crate::c_types::deserialize_obj(ser) {
+               HTLCUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
+       } else {
+               HTLCUpdate { inner: std::ptr::null_mut(), is_owned: true }
+       }
+}
+
+use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
+type nativeChannelMonitor = nativeChannelMonitorImport<crate::chain::keysinterface::ChannelKeys>;
+
+/// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
+/// on-chain transactions to ensure no loss of funds occurs.
+///
+/// You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
+/// information and are actively monitoring the chain.
+///
+/// Pending Events or updated HTLCs which have not yet been read out by
+/// get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
+/// reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
+/// gotten are fully handled before re-serializing the new state.
+#[must_use]
+#[repr(C)]
+pub struct ChannelMonitor {
+       /// 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 nativeChannelMonitor,
+       pub is_owned: bool,
+}
+
+impl Drop for ChannelMonitor {
+       fn drop(&mut self) {
+               if self.is_owned && !self.inner.is_null() {
+                       let _ = unsafe { Box::from_raw(self.inner) };
+               }
+       }
+}
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_free(this_ptr: ChannelMonitor) { }
+#[allow(unused)]
+/// Used only if an object of this type is returned as a trait impl by a method
+extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
+       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitor); }
+}
+#[allow(unused)]
+/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
+impl ChannelMonitor {
+       pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitor {
+               assert!(self.is_owned);
+               let ret = self.inner;
+               self.inner = std::ptr::null_mut();
+               ret
+       }
+}
+/// Updates a ChannelMonitor on the basis of some new information provided by the Channel
+/// itself.
+///
+/// panics if the given update is not the next update by update_id.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &mut ChannelMonitor, mut updates: crate::chain::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.update_monitor(*unsafe { Box::from_raw(updates.take_ptr()) }, broadcaster, logger);
+       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::chain::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
+       local_ret
+}
+
+/// Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
+/// ChannelMonitor.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor) -> u64 {
+       let mut ret = unsafe { &*this_arg.inner }.get_latest_update_id();
+       ret
+}
+
+/// Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> crate::c_types::derived::C2Tuple_OutPointScriptZ {
+       let mut ret = unsafe { &*this_arg.inner }.get_funding_txo();
+       let (ref orig_ret_0, ref orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*orig_ret_0) as *const _) as *mut _) }, is_owned: false }, orig_ret_1.clone().into_bytes().into()).into();
+       local_ret
+}
+
+/// Get the list of HTLCs who's status has been updated on chain. This should be called by
+/// ChannelManager via [`chain::Watch::release_pending_monitor_events`].
+///
+/// [`chain::Watch::release_pending_monitor_events`]: ../trait.Watch.html#tymethod.release_pending_monitor_events
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_monitor_events();
+       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::chain::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
+       local_ret.into()
+}
+
+/// Gets the list of pending events which were generated by previous actions, clearing the list
+/// in the process.
+///
+/// This is called by ChainMonitor::get_and_clear_pending_events() and is equivalent to
+/// EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
+/// no internal locking in ChannelMonitors.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_events();
+       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
+       local_ret.into()
+}
+
+/// Used by ChannelManager deserialization to broadcast the latest holder state if its copy of
+/// the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of
+/// fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows
+/// a higher revocation secret than the holder commitment number we are aware of. Broadcasting these
+/// transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to
+/// broadcast them if counterparty don't close channel with his higher commitment transaction after a
+/// substantial amount of time (a month or even a year) to get back funds. Best may be to contact
+/// out-of-band the other node operator to coordinate with him if option is available to you.
+/// In any-case, choice is up to the user.
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_holder_commitment_txn(logger);
+       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); crate::c_types::Transaction::from_vec(local_ret_0) }); };
+       local_ret.into()
+}
+
+/// Processes transactions in a newly connected block, which may result in any of the following:
+/// - update the monitor's state against resolved HTLCs
+/// - punish the counterparty in the case of seeing a revoked commitment transaction
+/// - force close the channel and claim/timeout incoming/outgoing HTLCs if near expiration
+/// - detect settled outputs for later spending
+/// - schedule and bump any in-flight claims
+///
+/// Returns any new outputs to watch from `txdata`; after called, these are also included in
+/// [`get_outputs_to_watch`].
+///
+/// [`get_outputs_to_watch`]: #method.get_outputs_to_watch
+#[must_use]
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_block_connected(this_arg: &mut ChannelMonitor, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CVec_C2Tuple_TxidCVec_TxOutZZZ {
+       let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); };
+       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height, broadcaster, fee_estimator, logger);
+       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::TxOut::from_rust(item) }); }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.into_inner() }, local_orig_ret_0_1.into()).into(); local_ret_0 }); };
+       local_ret.into()
+}
+
+/// Determines if the disconnected block contained any transactions of interest and updates
+/// appropriately.
+#[no_mangle]
+pub extern "C" fn ChannelMonitor_block_disconnected(this_arg: &mut ChannelMonitor, header: *const [u8; 80], mut height: u32, mut broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut logger: crate::util::logger::Logger) {
+       unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, broadcaster, fee_estimator, logger)
+}
+
index 290b295537fdf807e01c2f8f1a150275b7c13059..8d8a0acd129f29fd383c9fad62531a4053edc4bb 100644 (file)
@@ -409,7 +409,7 @@ impl rustChannelKeys for ChannelKeys {
        fn sign_counterparty_commitment<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, feerate_per_kw: u32, commitment_tx: &bitcoin::blockdata::transaction::Transaction, keys: &lightning::ln::chan_utils::PreCalculatedTxCreationKeys, htlcs: &[&lightning::ln::chan_utils::HTLCOutputInCommitment], _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<(bitcoin::secp256k1::Signature, Vec<bitcoin::secp256k1::Signature>), ()> {
                let mut local_commitment_tx = ::bitcoin::consensus::encode::serialize(commitment_tx);
                let mut local_htlcs = Vec::new(); for item in htlcs.iter() { local_htlcs.push( { crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ( (&(**item) as *const _) as *mut _) }, is_owned: false } }); };
-               let mut ret = (self.sign_counterparty_commitment)(self.this_arg, feerate_per_kw, crate::c_types::Transaction::from_slice(&local_commitment_tx), &crate::ln::chan_utils::PreCalculatedTxCreationKeys { inner: unsafe { (keys as *const _) as *mut _ }, is_owned: false }, local_htlcs.into());
+               let mut ret = (self.sign_counterparty_commitment)(self.this_arg, feerate_per_kw, crate::c_types::Transaction::from_vec(local_commitment_tx), &crate::ln::chan_utils::PreCalculatedTxCreationKeys { inner: unsafe { (keys as *const _) as *mut _ }, is_owned: false }, local_htlcs.into());
                let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).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(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
@@ -426,19 +426,19 @@ impl rustChannelKeys for ChannelKeys {
        fn sign_justice_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, justice_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_key: &bitcoin::secp256k1::key::SecretKey, htlc: &Option<lightning::ln::chan_utils::HTLCOutputInCommitment>, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
                let mut local_justice_tx = ::bitcoin::consensus::encode::serialize(justice_tx);
                let mut local_htlc = &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (if htlc.is_none() { std::ptr::null() } else {  { (htlc.as_ref().unwrap()) } } as *const _) as *mut _ }, is_owned: false };
-               let mut ret = (self.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_justice_tx), input, amount, per_commitment_key.as_ref(), local_htlc);
+               let mut ret = (self.sign_justice_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_justice_tx), input, amount, per_commitment_key.as_ref(), local_htlc);
                let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
        fn sign_counterparty_htlc_transaction<T:bitcoin::secp256k1::Signing + bitcoin::secp256k1::Verification>(&self, htlc_tx: &bitcoin::blockdata::transaction::Transaction, input: usize, amount: u64, per_commitment_point: &bitcoin::secp256k1::key::PublicKey, htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
                let mut local_htlc_tx = ::bitcoin::consensus::encode::serialize(htlc_tx);
-               let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
+               let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { (htlc as *const _) as *mut _ }, is_owned: false });
                let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
        fn sign_closing_transaction<T:bitcoin::secp256k1::Signing>(&self, closing_tx: &bitcoin::blockdata::transaction::Transaction, _secp_ctx: &bitcoin::secp256k1::Secp256k1<T>) -> Result<bitcoin::secp256k1::Signature, ()> {
                let mut local_closing_tx = ::bitcoin::consensus::encode::serialize(closing_tx);
-               let mut ret = (self.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_slice(&local_closing_tx));
+               let mut ret = (self.sign_closing_transaction)(self.this_arg, crate::c_types::Transaction::from_vec(local_closing_tx));
                let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(ret.contents.err.take_ptr()) })*/ })};
                local_ret
        }
@@ -548,7 +548,7 @@ type nativeInMemoryChannelKeys = nativeInMemoryChannelKeysImport;
 #[must_use]
 #[repr(C)]
 pub struct InMemoryChannelKeys {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeInMemoryChannelKeys,
        pub is_owned: bool,
@@ -750,7 +750,7 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_key_derivation_params(this_arg: *c
        local_ret
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, mut feerate_per_kw: u32, commitment_tx: crate::c_types::Transaction, pre_keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, mut htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_commitment(this_arg: *const c_void, mut feerate_per_kw: u32, mut commitment_tx: crate::c_types::Transaction, pre_keys: &crate::ln::chan_utils::PreCalculatedTxCreationKeys, mut htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> crate::c_types::derived::CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
        let mut local_htlcs = Vec::new(); for mut item in htlcs.as_slice().iter() { local_htlcs.push( { unsafe { &*item.inner } }); };
        let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_commitment(feerate_per_kw, &commitment_tx.into_bitcoin(), unsafe { &*pre_keys.inner }, &local_htlcs[..], &bitcoin::secp256k1::Secp256k1::new());
        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 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 }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
@@ -769,20 +769,20 @@ extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_holder_commitment_htlc_transa
        local_ret
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_justice_transaction(this_arg: *const c_void, justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_justice_transaction(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
        let mut local_htlc = if htlc.inner.is_null() { None } else { Some((* { unsafe { &*htlc.inner } }).clone()) };
        let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_justice_transaction(&justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), &local_htlc, &bitcoin::secp256k1::Secp256k1::new());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
        local_ret
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction(this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_SignatureNoneZ {
        let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_counterparty_htlc_transaction(&htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), unsafe { &*htlc.inner }, &bitcoin::secp256k1::Secp256k1::new());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
        local_ret
 }
 #[must_use]
-extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_closing_transaction(this_arg: *const c_void, closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
+extern "C" fn InMemoryChannelKeys_ChannelKeys_sign_closing_transaction(this_arg: *const c_void, mut closing_tx: crate::c_types::Transaction) -> crate::c_types::derived::CResult_SignatureNoneZ {
        let mut ret = unsafe { &mut *(this_arg as *mut nativeInMemoryChannelKeys) }.sign_closing_transaction(&closing_tx.into_bitcoin(), &bitcoin::secp256k1::Secp256k1::new());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Signature::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { 0u8 /*e*/ }) };
        local_ret
@@ -823,7 +823,7 @@ type nativeKeysManager = nativeKeysManagerImport;
 #[must_use]
 #[repr(C)]
 pub struct KeysManager {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeKeysManager,
        pub is_owned: bool,
index 44ce4c142203b805123a1af799c18ce67bb3227b..cbfa6074ada4f2f3055c733784c0a0a5e3552570 100644 (file)
@@ -5,5 +5,248 @@ use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
 pub mod chaininterface;
+pub mod chainmonitor;
+pub mod channelmonitor;
 pub mod transaction;
 pub mod keysinterface;
+/// An error when accessing the chain via [`Access`].
+///
+/// [`Access`]: trait.Access.html
+#[must_use]
+#[derive(Clone)]
+#[repr(C)]
+pub enum AccessError {
+       /// The requested chain is unknown.
+       UnknownChain,
+       /// The requested transaction doesn't exist or hasn't confirmed.
+       UnknownTx,
+}
+use lightning::chain::AccessError as nativeAccessError;
+impl AccessError {
+       #[allow(unused)]
+       pub(crate) fn to_native(&self) -> nativeAccessError {
+               match self {
+                       AccessError::UnknownChain => nativeAccessError::UnknownChain,
+                       AccessError::UnknownTx => nativeAccessError::UnknownTx,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn into_native(self) -> nativeAccessError {
+               match self {
+                       AccessError::UnknownChain => nativeAccessError::UnknownChain,
+                       AccessError::UnknownTx => nativeAccessError::UnknownTx,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn from_native(native: &nativeAccessError) -> Self {
+               match native {
+                       nativeAccessError::UnknownChain => AccessError::UnknownChain,
+                       nativeAccessError::UnknownTx => AccessError::UnknownTx,
+               }
+       }
+       #[allow(unused)]
+       pub(crate) fn native_into(native: nativeAccessError) -> Self {
+               match native {
+                       nativeAccessError::UnknownChain => AccessError::UnknownChain,
+                       nativeAccessError::UnknownTx => AccessError::UnknownTx,
+               }
+       }
+}
+/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and
+/// UTXOs.
+#[repr(C)]
+pub struct Access {
+       pub this_arg: *mut c_void,
+       /// 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
+       #[must_use]
+       pub get_utxo: extern "C" fn (this_arg: *const c_void, genesis_hash: *const [u8; 32], short_channel_id: u64) -> crate::c_types::derived::CResult_TxOutAccessErrorZ,
+       pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for Access {}
+unsafe impl Sync for Access {}
+
+use lightning::chain::Access as rustAccess;
+impl rustAccess for Access {
+       fn get_utxo(&self, genesis_hash: &bitcoin::hash_types::BlockHash, short_channel_id: u64) -> Result<bitcoin::blockdata::transaction::TxOut, lightning::chain::AccessError> {
+               let mut ret = (self.get_utxo)(self.this_arg, genesis_hash.as_inner(), short_channel_id);
+               let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(ret.contents.result.take_ptr()) }).into_rust() }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
+               local_ret
+       }
+}
+
+// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
+// directly as a Deref trait in higher-level structs:
+impl std::ops::Deref for Access {
+       type Target = Self;
+       fn deref(&self) -> &Self {
+               self
+       }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn Access_free(this_ptr: Access) { }
+impl Drop for Access {
+       fn drop(&mut self) {
+               if let Some(f) = self.free {
+                       f(self.this_arg);
+               }
+       }
+}
+/// The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
+/// blocks are connected and disconnected.
+///
+/// Each channel is associated with a [`ChannelMonitor`]. Implementations of this trait are
+/// responsible for maintaining a set of monitors such that they can be updated accordingly as
+/// channel state changes and HTLCs are resolved. See method documentation for specific
+/// requirements.
+///
+/// Implementations **must** ensure that updates are successfully applied and persisted upon method
+/// completion. If an update fails with a [`PermanentFailure`], then it must immediately shut down
+/// without taking any further action such as persisting the current state.
+///
+/// If an implementation maintains multiple instances of a channel's monitor (e.g., by storing
+/// backup copies), then it must ensure that updates are applied across all instances. Otherwise, it
+/// could result in a revoked transaction being broadcast, allowing the counterparty to claim all
+/// funds in the channel. See [`ChannelMonitorUpdateErr`] for more details about how to handle
+/// multiple instances.
+///
+/// [`ChannelMonitor`]: channelmonitor/struct.ChannelMonitor.html
+/// [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+/// [`PermanentFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.PermanentFailure
+#[repr(C)]
+pub struct Watch {
+       pub this_arg: *mut c_void,
+       /// Watches a channel identified by `funding_txo` using `monitor`.
+       ///
+       /// Implementations are responsible for watching the chain for the funding transaction along
+       /// with any spends of outputs returned by [`get_outputs_to_watch`]. In practice, this means
+       /// calling [`block_connected`] and [`block_disconnected`] on the monitor.
+       ///
+       /// [`get_outputs_to_watch`]: channelmonitor/struct.ChannelMonitor.html#method.get_outputs_to_watch
+       /// [`block_connected`]: channelmonitor/struct.ChannelMonitor.html#method.block_connected
+       /// [`block_disconnected`]: channelmonitor/struct.ChannelMonitor.html#method.block_disconnected
+       #[must_use]
+       pub watch_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
+       /// Updates a channel identified by `funding_txo` by applying `update` to its monitor.
+       ///
+       /// Implementations must call [`update_monitor`] with the given update. See
+       /// [`ChannelMonitorUpdateErr`] for invariants around returning an error.
+       ///
+       /// [`update_monitor`]: channelmonitor/struct.ChannelMonitor.html#method.update_monitor
+       /// [`ChannelMonitorUpdateErr`]: channelmonitor/enum.ChannelMonitorUpdateErr.html
+       #[must_use]
+       pub update_channel: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, update: crate::chain::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
+       /// Returns any monitor events since the last call. Subsequent calls must only return new
+       /// events.
+       #[must_use]
+       pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ,
+       pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for Watch {}
+unsafe impl Sync for Watch {}
+
+use lightning::chain::Watch as rustWatch;
+impl rustWatch for Watch {
+       type Keys = crate::chain::keysinterface::ChannelKeys;
+       fn watch_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::chain::channelmonitor::ChannelMonitor<Self::Keys>) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> {
+               let mut ret = (self.watch_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::chain::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
+               let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
+               local_ret
+       }
+       fn update_channel(&self, funding_txo: lightning::chain::transaction::OutPoint, update: lightning::chain::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::chain::channelmonitor::ChannelMonitorUpdateErr> {
+               let mut ret = (self.update_channel)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::chain::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(update)), is_owned: true });
+               let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
+               local_ret
+       }
+       fn release_pending_monitor_events(&self) -> Vec<lightning::chain::channelmonitor::MonitorEvent> {
+               let mut ret = (self.release_pending_monitor_events)(self.this_arg);
+               let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
+               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 Watch {
+       type Target = Self;
+       fn deref(&self) -> &Self {
+               self
+       }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn Watch_free(this_ptr: Watch) { }
+impl Drop for Watch {
+       fn drop(&mut self) {
+               if let Some(f) = self.free {
+                       f(self.this_arg);
+               }
+       }
+}
+/// 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`].
+///
+/// [`Watch`]: trait.Watch.html
+/// [`TemporaryFailure`]: channelmonitor/enum.ChannelMonitorUpdateErr.html#variant.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
+#[repr(C)]
+pub struct Filter {
+       pub this_arg: *mut c_void,
+       /// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
+       /// a spending condition.
+       pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice),
+       /// Registers interest in spends of a transaction output identified by `outpoint` having
+       /// `script_pubkey` as the spending condition.
+       pub register_output: extern "C" fn (this_arg: *const c_void, outpoint: &crate::chain::transaction::OutPoint, script_pubkey: crate::c_types::u8slice),
+       pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
+}
+unsafe impl Send for Filter {}
+unsafe impl Sync for Filter {}
+
+use lightning::chain::Filter as rustFilter;
+impl rustFilter for Filter {
+       fn register_tx(&self, txid: &bitcoin::hash_types::Txid, script_pubkey: &bitcoin::blockdata::script::Script) {
+               (self.register_tx)(self.this_arg, txid.as_inner(), crate::c_types::u8slice::from_slice(&script_pubkey[..]))
+       }
+       fn register_output(&self, outpoint: &lightning::chain::transaction::OutPoint, script_pubkey: &bitcoin::blockdata::script::Script) {
+               (self.register_output)(self.this_arg, &crate::chain::transaction::OutPoint { inner: unsafe { (outpoint as *const _) as *mut _ }, is_owned: false }, crate::c_types::u8slice::from_slice(&script_pubkey[..]))
+       }
+}
+
+// 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 Filter {
+       type Target = Self;
+       fn deref(&self) -> &Self {
+               self
+       }
+}
+/// Calls the free function if one is set
+#[no_mangle]
+pub extern "C" fn Filter_free(this_ptr: Filter) { }
+impl Drop for Filter {
+       fn drop(&mut self) {
+               if let Some(f) = self.free {
+                       f(self.this_arg);
+               }
+       }
+}
index 39236768def15fbc7de7dcbd2339f194764f793c..9d099cb6939f52a664e2d66fce645a1841ce5977 100644 (file)
@@ -1,4 +1,4 @@
-//! Contains simple structs describing parts of transactions on the chain.
+//! Types describing on-chain transactions.
 
 use std::ffi::c_void;
 use bitcoin::hashes::Hash;
@@ -15,7 +15,7 @@ type nativeOutPoint = nativeOutPointImport;
 #[must_use]
 #[repr(C)]
 pub struct OutPoint {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeOutPoint,
        pub is_owned: bool,
index bf3953a09e40f9b20e2705afb91440c72fde0784..038ad71c051d27f53e36f683ea4bcf3d70c0e2f3 100644 (file)
@@ -19,7 +19,7 @@ pub extern "C" fn build_commitment_secret(commitment_seed: *const [u8; 32], mut
 /// Note that this is infallible iff we trust that at least one of the two input keys are randomly
 /// generated (ie our own).
 #[no_mangle]
-pub extern "C" fn derive_private_key(per_commitment_point: crate::c_types::PublicKey, base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeySecpErrorZ {
+pub extern "C" fn derive_private_key(mut per_commitment_point: crate::c_types::PublicKey, base_secret: *const [u8; 32]) -> crate::c_types::derived::CResult_SecretKeySecpErrorZ {
        let mut ret = lightning::ln::chan_utils::derive_private_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *base_secret}[..]).unwrap());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SecretKey::from_rust(o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
        local_ret
@@ -32,7 +32,7 @@ pub extern "C" fn derive_private_key(per_commitment_point: crate::c_types::Publi
 /// Note that this is infallible iff we trust that at least one of the two input keys are randomly
 /// generated (ie our own).
 #[no_mangle]
-pub extern "C" fn derive_public_key(per_commitment_point: crate::c_types::PublicKey, base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ {
+pub extern "C" fn derive_public_key(mut per_commitment_point: crate::c_types::PublicKey, mut base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ {
        let mut ret = lightning::ln::chan_utils::derive_public_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &base_point.into_rust());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
        local_ret
@@ -66,7 +66,7 @@ pub extern "C" fn derive_private_revocation_key(per_commitment_secret: *const [u
 /// Note that this is infallible iff we trust that at least one of the two input keys are randomly
 /// generated (ie our own).
 #[no_mangle]
-pub extern "C" fn derive_public_revocation_key(per_commitment_point: crate::c_types::PublicKey, countersignatory_revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ {
+pub extern "C" fn derive_public_revocation_key(mut per_commitment_point: crate::c_types::PublicKey, mut countersignatory_revocation_base_point: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_PublicKeySecpErrorZ {
        let mut ret = lightning::ln::chan_utils::derive_public_revocation_key(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &countersignatory_revocation_base_point.into_rust());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
        local_ret
@@ -90,7 +90,7 @@ type nativeTxCreationKeys = nativeTxCreationKeysImport;
 #[must_use]
 #[repr(C)]
 pub struct TxCreationKeys {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeTxCreationKeys,
        pub is_owned: bool,
@@ -226,7 +226,7 @@ type nativePreCalculatedTxCreationKeys = nativePreCalculatedTxCreationKeysImport
 #[must_use]
 #[repr(C)]
 pub struct PreCalculatedTxCreationKeys {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativePreCalculatedTxCreationKeys,
        pub is_owned: bool,
@@ -289,7 +289,7 @@ type nativeChannelPublicKeys = nativeChannelPublicKeysImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelPublicKeys {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelPublicKeys,
        pub is_owned: bool,
@@ -431,7 +431,7 @@ pub extern "C" fn ChannelPublicKeys_read(ser: crate::c_types::u8slice) -> Channe
 /// Create a new TxCreationKeys from channel base points and the per-commitment point
 #[must_use]
 #[no_mangle]
-pub extern "C" fn TxCreationKeys_derive_new(per_commitment_point: crate::c_types::PublicKey, broadcaster_delayed_payment_base: crate::c_types::PublicKey, broadcaster_htlc_base: crate::c_types::PublicKey, countersignatory_revocation_base: crate::c_types::PublicKey, countersignatory_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysSecpErrorZ {
+pub extern "C" fn TxCreationKeys_derive_new(mut per_commitment_point: crate::c_types::PublicKey, mut broadcaster_delayed_payment_base: crate::c_types::PublicKey, mut broadcaster_htlc_base: crate::c_types::PublicKey, mut countersignatory_revocation_base: crate::c_types::PublicKey, mut countersignatory_htlc_base: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_TxCreationKeysSecpErrorZ {
        let mut ret = lightning::ln::chan_utils::TxCreationKeys::derive_new(&bitcoin::secp256k1::Secp256k1::new(), &per_commitment_point.into_rust(), &broadcaster_delayed_payment_base.into_rust(), &broadcaster_htlc_base.into_rust(), &countersignatory_revocation_base.into_rust(), &countersignatory_htlc_base.into_rust());
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::ln::chan_utils::TxCreationKeys { inner: Box::into_raw(Box::new(o)), is_owned: true } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }) };
        local_ret
@@ -441,7 +441,7 @@ pub extern "C" fn TxCreationKeys_derive_new(per_commitment_point: crate::c_types
 /// key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain.
 /// Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions.
 #[no_mangle]
-pub extern "C" fn get_revokeable_redeemscript(revocation_key: crate::c_types::PublicKey, mut contest_delay: u16, broadcaster_delayed_payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
+pub extern "C" fn get_revokeable_redeemscript(mut revocation_key: crate::c_types::PublicKey, mut contest_delay: u16, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
        let mut ret = lightning::ln::chan_utils::get_revokeable_redeemscript(&revocation_key.into_rust(), contest_delay, &broadcaster_delayed_payment_key.into_rust());
        ret.into_bytes().into()
 }
@@ -454,7 +454,7 @@ type nativeHTLCOutputInCommitment = nativeHTLCOutputInCommitmentImport;
 #[must_use]
 #[repr(C)]
 pub struct HTLCOutputInCommitment {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeHTLCOutputInCommitment,
        pub is_owned: bool,
@@ -572,17 +572,17 @@ pub extern "C" fn get_htlc_redeemscript(htlc: &crate::ln::chan_utils::HTLCOutput
 /// Gets the redeemscript for a funding output from the two funding public keys.
 /// Note that the order of funding public keys does not matter.
 #[no_mangle]
-pub extern "C" fn make_funding_redeemscript(broadcaster: crate::c_types::PublicKey, countersignatory: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
+pub extern "C" fn make_funding_redeemscript(mut broadcaster: crate::c_types::PublicKey, mut countersignatory: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
        let mut ret = lightning::ln::chan_utils::make_funding_redeemscript(&broadcaster.into_rust(), &countersignatory.into_rust());
        ret.into_bytes().into()
 }
 
 /// panics if htlc.transaction_output_index.is_none()!
 #[no_mangle]
-pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, broadcaster_delayed_payment_key: crate::c_types::PublicKey, revocation_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z {
+pub extern "C" fn build_htlc_transaction(prev_hash: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::ln::chan_utils::HTLCOutputInCommitment, mut broadcaster_delayed_payment_key: crate::c_types::PublicKey, mut revocation_key: crate::c_types::PublicKey) -> crate::c_types::Transaction {
        let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*prev_hash }[..]).unwrap(), feerate_per_kw, contest_delay, unsafe { &*htlc.inner }, &broadcaster_delayed_payment_key.into_rust(), &revocation_key.into_rust());
        let mut local_ret = ::bitcoin::consensus::encode::serialize(&ret);
-       local_ret.into()
+       crate::c_types::Transaction::from_vec(local_ret)
 }
 
 
@@ -595,7 +595,7 @@ type nativeHolderCommitmentTransaction = nativeHolderCommitmentTransactionImport
 #[must_use]
 #[repr(C)]
 pub struct HolderCommitmentTransaction {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeHolderCommitmentTransaction,
        pub is_owned: bool,
@@ -640,15 +640,15 @@ pub(crate) extern "C" fn HolderCommitmentTransaction_clone_void(this_ptr: *const
 }
 /// The commitment transaction itself, in unsigned form.
 #[no_mangle]
-pub extern "C" fn HolderCommitmentTransaction_get_unsigned_tx(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::derived::CVec_u8Z {
+pub extern "C" fn HolderCommitmentTransaction_get_unsigned_tx(this_ptr: &HolderCommitmentTransaction) -> crate::c_types::Transaction {
        let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.unsigned_tx;
        let mut local_inner_val = ::bitcoin::consensus::encode::serialize(inner_val);
-       local_inner_val.into()
+       crate::c_types::Transaction::from_vec(local_inner_val)
 }
 /// The commitment transaction itself, in unsigned form.
 #[no_mangle]
-pub extern "C" fn HolderCommitmentTransaction_set_unsigned_tx(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::derived::CVec_u8Z) {
-       unsafe { &mut *this_ptr.inner }.unsigned_tx = ::bitcoin::consensus::encode::deserialize(&val.into_rust()[..]).unwrap();
+pub extern "C" fn HolderCommitmentTransaction_set_unsigned_tx(this_ptr: &mut HolderCommitmentTransaction, mut val: crate::c_types::Transaction) {
+       unsafe { &mut *this_ptr.inner }.unsigned_tx = val.into_bitcoin();
 }
 /// Our counterparty's signature for the transaction, above.
 #[no_mangle]
@@ -694,9 +694,9 @@ pub extern "C" fn HolderCommitmentTransaction_set_per_htlc(this_ptr: &mut Holder
 /// only checks that the shape and amounts are consistent, but does not check the scriptPubkey.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn HolderCommitmentTransaction_new_missing_holder_sig(mut unsigned_tx: crate::c_types::derived::CVec_u8Z, mut counterparty_sig: crate::c_types::Signature, holder_funding_key: crate::c_types::PublicKey, counterparty_funding_key: crate::c_types::PublicKey, mut keys: crate::ln::chan_utils::TxCreationKeys, mut feerate_per_kw: u32, mut htlc_data: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) -> crate::ln::chan_utils::HolderCommitmentTransaction {
+pub extern "C" fn HolderCommitmentTransaction_new_missing_holder_sig(mut unsigned_tx: crate::c_types::Transaction, mut counterparty_sig: crate::c_types::Signature, mut holder_funding_key: crate::c_types::PublicKey, mut counterparty_funding_key: crate::c_types::PublicKey, mut keys: crate::ln::chan_utils::TxCreationKeys, mut feerate_per_kw: u32, mut htlc_data: crate::c_types::derived::CVec_C2Tuple_HTLCOutputInCommitmentSignatureZZ) -> crate::ln::chan_utils::HolderCommitmentTransaction {
        let mut local_htlc_data = Vec::new(); for mut item in htlc_data.into_rust().drain(..) { local_htlc_data.push( { let (mut orig_htlc_data_0_0, mut orig_htlc_data_0_1) = item.to_rust(); let mut local_orig_htlc_data_0_1 = if orig_htlc_data_0_1.is_null() { None } else { Some( { orig_htlc_data_0_1.into_rust() }) }; let mut local_htlc_data_0 = (*unsafe { Box::from_raw(orig_htlc_data_0_0.take_ptr()) }, local_orig_htlc_data_0_1); local_htlc_data_0 }); };
-       let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new_missing_holder_sig(::bitcoin::consensus::encode::deserialize(&unsigned_tx.into_rust()[..]).unwrap(), counterparty_sig.into_rust(), &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust(), *unsafe { Box::from_raw(keys.take_ptr()) }, feerate_per_kw, local_htlc_data);
+       let mut ret = lightning::ln::chan_utils::HolderCommitmentTransaction::new_missing_holder_sig(unsigned_tx.into_bitcoin(), counterparty_sig.into_rust(), &holder_funding_key.into_rust(), &counterparty_funding_key.into_rust(), *unsafe { Box::from_raw(keys.take_ptr()) }, feerate_per_kw, local_htlc_data);
        crate::ln::chan_utils::HolderCommitmentTransaction { inner: Box::into_raw(Box::new(ret)), is_owned: true }
 }
 
@@ -728,7 +728,7 @@ pub extern "C" fn HolderCommitmentTransaction_txid(this_arg: &HolderCommitmentTr
 /// Channel value is amount locked in funding_outpoint.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn HolderCommitmentTransaction_get_holder_sig(this_arg: &HolderCommitmentTransaction, funding_key: *const [u8; 32], funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::Signature {
+pub extern "C" fn HolderCommitmentTransaction_get_holder_sig(this_arg: &HolderCommitmentTransaction, 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 { &*this_arg.inner }.get_holder_sig(&::bitcoin::secp256k1::key::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), &::bitcoin::blockdata::script::Script::from(Vec::from(funding_redeemscript.to_slice())), channel_value_satoshis, &bitcoin::secp256k1::Secp256k1::new());
        crate::c_types::Signature::from_rust(&ret)
 }
index c71305904c71f0a809a58b182cb5d02c388e8aef..7d9028a572586b66fbb62d2535d44d3ae9dc7f88 100644 (file)
@@ -7,6 +7,7 @@
 //! It does not manage routing logic (see routing::router::get_route for that) nor does it manage constructing
 //! on-chain transactions (it only monitors the chain to watch for any force-closes that might
 //! imply it needs to fail HTLCs/payments/channels it manages).
+//!
 
 use std::ffi::c_void;
 use bitcoin::hashes::Hash;
@@ -14,7 +15,7 @@ use crate::c_types::*;
 
 
 use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport;
-type nativeChannelManager = nativeChannelManagerImport<crate::chain::keysinterface::ChannelKeys, crate::ln::channelmonitor::ManyChannelMonitor, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>;
+type nativeChannelManager = nativeChannelManagerImport<crate::chain::keysinterface::ChannelKeys, crate::chain::Watch, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>;
 
 /// Manager which keeps track of a number of channels and sends messages to the appropriate
 /// channel, also tracking HTLC preimages and forwarding onion packets appropriately.
@@ -29,7 +30,7 @@ type nativeChannelManager = nativeChannelManagerImport<crate::chain::keysinterfa
 ///
 /// Note that you can be a bit lazier about writing out ChannelManager than you can be with
 /// ChannelMonitors. With ChannelMonitors you MUST write each monitor update out to disk before
-/// returning from ManyChannelMonitor::add_/update_monitor, with ChannelManagers, writing updates
+/// returning from chain::Watch::watch_/update_channel, with ChannelManagers, writing updates
 /// happens out-of-band (and will prevent any other ChannelManager operations from occurring during
 /// the serialization process). If the deserialized version is out-of-date compared to the
 /// ChannelMonitors passed by reference to read(), those channels will be force-closed based on the
@@ -55,7 +56,7 @@ type nativeChannelManager = nativeChannelManagerImport<crate::chain::keysinterfa
 #[must_use]
 #[repr(C)]
 pub struct ChannelManager {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelManager,
        pub is_owned: bool,
@@ -93,7 +94,7 @@ type nativeChannelDetails = nativeChannelDetailsImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelDetails {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeChannelDetails,
        pub is_owned: bool,
@@ -247,7 +248,7 @@ type nativePaymentSendFailure = nativePaymentSendFailureImport;
 #[must_use]
 #[repr(C)]
 pub struct PaymentSendFailure {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativePaymentSendFailure,
        pub is_owned: bool,
@@ -291,14 +292,10 @@ impl PaymentSendFailure {
 ///
 /// Users need to notify the new ChannelManager when a new block is connected or
 /// disconnected using its `block_connected` and `block_disconnected` methods.
-/// However, rather than calling these methods directly, the user should register
-/// the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
-/// `block_(dis)connected` methods, which will notify all registered listeners in one
-/// go.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelManager_new(mut network: crate::bitcoin::network::Network, mut fee_est: crate::chain::chaininterface::FeeEstimator, mut monitor: crate::ln::channelmonitor::ManyChannelMonitor, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut keys_manager: crate::chain::keysinterface::KeysInterface, mut config: crate::util::config::UserConfig, mut current_blockchain_height: usize) -> ChannelManager {
-       let mut ret = lightning::ln::channelmanager::ChannelManager::new(network.into_bitcoin(), fee_est, monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_ptr()) }, current_blockchain_height);
+pub extern "C" fn ChannelManager_new(mut network: crate::bitcoin::network::Network, mut fee_est: crate::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::chain::Watch, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut keys_manager: crate::chain::keysinterface::KeysInterface, mut config: crate::util::config::UserConfig, mut current_blockchain_height: usize) -> ChannelManager {
+       let mut ret = lightning::ln::channelmanager::ChannelManager::new(network.into_bitcoin(), fee_est, chain_monitor, tx_broadcaster, logger, keys_manager, *unsafe { Box::from_raw(config.take_ptr()) }, current_blockchain_height);
        ChannelManager { inner: Box::into_raw(Box::new(ret)), is_owned: true }
 }
 
@@ -414,7 +411,7 @@ pub extern "C" fn ChannelManager_force_close_all_channels(this_arg: &ChannelMana
 /// we assume the invoice had the basic_mpp feature set.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelManager_send_payment(this_arg: &ChannelManager, route: &crate::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
+pub extern "C" fn ChannelManager_send_payment(this_arg: &ChannelManager, route: &crate::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ {
        let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
        let mut ret = unsafe { &*this_arg.inner }.send_payment(unsafe { &*route.inner }, ::lightning::ln::channelmanager::PaymentHash(payment_hash.data), &local_payment_secret);
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmanager::PaymentSendFailure { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
@@ -480,7 +477,7 @@ pub extern "C" fn ChannelManager_timer_chan_freshness_every_min(this_arg: &Chann
 /// HTLC backwards has been started.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, payment_hash: *const [u8; 32], payment_secret: crate::c_types::ThirtyTwoBytes) -> bool {
+pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager, payment_hash: *const [u8; 32], mut payment_secret: crate::c_types::ThirtyTwoBytes) -> bool {
        let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
        let mut ret = unsafe { &*this_arg.inner }.fail_htlc_backwards(&::lightning::ln::channelmanager::PaymentHash(unsafe { *payment_hash }), &local_payment_secret);
        ret
@@ -503,7 +500,7 @@ pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &ChannelManager,
 /// May panic if called except in response to a PaymentReceived event.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelManager_claim_funds(this_arg: &ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, payment_secret: crate::c_types::ThirtyTwoBytes, mut expected_amount: u64) -> bool {
+pub extern "C" fn ChannelManager_claim_funds(this_arg: &ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes, mut expected_amount: u64) -> bool {
        let mut local_payment_secret = if payment_secret.data == [0; 32] { None } else { Some( { ::lightning::ln::channelmanager::PaymentSecret(payment_secret.data) }) };
        let mut ret = unsafe { &*this_arg.inner }.claim_funds(::lightning::ln::channelmanager::PaymentPreimage(payment_preimage.data), &local_payment_secret, expected_amount);
        ret
@@ -530,7 +527,7 @@ pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &ChannelManager) -> c
 /// exists largely only to prevent races between this and concurrent update_monitor calls.
 ///
 /// Thus, the anticipated use is, at a high level:
-///  1) You register a ManyChannelMonitor with this ChannelManager,
+///  1) You register a chain::Watch with this ChannelManager,
 ///  2) it stores each update to disk, and begins updating any remote (eg watchtower) copies of
 ///     said ChannelMonitors as it can, returning ChannelMonitorUpdateErr::TemporaryFailures
 ///     any time it cannot do so instantly,
@@ -574,22 +571,20 @@ extern "C" fn ChannelManager_EventsProvider_get_and_clear_pending_events(this_ar
        local_ret.into()
 }
 
+/// Updates channel state based on transactions seen in a connected block.
 #[no_mangle]
-pub extern "C" fn ChannelManager_as_ChainListener(this_arg: *const ChannelManager) -> crate::chain::chaininterface::ChainListener {
-       crate::chain::chaininterface::ChainListener {
-               this_arg: unsafe { (*this_arg).inner as *mut c_void },
-               free: None,
-               block_connected: ChannelManager_ChainListener_block_connected,
-               block_disconnected: ChannelManager_ChainListener_block_disconnected,
-       }
+pub extern "C" fn ChannelManager_block_connected(this_arg: &ChannelManager, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) {
+       let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); };
+       unsafe { &*this_arg.inner }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::<Vec<_>>()[..], height)
 }
-use lightning::chain::chaininterface::ChainListener as ChainListenerTraitImport;
-extern "C" fn ChannelManager_ChainListener_block_connected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32, mut txn_matched: crate::c_types::derived::CVec_TransactionZ, mut indexes_of_txn_matched: crate::c_types::usizeslice) {
-       let mut local_txn_matched = Vec::new(); for mut item in txn_matched.into_rust().drain(..) { local_txn_matched.push( { ::bitcoin::consensus::encode::deserialize(&item.into_rust()[..]).unwrap() }); };
-       unsafe { &mut *(this_arg as *mut nativeChannelManager) }.block_connected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height, &local_txn_matched.iter().collect::<Vec<_>>()[..], indexes_of_txn_matched.to_slice())
-}
-extern "C" fn ChannelManager_ChainListener_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], unused_0: u32) {
-       unsafe { &mut *(this_arg as *mut nativeChannelManager) }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), unused_0)
+
+/// Updates channel state based on a disconnected block.
+///
+/// If necessary, the channel may be force-closed without letting the counterparty participate
+/// in the shutdown.
+#[no_mangle]
+pub extern "C" fn ChannelManager_block_disconnected(this_arg: &ChannelManager, header: *const [u8; 80]) {
+       unsafe { &*this_arg.inner }.block_disconnected(&::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap())
 }
 
 #[no_mangle]
@@ -624,61 +619,61 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: *const Chann
        }
 }
 use lightning::ln::msgs::ChannelMessageHandler as ChannelMessageHandlerTraitImport;
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::OpenChannel) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_open_channel(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut their_features: crate::ln::features::InitFeatures, msg: &crate::ln::msgs::AcceptChannel) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_accept_channel(&counterparty_node_id.into_rust(), *unsafe { Box::from_raw(their_features.take_ptr()) }, unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingCreated) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_created(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingSigned) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_signed(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_locked(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::FundingLocked) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_funding_locked(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::Shutdown) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_shutdown(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ClosingSigned) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_closing_signed(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateAddHTLC) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_add_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFulfillHTLC) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fulfill_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailHTLC) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFailMalformedHTLC) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fail_malformed_htlc(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::CommitmentSigned) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_commitment_signed(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::RevokeAndACK) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_revoke_and_ack(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::UpdateFee) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_update_fee(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::AnnouncementSignatures) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_announcement_signatures(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ChannelReestablish) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_channel_reestablish(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
+extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, mut no_connection_possible: bool) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_disconnected(&counterparty_node_id.into_rust(), no_connection_possible)
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) {
+extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, init_msg: &crate::ln::msgs::Init) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.peer_connected(&counterparty_node_id.into_rust(), unsafe { &*init_msg.inner })
 }
-extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage) {
+extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut counterparty_node_id: crate::c_types::PublicKey, msg: &crate::ln::msgs::ErrorMessage) {
        unsafe { &mut *(this_arg as *mut nativeChannelManager) }.handle_error(&counterparty_node_id.into_rust(), unsafe { &*msg.inner })
 }
 use lightning::util::events::MessageSendEventsProvider as nativeMessageSendEventsProviderTrait;
@@ -691,7 +686,7 @@ extern "C" fn ChannelManager_ChannelMessageHandler_get_and_clear_pending_msg_eve
 
 
 use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport;
-type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::chain::keysinterface::ChannelKeys, crate::ln::channelmonitor::ManyChannelMonitor, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>;
+type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::chain::keysinterface::ChannelKeys, crate::chain::Watch, crate::chain::chaininterface::BroadcasterInterface, crate::chain::keysinterface::KeysInterface, crate::chain::chaininterface::FeeEstimator, crate::util::logger::Logger>;
 
 /// Arguments for the creation of a ChannelManager that are not deserialized.
 ///
@@ -703,15 +698,14 @@ type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static,
 ///    This may result in closing some Channels if the ChannelMonitor is newer than the stored
 ///    ChannelManager state to ensure no loss of funds. Thus, transactions may be broadcasted.
 /// 3) Register all relevant ChannelMonitor outpoints with your chain watch mechanism using
-///    ChannelMonitor::get_monitored_outpoints and ChannelMonitor::get_funding_txo().
+///    ChannelMonitor::get_outputs_to_watch() and ChannelMonitor::get_funding_txo().
 /// 4) Reconnect blocks on your ChannelMonitors.
-/// 5) Move the ChannelMonitors into your local ManyChannelMonitor.
+/// 5) Move the ChannelMonitors into your local chain::Watch.
 /// 6) Disconnect/connect blocks on the ChannelManager.
-/// 7) Register the new ChannelManager with your ChainWatchInterface.
 #[must_use]
 #[repr(C)]
 pub struct ChannelManagerReadArgs {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelManagerReadArgs,
        pub is_owned: bool,
@@ -769,24 +763,24 @@ pub extern "C" fn ChannelManagerReadArgs_get_fee_estimator(this_ptr: &ChannelMan
 pub extern "C" fn ChannelManagerReadArgs_set_fee_estimator(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::chain::chaininterface::FeeEstimator) {
        unsafe { &mut *this_ptr.inner }.fee_estimator = val;
 }
-/// The ManyChannelMonitor for use in the ChannelManager in the future.
+/// The chain::Watch for use in the ChannelManager in the future.
 ///
-/// No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+/// No calls to the chain::Watch will be made during deserialization. It is assumed that
 /// you have deserialized ChannelMonitors separately and will add them to your
-/// ManyChannelMonitor after deserializing this ChannelManager.
+/// chain::Watch after deserializing this ChannelManager.
 #[no_mangle]
-pub extern "C" fn ChannelManagerReadArgs_get_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::ln::channelmonitor::ManyChannelMonitor {
-       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.monitor;
+pub extern "C" fn ChannelManagerReadArgs_get_chain_monitor(this_ptr: &ChannelManagerReadArgs) -> *const crate::chain::Watch {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.chain_monitor;
        &(*inner_val)
 }
-/// The ManyChannelMonitor for use in the ChannelManager in the future.
+/// The chain::Watch for use in the ChannelManager in the future.
 ///
-/// No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
+/// No calls to the chain::Watch will be made during deserialization. It is assumed that
 /// you have deserialized ChannelMonitors separately and will add them to your
-/// ManyChannelMonitor after deserializing this ChannelManager.
+/// chain::Watch after deserializing this ChannelManager.
 #[no_mangle]
-pub extern "C" fn ChannelManagerReadArgs_set_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::ln::channelmonitor::ManyChannelMonitor) {
-       unsafe { &mut *this_ptr.inner }.monitor = val;
+pub extern "C" fn ChannelManagerReadArgs_set_chain_monitor(this_ptr: &mut ChannelManagerReadArgs, mut val: crate::chain::Watch) {
+       unsafe { &mut *this_ptr.inner }.chain_monitor = val;
 }
 /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
 /// used to broadcast the latest local commitment transactions of channels which must be
@@ -834,9 +828,9 @@ pub extern "C" fn ChannelManagerReadArgs_set_default_config(this_ptr: &mut Chann
 /// populate a HashMap directly from C.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn ChannelManagerReadArgs_new(mut keys_manager: crate::chain::keysinterface::KeysInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut monitor: crate::ln::channelmonitor::ManyChannelMonitor, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut default_config: crate::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> ChannelManagerReadArgs {
+pub extern "C" fn ChannelManagerReadArgs_new(mut keys_manager: crate::chain::keysinterface::KeysInterface, mut fee_estimator: crate::chain::chaininterface::FeeEstimator, mut chain_monitor: crate::chain::Watch, mut tx_broadcaster: crate::chain::chaininterface::BroadcasterInterface, mut logger: crate::util::logger::Logger, mut default_config: crate::util::config::UserConfig, mut channel_monitors: crate::c_types::derived::CVec_ChannelMonitorZ) -> ChannelManagerReadArgs {
        let mut local_channel_monitors = Vec::new(); for mut item in channel_monitors.into_rust().drain(..) { local_channel_monitors.push( { unsafe { &mut *item.inner } }); };
-       let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(keys_manager, fee_estimator, monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_ptr()) }, local_channel_monitors);
+       let mut ret = lightning::ln::channelmanager::ChannelManagerReadArgs::new(keys_manager, fee_estimator, chain_monitor, tx_broadcaster, logger, *unsafe { Box::from_raw(default_config.take_ptr()) }, local_channel_monitors);
        ChannelManagerReadArgs { inner: Box::into_raw(Box::new(ret)), is_owned: true }
 }
 
diff --git a/lightning-c-bindings/src/ln/channelmonitor.rs b/lightning-c-bindings/src/ln/channelmonitor.rs
deleted file mode 100644 (file)
index 671566a..0000000
+++ /dev/null
@@ -1,563 +0,0 @@
-//! The logic to monitor for on-chain transactions and create the relevant claim responses lives
-//! here.
-//!
-//! ChannelMonitor objects are generated by ChannelManager in response to relevant
-//! messages/actions, and MUST be persisted to disk (and, preferably, remotely) before progress can
-//! be made in responding to certain messages, see ManyChannelMonitor for more.
-//!
-//! Note that ChannelMonitors are an important part of the lightning trust model and a copy of the
-//! latest ChannelMonitor must always be actively monitoring for chain updates (and no out-of-date
-//! ChannelMonitors should do so). Thus, if you're building rust-lightning into an HSM or other
-//! security-domain-separated system design, you should consider having multiple paths for
-//! ChannelMonitors to get out of the HSM and onto monitoring devices.
-
-use std::ffi::c_void;
-use bitcoin::hashes::Hash;
-use crate::c_types::*;
-
-
-use lightning::ln::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
-type nativeChannelMonitorUpdate = nativeChannelMonitorUpdateImport;
-
-/// An update generated by the underlying Channel itself which contains some new information the
-/// ChannelMonitor should be made aware of.
-#[must_use]
-#[repr(C)]
-pub struct ChannelMonitorUpdate {
-       /// Nearly everyhwere, 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 nativeChannelMonitorUpdate,
-       pub is_owned: bool,
-}
-
-impl Drop for ChannelMonitorUpdate {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn ChannelMonitorUpdate_free(this_ptr: ChannelMonitorUpdate) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelMonitorUpdate_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitorUpdate); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl ChannelMonitorUpdate {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitorUpdate {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-impl Clone for ChannelMonitorUpdate {
-       fn clone(&self) -> Self {
-               Self {
-                       inner: Box::into_raw(Box::new(unsafe { &*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 ChannelMonitorUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelMonitorUpdate)).clone() })) as *mut c_void
-}
-/// The sequence number of this update. Updates *must* be replayed in-order according to this
-/// sequence number (and updates may panic if they are not). The update_id values are strictly
-/// increasing and increase by one for each new update.
-///
-/// This sequence number is also used to track up to which points updates which returned
-/// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
-/// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
-#[no_mangle]
-pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUpdate) -> u64 {
-       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.update_id;
-       (*inner_val)
-}
-/// The sequence number of this update. Updates *must* be replayed in-order according to this
-/// sequence number (and updates may panic if they are not). The update_id values are strictly
-/// increasing and increase by one for each new update.
-///
-/// This sequence number is also used to track up to which points updates which returned
-/// ChannelMonitorUpdateErr::TemporaryFailure have been applied to all copies of a given
-/// ChannelMonitor when ChannelManager::channel_monitor_updated is called.
-#[no_mangle]
-pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) {
-       unsafe { &mut *this_ptr.inner }.update_id = val;
-}
-#[no_mangle]
-pub extern "C" fn ChannelMonitorUpdate_write(obj: *const ChannelMonitorUpdate) -> crate::c_types::derived::CVec_u8Z {
-       crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
-}
-#[no_mangle]
-pub extern "C" fn ChannelMonitorUpdate_read(ser: crate::c_types::u8slice) -> ChannelMonitorUpdate {
-       if let Ok(res) = crate::c_types::deserialize_obj(ser) {
-               ChannelMonitorUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
-       } else {
-               ChannelMonitorUpdate { inner: std::ptr::null_mut(), is_owned: true }
-       }
-}
-/// An error enum representing a failure to persist a channel monitor update.
-#[must_use]
-#[derive(Clone)]
-#[repr(C)]
-pub enum ChannelMonitorUpdateErr {
-       /// Used to indicate a temporary failure (eg connection to a watchtower or remote backup of
-       /// our state failed, but is expected to succeed at some point in the future).
-       ///
-       /// Such a failure will \"freeze\" a channel, preventing us from revoking old states or
-       /// submitting new commitment transactions to the counterparty. Once the update(s) which failed
-       /// have been successfully applied, ChannelManager::channel_monitor_updated can be used to
-       /// restore the channel to an operational state.
-       ///
-       /// Note that a given ChannelManager will *never* re-generate a given ChannelMonitorUpdate. If
-       /// you return a TemporaryFailure you must ensure that it is written to disk safely before
-       /// writing out the latest ChannelManager state.
-       ///
-       /// Even when a channel has been \"frozen\" updates to the ChannelMonitor can continue to occur
-       /// (eg if an inbound HTLC which we forwarded was claimed upstream resulting in us attempting
-       /// to claim it on this channel) and those updates must be applied wherever they can be. At
-       /// least one such updated ChannelMonitor must be persisted otherwise PermanentFailure should
-       /// be returned to get things on-chain ASAP using only the in-memory copy. Obviously updates to
-       /// the channel which would invalidate previous ChannelMonitors are not made when a channel has
-       /// been \"frozen\".
-       ///
-       /// Note that even if updates made after TemporaryFailure succeed you must still call
-       /// channel_monitor_updated to ensure you have the latest monitor and re-enable normal channel
-       /// operation.
-       ///
-       /// Note that the update being processed here will not be replayed for you when you call
-       /// ChannelManager::channel_monitor_updated, so you must store the update itself along
-       /// with the persisted ChannelMonitor on your own local disk prior to returning a
-       /// TemporaryFailure. You may, of course, employ a journaling approach, storing only the
-       /// ChannelMonitorUpdate on disk without updating the monitor itself, replaying the journal at
-       /// reload-time.
-       ///
-       /// For deployments where a copy of ChannelMonitors and other local state are backed up in a
-       /// remote location (with local copies persisted immediately), it is anticipated that all
-       /// updates will return TemporaryFailure until the remote copies could be updated.
-       TemporaryFailure,
-       /// Used to indicate no further channel monitor updates will be allowed (eg we've moved on to a
-       /// different watchtower and cannot update with all watchtowers that were previously informed
-       /// of this channel).
-       ///
-       /// At reception of this error, ChannelManager will force-close the channel and return at
-       /// least a final ChannelMonitorUpdate::ChannelForceClosed which must be delivered to at
-       /// least one ChannelMonitor copy. Revocation secret MUST NOT be released and offchain channel
-       /// update must be rejected.
-       ///
-       /// This failure may also signal a failure to update the local persisted copy of one of
-       /// the channel monitor instance.
-       ///
-       /// Note that even when you fail a holder commitment transaction update, you must store the
-       /// update to ensure you can claim from it in case of a duplicate copy of this ChannelMonitor
-       /// broadcasts it (e.g distributed channel-monitor deployment)
-       PermanentFailure,
-}
-use lightning::ln::channelmonitor::ChannelMonitorUpdateErr as nativeChannelMonitorUpdateErr;
-impl ChannelMonitorUpdateErr {
-       #[allow(unused)]
-       pub(crate) fn to_native(&self) -> nativeChannelMonitorUpdateErr {
-               match self {
-                       ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
-                       ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn into_native(self) -> nativeChannelMonitorUpdateErr {
-               match self {
-                       ChannelMonitorUpdateErr::TemporaryFailure => nativeChannelMonitorUpdateErr::TemporaryFailure,
-                       ChannelMonitorUpdateErr::PermanentFailure => nativeChannelMonitorUpdateErr::PermanentFailure,
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn from_native(native: &nativeChannelMonitorUpdateErr) -> Self {
-               match native {
-                       nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
-                       nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
-               }
-       }
-       #[allow(unused)]
-       pub(crate) fn native_into(native: nativeChannelMonitorUpdateErr) -> Self {
-               match native {
-                       nativeChannelMonitorUpdateErr::TemporaryFailure => ChannelMonitorUpdateErr::TemporaryFailure,
-                       nativeChannelMonitorUpdateErr::PermanentFailure => ChannelMonitorUpdateErr::PermanentFailure,
-               }
-       }
-}
-
-use lightning::ln::channelmonitor::MonitorUpdateError as nativeMonitorUpdateErrorImport;
-type nativeMonitorUpdateError = nativeMonitorUpdateErrorImport;
-
-/// General Err type for ChannelMonitor actions. Generally, this implies that the data provided is
-/// inconsistent with the ChannelMonitor being called. eg for ChannelMonitor::update_monitor this
-/// means you tried to update a monitor for a different channel or the ChannelMonitorUpdate was
-/// corrupted.
-/// Contains a human-readable error message.
-#[must_use]
-#[repr(C)]
-pub struct MonitorUpdateError {
-       /// Nearly everyhwere, 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 nativeMonitorUpdateError,
-       pub is_owned: bool,
-}
-
-impl Drop for MonitorUpdateError {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn MonitorUpdateError_free(this_ptr: MonitorUpdateError) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn MonitorUpdateError_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorUpdateError); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl MonitorUpdateError {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorUpdateError {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-
-use lightning::ln::channelmonitor::MonitorEvent as nativeMonitorEventImport;
-type nativeMonitorEvent = nativeMonitorEventImport;
-
-/// An event to be processed by the ChannelManager.
-#[must_use]
-#[repr(C)]
-pub struct MonitorEvent {
-       /// Nearly everyhwere, 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 nativeMonitorEvent,
-       pub is_owned: bool,
-}
-
-impl Drop for MonitorEvent {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn MonitorEvent_free(this_ptr: MonitorEvent) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn MonitorEvent_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeMonitorEvent); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl MonitorEvent {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeMonitorEvent {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-
-use lightning::ln::channelmonitor::HTLCUpdate as nativeHTLCUpdateImport;
-type nativeHTLCUpdate = nativeHTLCUpdateImport;
-
-/// Simple structure send back by ManyChannelMonitor in case of HTLC detected onchain from a
-/// forward channel and from which info are needed to update HTLC in a backward channel.
-#[must_use]
-#[repr(C)]
-pub struct HTLCUpdate {
-       /// Nearly everyhwere, 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 nativeHTLCUpdate,
-       pub is_owned: bool,
-}
-
-impl Drop for HTLCUpdate {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn HTLCUpdate_free(this_ptr: HTLCUpdate) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn HTLCUpdate_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeHTLCUpdate); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl HTLCUpdate {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeHTLCUpdate {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-impl Clone for HTLCUpdate {
-       fn clone(&self) -> Self {
-               Self {
-                       inner: Box::into_raw(Box::new(unsafe { &*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 HTLCUpdate_clone_void(this_ptr: *const c_void) -> *mut c_void {
-       Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeHTLCUpdate)).clone() })) as *mut c_void
-}
-#[no_mangle]
-pub extern "C" fn HTLCUpdate_write(obj: *const HTLCUpdate) -> crate::c_types::derived::CVec_u8Z {
-       crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
-}
-#[no_mangle]
-pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> HTLCUpdate {
-       if let Ok(res) = crate::c_types::deserialize_obj(ser) {
-               HTLCUpdate { inner: Box::into_raw(Box::new(res)), is_owned: true }
-       } else {
-               HTLCUpdate { inner: std::ptr::null_mut(), is_owned: true }
-       }
-}
-
-use lightning::ln::channelmonitor::ChannelMonitor as nativeChannelMonitorImport;
-type nativeChannelMonitor = nativeChannelMonitorImport<crate::chain::keysinterface::ChannelKeys>;
-
-/// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates
-/// on-chain transactions to ensure no loss of funds occurs.
-///
-/// You MUST ensure that no ChannelMonitors for a given channel anywhere contain out-of-date
-/// information and are actively monitoring the chain.
-///
-/// Pending Events or updated HTLCs which have not yet been read out by
-/// get_and_clear_pending_monitor_events or get_and_clear_pending_events are serialized to disk and
-/// reloaded at deserialize-time. Thus, you must ensure that, when handling events, all events
-/// gotten are fully handled before re-serializing the new state.
-#[must_use]
-#[repr(C)]
-pub struct ChannelMonitor {
-       /// Nearly everyhwere, 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 nativeChannelMonitor,
-       pub is_owned: bool,
-}
-
-impl Drop for ChannelMonitor {
-       fn drop(&mut self) {
-               if self.is_owned && !self.inner.is_null() {
-                       let _ = unsafe { Box::from_raw(self.inner) };
-               }
-       }
-}
-#[no_mangle]
-pub extern "C" fn ChannelMonitor_free(this_ptr: ChannelMonitor) { }
-#[allow(unused)]
-/// Used only if an object of this type is returned as a trait impl by a method
-extern "C" fn ChannelMonitor_free_void(this_ptr: *mut c_void) {
-       unsafe { let _ = Box::from_raw(this_ptr as *mut nativeChannelMonitor); }
-}
-#[allow(unused)]
-/// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy
-impl ChannelMonitor {
-       pub(crate) fn take_ptr(mut self) -> *mut nativeChannelMonitor {
-               assert!(self.is_owned);
-               let ret = self.inner;
-               self.inner = std::ptr::null_mut();
-               ret
-       }
-}
-/// Simple trait indicating ability to track a set of ChannelMonitors and multiplex events between
-/// them. Generally should be implemented by keeping a local SimpleManyChannelMonitor and passing
-/// events to it, while also taking any add/update_monitor events and passing them to some remote
-/// server(s).
-///
-/// In general, you must always have at least one local copy in memory, which must never fail to
-/// update (as it is responsible for broadcasting the latest state in case the channel is closed),
-/// and then persist it to various on-disk locations. If, for some reason, the in-memory copy fails
-/// to update (eg out-of-memory or some other condition), you must immediately shut down without
-/// taking any further action such as writing the current state to disk. This should likely be
-/// accomplished via panic!() or abort().
-///
-/// Note that any updates to a channel's monitor *must* be applied to each instance of the
-/// channel's monitor everywhere (including remote watchtowers) *before* this function returns. If
-/// an update occurs and a remote watchtower is left with old state, it may broadcast transactions
-/// which we have revoked, allowing our counterparty to claim all funds in the channel!
-///
-/// User needs to notify implementors of ManyChannelMonitor when a new block is connected or
-/// disconnected using their `block_connected` and `block_disconnected` methods. However, rather
-/// than calling these methods directly, the user should register implementors as listeners to the
-/// BlockNotifier and call the BlockNotifier's `block_(dis)connected` methods, which will notify
-/// all registered listeners in one go.
-#[repr(C)]
-pub struct ManyChannelMonitor {
-       pub this_arg: *mut c_void,
-       /// Adds a monitor for the given `funding_txo`.
-       ///
-       /// Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
-       /// any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
-       /// callbacks with the funding transaction, or any spends of it.
-       ///
-       /// Further, the implementer must also ensure that each output returned in
-       /// monitor.get_outputs_to_watch() is registered to ensure that the provided monitor learns about
-       /// any spends of any of the outputs.
-       ///
-       /// Any spends of outputs which should have been registered which aren't passed to
-       /// ChannelMonitors via block_connected may result in FUNDS LOSS.
-       #[must_use]
-       pub add_monitor: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::ln::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
-       /// Updates a monitor for the given `funding_txo`.
-       ///
-       /// Implementer must also ensure that the funding_txo txid *and* outpoint are registered with
-       /// any relevant ChainWatchInterfaces such that the provided monitor receives block_connected
-       /// callbacks with the funding transaction, or any spends of it.
-       ///
-       /// Further, the implementer must also ensure that each output returned in
-       /// monitor.get_watch_outputs() is registered to ensure that the provided monitor learns about
-       /// any spends of any of the outputs.
-       ///
-       /// Any spends of outputs which should have been registered which aren't passed to
-       /// ChannelMonitors via block_connected may result in FUNDS LOSS.
-       ///
-       /// In case of distributed watchtowers deployment, even if an Err is return, the new version
-       /// must be written to disk, as state may have been stored but rejected due to a block forcing
-       /// a commitment broadcast. This storage is used to claim outputs of rejected state confirmed
-       /// onchain by another watchtower, lagging behind on block processing.
-       #[must_use]
-       pub update_monitor: extern "C" fn (this_arg: *const c_void, funding_txo: crate::chain::transaction::OutPoint, monitor: crate::ln::channelmonitor::ChannelMonitorUpdate) -> crate::c_types::derived::CResult_NoneChannelMonitorUpdateErrZ,
-       /// Used by ChannelManager to get list of HTLC resolved onchain and which needed to be updated
-       /// with success or failure.
-       ///
-       /// You should probably just call through to
-       /// ChannelMonitor::get_and_clear_pending_monitor_events() for each ChannelMonitor and return
-       /// the full list.
-       #[must_use]
-       pub get_and_clear_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_MonitorEventZ,
-       pub free: Option<extern "C" fn(this_arg: *mut c_void)>,
-}
-unsafe impl Send for ManyChannelMonitor {}
-unsafe impl Sync for ManyChannelMonitor {}
-
-use lightning::ln::channelmonitor::ManyChannelMonitor as rustManyChannelMonitor;
-impl rustManyChannelMonitor for ManyChannelMonitor {
-       type Keys = crate::chain::keysinterface::ChannelKeys;
-       fn add_monitor(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::ln::channelmonitor::ChannelMonitor<Self::Keys>) -> Result<(), lightning::ln::channelmonitor::ChannelMonitorUpdateErr> {
-               let mut ret = (self.add_monitor)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::ln::channelmonitor::ChannelMonitor { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
-               let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
-               local_ret
-       }
-       fn update_monitor(&self, funding_txo: lightning::chain::transaction::OutPoint, monitor: lightning::ln::channelmonitor::ChannelMonitorUpdate) -> Result<(), lightning::ln::channelmonitor::ChannelMonitorUpdateErr> {
-               let mut ret = (self.update_monitor)(self.this_arg, crate::chain::transaction::OutPoint { inner: Box::into_raw(Box::new(funding_txo)), is_owned: true }, crate::ln::channelmonitor::ChannelMonitorUpdate { inner: Box::into_raw(Box::new(monitor)), is_owned: true });
-               let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(ret.contents.result.take_ptr()) })*/ }), false => Err( { (*unsafe { Box::from_raw(ret.contents.err.take_ptr()) }).into_native() })};
-               local_ret
-       }
-       fn get_and_clear_pending_monitor_events(&self) -> Vec<lightning::ln::channelmonitor::MonitorEvent> {
-               let mut ret = (self.get_and_clear_pending_monitor_events)(self.this_arg);
-               let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { *unsafe { Box::from_raw(item.take_ptr()) } }); };
-               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 ManyChannelMonitor {
-       type Target = Self;
-       fn deref(&self) -> &Self {
-               self
-       }
-}
-/// Calls the free function if one is set
-#[no_mangle]
-pub extern "C" fn ManyChannelMonitor_free(this_ptr: ManyChannelMonitor) { }
-impl Drop for ManyChannelMonitor {
-       fn drop(&mut self) {
-               if let Some(f) = self.free {
-                       f(self.this_arg);
-               }
-       }
-}
-/// Updates a ChannelMonitor on the basis of some new information provided by the Channel
-/// itself.
-///
-/// panics if the given update is not the next update by update_id.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChannelMonitor_update_monitor(this_arg: &mut ChannelMonitor, mut updates: crate::ln::channelmonitor::ChannelMonitorUpdate, broadcaster: &crate::chain::chaininterface::BroadcasterInterface, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CResult_NoneMonitorUpdateErrorZ {
-       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.update_monitor(*unsafe { Box::from_raw(updates.take_ptr()) }, broadcaster, logger);
-       let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { 0u8 /*o*/ }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::channelmonitor::MonitorUpdateError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
-       local_ret
-}
-
-/// Gets the update_id from the latest ChannelMonitorUpdate which was applied to this
-/// ChannelMonitor.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChannelMonitor_get_latest_update_id(this_arg: &ChannelMonitor) -> u64 {
-       let mut ret = unsafe { &*this_arg.inner }.get_latest_update_id();
-       ret
-}
-
-/// Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &ChannelMonitor) -> crate::c_types::derived::C2Tuple_OutPointScriptZ {
-       let mut ret = unsafe { &*this_arg.inner }.get_funding_txo();
-       let (ref orig_ret_0, ref orig_ret_1) = ret; let mut local_ret = (crate::chain::transaction::OutPoint { inner: unsafe { ( (&(*orig_ret_0) as *const _) as *mut _) }, is_owned: false }, orig_ret_1.clone().into_bytes().into()).into();
-       local_ret
-}
-
-/// Get the list of HTLCs who's status has been updated on chain. This should be called by
-/// ChannelManager via ManyChannelMonitor::get_and_clear_pending_monitor_events().
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_MonitorEventZ {
-       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_monitor_events();
-       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::ln::channelmonitor::MonitorEvent { inner: Box::into_raw(Box::new(item)), is_owned: true } }); };
-       local_ret.into()
-}
-
-/// Gets the list of pending events which were generated by previous actions, clearing the list
-/// in the process.
-///
-/// This is called by ManyChannelMonitor::get_and_clear_pending_events() and is equivalent to
-/// EventsProvider::get_and_clear_pending_events() except that it requires &mut self as we do
-/// no internal locking in ChannelMonitors.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChannelMonitor_get_and_clear_pending_events(this_arg: &mut ChannelMonitor) -> crate::c_types::derived::CVec_EventZ {
-       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_and_clear_pending_events();
-       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { crate::util::events::Event::native_into(item) }); };
-       local_ret.into()
-}
-
-/// Used by ChannelManager deserialization to broadcast the latest holder state if its copy of
-/// the Channel was out-of-date. You may use it to get a broadcastable holder toxic tx in case of
-/// fallen-behind, i.e when receiving a channel_reestablish with a proof that our counterparty side knows
-/// a higher revocation secret than the holder commitment number we are aware of. Broadcasting these
-/// transactions are UNSAFE, as they allow counterparty side to punish you. Nevertheless you may want to
-/// broadcast them if counterparty don't close channel with his higher commitment transaction after a
-/// substantial amount of time (a month or even a year) to get back funds. Best may be to contact
-/// out-of-band the other node operator to coordinate with him if option is available to you.
-/// In any-case, choice is up to the user.
-#[must_use]
-#[no_mangle]
-pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &mut ChannelMonitor, logger: &crate::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ {
-       let mut ret = unsafe { &mut (*(this_arg.inner as *mut nativeChannelMonitor)) }.get_latest_holder_commitment_txn(logger);
-       let mut local_ret = Vec::new(); for item in ret.drain(..) { local_ret.push( { let mut local_ret_0 = ::bitcoin::consensus::encode::serialize(&item); local_ret_0.into() }); };
-       local_ret.into()
-}
-
index 44d2d68dfd77ef9a4870b688cf90e42dd4838ced..6a6be28459a03a560c8efc311d0789bda9c9dd0a 100644 (file)
@@ -28,7 +28,7 @@ type nativeInitFeatures = nativeInitFeaturesImport;
 #[must_use]
 #[repr(C)]
 pub struct InitFeatures {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeInitFeatures,
        pub is_owned: bool,
@@ -66,7 +66,7 @@ type nativeNodeFeatures = nativeNodeFeaturesImport;
 #[must_use]
 #[repr(C)]
 pub struct NodeFeatures {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeNodeFeatures,
        pub is_owned: bool,
@@ -104,7 +104,7 @@ type nativeChannelFeatures = nativeChannelFeaturesImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelFeatures {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeChannelFeatures,
        pub is_owned: bool,
index 69f17a0b5f73d3933b0bfeebd77d1049b93ac1c4..b81204a4720322bbfbb39a3caef304ac555a8e68 100644 (file)
@@ -14,7 +14,6 @@ use bitcoin::hashes::Hash;
 use crate::c_types::*;
 
 pub mod channelmanager;
-pub mod channelmonitor;
 pub mod msgs;
 pub mod peer_handler;
 pub mod chan_utils;
index e3ca0944af41bacb79e24ce3cedf199ecb884fc9..6925139d69392335e62ca8176160cecc0f0a5995 100644 (file)
@@ -27,7 +27,7 @@ type nativeDecodeError = nativeDecodeErrorImport;
 #[must_use]
 #[repr(C)]
 pub struct DecodeError {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeDecodeError,
        pub is_owned: bool,
@@ -65,7 +65,7 @@ type nativeInit = nativeInitImport;
 #[must_use]
 #[repr(C)]
 pub struct Init {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeInit,
        pub is_owned: bool,
@@ -103,7 +103,7 @@ type nativeErrorMessage = nativeErrorMessageImport;
 #[must_use]
 #[repr(C)]
 pub struct ErrorMessage {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeErrorMessage,
        pub is_owned: bool,
@@ -190,7 +190,7 @@ type nativePing = nativePingImport;
 #[must_use]
 #[repr(C)]
 pub struct Ping {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativePing,
        pub is_owned: bool,
@@ -260,7 +260,7 @@ type nativePong = nativePongImport;
 #[must_use]
 #[repr(C)]
 pub struct Pong {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativePong,
        pub is_owned: bool,
@@ -318,7 +318,7 @@ type nativeOpenChannel = nativeOpenChannelImport;
 #[must_use]
 #[repr(C)]
 pub struct OpenChannel {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeOpenChannel,
        pub is_owned: bool,
@@ -567,7 +567,7 @@ type nativeAcceptChannel = nativeAcceptChannelImport;
 #[must_use]
 #[repr(C)]
 pub struct AcceptChannel {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeAcceptChannel,
        pub is_owned: bool,
@@ -772,7 +772,7 @@ type nativeFundingCreated = nativeFundingCreatedImport;
 #[must_use]
 #[repr(C)]
 pub struct FundingCreated {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeFundingCreated,
        pub is_owned: bool,
@@ -877,7 +877,7 @@ type nativeFundingSigned = nativeFundingSignedImport;
 #[must_use]
 #[repr(C)]
 pub struct FundingSigned {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeFundingSigned,
        pub is_owned: bool,
@@ -958,7 +958,7 @@ type nativeFundingLocked = nativeFundingLockedImport;
 #[must_use]
 #[repr(C)]
 pub struct FundingLocked {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeFundingLocked,
        pub is_owned: bool,
@@ -1039,7 +1039,7 @@ type nativeShutdown = nativeShutdownImport;
 #[must_use]
 #[repr(C)]
 pub struct Shutdown {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeShutdown,
        pub is_owned: bool,
@@ -1122,7 +1122,7 @@ type nativeClosingSigned = nativeClosingSignedImport;
 #[must_use]
 #[repr(C)]
 pub struct ClosingSigned {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeClosingSigned,
        pub is_owned: bool,
@@ -1215,7 +1215,7 @@ type nativeUpdateAddHTLC = nativeUpdateAddHTLCImport;
 #[must_use]
 #[repr(C)]
 pub struct UpdateAddHTLC {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUpdateAddHTLC,
        pub is_owned: bool,
@@ -1321,7 +1321,7 @@ type nativeUpdateFulfillHTLC = nativeUpdateFulfillHTLCImport;
 #[must_use]
 #[repr(C)]
 pub struct UpdateFulfillHTLC {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUpdateFulfillHTLC,
        pub is_owned: bool,
@@ -1414,7 +1414,7 @@ type nativeUpdateFailHTLC = nativeUpdateFailHTLCImport;
 #[must_use]
 #[repr(C)]
 pub struct UpdateFailHTLC {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUpdateFailHTLC,
        pub is_owned: bool,
@@ -1487,7 +1487,7 @@ type nativeUpdateFailMalformedHTLC = nativeUpdateFailMalformedHTLCImport;
 #[must_use]
 #[repr(C)]
 pub struct UpdateFailMalformedHTLC {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUpdateFailMalformedHTLC,
        pub is_owned: bool,
@@ -1571,7 +1571,7 @@ type nativeCommitmentSigned = nativeCommitmentSignedImport;
 #[must_use]
 #[repr(C)]
 pub struct CommitmentSigned {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeCommitmentSigned,
        pub is_owned: bool,
@@ -1660,7 +1660,7 @@ type nativeRevokeAndACK = nativeRevokeAndACKImport;
 #[must_use]
 #[repr(C)]
 pub struct RevokeAndACK {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeRevokeAndACK,
        pub is_owned: bool,
@@ -1753,7 +1753,7 @@ type nativeUpdateFee = nativeUpdateFeeImport;
 #[must_use]
 #[repr(C)]
 pub struct UpdateFee {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUpdateFee,
        pub is_owned: bool,
@@ -1837,7 +1837,7 @@ type nativeDataLossProtect = nativeDataLossProtectImport;
 #[must_use]
 #[repr(C)]
 pub struct DataLossProtect {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeDataLossProtect,
        pub is_owned: bool,
@@ -1920,7 +1920,7 @@ type nativeChannelReestablish = nativeChannelReestablishImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelReestablish {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelReestablish,
        pub is_owned: bool,
@@ -2004,7 +2004,7 @@ type nativeAnnouncementSignatures = nativeAnnouncementSignaturesImport;
 #[must_use]
 #[repr(C)]
 pub struct AnnouncementSignatures {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeAnnouncementSignatures,
        pub is_owned: bool,
@@ -2288,7 +2288,7 @@ type nativeUnsignedNodeAnnouncement = nativeUnsignedNodeAnnouncementImport;
 #[must_use]
 #[repr(C)]
 pub struct UnsignedNodeAnnouncement {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUnsignedNodeAnnouncement,
        pub is_owned: bool,
@@ -2331,6 +2331,17 @@ impl Clone for UnsignedNodeAnnouncement {
 pub(crate) extern "C" fn UnsignedNodeAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
        Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedNodeAnnouncement)).clone() })) as *mut c_void
 }
+/// The advertised features
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::ln::features::NodeFeatures {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
+       crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The advertised features
+#[no_mangle]
+pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::ln::features::NodeFeatures) {
+       unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) };
+}
 /// A strictly monotonic announcement counter, with gaps allowed
 #[no_mangle]
 pub extern "C" fn UnsignedNodeAnnouncement_get_timestamp(this_ptr: &UnsignedNodeAnnouncement) -> u32 {
@@ -2393,7 +2404,7 @@ type nativeNodeAnnouncement = nativeNodeAnnouncementImport;
 #[must_use]
 #[repr(C)]
 pub struct NodeAnnouncement {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeNodeAnnouncement,
        pub is_owned: bool,
@@ -2474,7 +2485,7 @@ type nativeUnsignedChannelAnnouncement = nativeUnsignedChannelAnnouncementImport
 #[must_use]
 #[repr(C)]
 pub struct UnsignedChannelAnnouncement {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUnsignedChannelAnnouncement,
        pub is_owned: bool,
@@ -2517,6 +2528,17 @@ impl Clone for UnsignedChannelAnnouncement {
 pub(crate) extern "C" fn UnsignedChannelAnnouncement_clone_void(this_ptr: *const c_void) -> *mut c_void {
        Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeUnsignedChannelAnnouncement)).clone() })) as *mut c_void
 }
+/// The advertised channel features
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::ln::features::ChannelFeatures {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
+       crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The advertised channel features
+#[no_mangle]
+pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::ln::features::ChannelFeatures) {
+       unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) };
+}
 /// The genesis hash of the blockchain where the channel is to be opened
 #[no_mangle]
 pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &UnsignedChannelAnnouncement) -> *const [u8; 32] {
@@ -2591,7 +2613,7 @@ type nativeChannelAnnouncement = nativeChannelAnnouncementImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelAnnouncement {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelAnnouncement,
        pub is_owned: bool,
@@ -2708,7 +2730,7 @@ type nativeUnsignedChannelUpdate = nativeUnsignedChannelUpdateImport;
 #[must_use]
 #[repr(C)]
 pub struct UnsignedChannelUpdate {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUnsignedChannelUpdate,
        pub is_owned: bool,
@@ -2847,7 +2869,7 @@ type nativeChannelUpdate = nativeChannelUpdateImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelUpdate {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelUpdate,
        pub is_owned: bool,
@@ -2931,7 +2953,7 @@ type nativeQueryChannelRange = nativeQueryChannelRangeImport;
 #[must_use]
 #[repr(C)]
 pub struct QueryChannelRange {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeQueryChannelRange,
        pub is_owned: bool,
@@ -3030,7 +3052,7 @@ type nativeReplyChannelRange = nativeReplyChannelRangeImport;
 #[must_use]
 #[repr(C)]
 pub struct ReplyChannelRange {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeReplyChannelRange,
        pub is_owned: bool,
@@ -3152,7 +3174,7 @@ type nativeQueryShortChannelIds = nativeQueryShortChannelIdsImport;
 #[must_use]
 #[repr(C)]
 pub struct QueryShortChannelIds {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeQueryShortChannelIds,
        pub is_owned: bool,
@@ -3232,7 +3254,7 @@ type nativeReplyShortChannelIdsEnd = nativeReplyShortChannelIdsEndImport;
 #[must_use]
 #[repr(C)]
 pub struct ReplyShortChannelIdsEnd {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeReplyShortChannelIdsEnd,
        pub is_owned: bool,
@@ -3317,7 +3339,7 @@ type nativeGossipTimestampFilter = nativeGossipTimestampFilterImport;
 #[must_use]
 #[repr(C)]
 pub struct GossipTimestampFilter {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeGossipTimestampFilter,
        pub is_owned: bool,
@@ -3503,7 +3525,7 @@ type nativeLightningError = nativeLightningErrorImport;
 #[must_use]
 #[repr(C)]
 pub struct LightningError {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeLightningError,
        pub is_owned: bool,
@@ -3572,7 +3594,7 @@ type nativeCommitmentUpdate = nativeCommitmentUpdateImport;
 #[must_use]
 #[repr(C)]
 pub struct CommitmentUpdate {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeCommitmentUpdate,
        pub is_owned: bool,
index a763db63e4c95d28bbe96d78e6644cf1dee470ec..e4c8b59b1b45a78018335434b07ca609fe574cf0 100644 (file)
@@ -18,7 +18,7 @@ type nativeMessageHandler = nativeMessageHandlerImport<crate::ln::msgs::ChannelM
 #[must_use]
 #[repr(C)]
 pub struct MessageHandler {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeMessageHandler,
        pub is_owned: bool,
@@ -186,7 +186,7 @@ type nativePeerHandleError = nativePeerHandleErrorImport;
 #[must_use]
 #[repr(C)]
 pub struct PeerHandleError {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativePeerHandleError,
        pub is_owned: bool,
@@ -251,7 +251,7 @@ type nativePeerManager = nativePeerManagerImport<crate::ln::peer_handler::Socket
 #[must_use]
 #[repr(C)]
 pub struct PeerManager {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativePeerManager,
        pub is_owned: bool,
index 89f20fd4889487224864a0846ce22b2a70e0e6c0..c2930f0f335a12ff575b854e1fd104c5e59df6aa 100644 (file)
@@ -12,7 +12,7 @@ type nativeNetworkGraph = nativeNetworkGraphImport;
 #[must_use]
 #[repr(C)]
 pub struct NetworkGraph {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeNetworkGraph,
        pub is_owned: bool,
@@ -52,7 +52,7 @@ type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>;
 #[must_use]
 #[repr(C)]
 pub struct LockedNetworkGraph {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 is_owned: bool,
@@ -84,7 +84,7 @@ impl LockedNetworkGraph {
 }
 
 use lightning::routing::network_graph::NetGraphMsgHandler as nativeNetGraphMsgHandlerImport;
-type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::chain::chaininterface::ChainWatchInterface, crate::util::logger::Logger>;
+type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::chain::Access, crate::util::logger::Logger>;
 
 /// Receives and validates network updates from peers,
 /// stores authentic and relevant data as a network graph.
@@ -94,7 +94,7 @@ type nativeNetGraphMsgHandler = nativeNetGraphMsgHandlerImport<crate::chain::cha
 #[must_use]
 #[repr(C)]
 pub struct NetGraphMsgHandler {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeNetGraphMsgHandler,
        pub is_owned: bool,
@@ -131,8 +131,9 @@ impl NetGraphMsgHandler {
 /// channel owners' keys.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_new(mut chain_monitor: crate::chain::chaininterface::ChainWatchInterface, mut logger: crate::util::logger::Logger) -> NetGraphMsgHandler {
-       let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::new(chain_monitor, logger);
+pub extern "C" fn NetGraphMsgHandler_new(chain_access: *mut crate::chain::Access, mut logger: crate::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(local_chain_access, logger);
        NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
 }
 
@@ -140,8 +141,9 @@ pub extern "C" fn NetGraphMsgHandler_new(mut chain_monitor: crate::chain::chaini
 /// assuming an existing Network Graph.
 #[must_use]
 #[no_mangle]
-pub extern "C" fn NetGraphMsgHandler_from_net_graph(mut chain_monitor: crate::chain::chaininterface::ChainWatchInterface, mut logger: crate::util::logger::Logger, mut network_graph: crate::routing::network_graph::NetworkGraph) -> NetGraphMsgHandler {
-       let mut ret = lightning::routing::network_graph::NetGraphMsgHandler::from_net_graph(chain_monitor, logger, *unsafe { Box::from_raw(network_graph.take_ptr()) });
+pub extern "C" fn NetGraphMsgHandler_from_net_graph(chain_access: *mut crate::chain::Access, mut logger: crate::util::logger::Logger, mut network_graph: crate::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_ptr()) });
        NetGraphMsgHandler { inner: Box::into_raw(Box::new(ret)), is_owned: true }
 }
 
@@ -214,7 +216,7 @@ extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_node_announcemen
        local_ret.into()
 }
 #[must_use]
-extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_should_request_full_sync(this_arg: *const c_void, _node_id: crate::c_types::PublicKey) -> bool {
+extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_should_request_full_sync(this_arg: *const c_void, mut _node_id: crate::c_types::PublicKey) -> bool {
        let mut ret = unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }.should_request_full_sync(&_node_id.into_rust());
        ret
 }
@@ -228,7 +230,7 @@ type nativeDirectionalChannelInfo = nativeDirectionalChannelInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct DirectionalChannelInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeDirectionalChannelInfo,
        pub is_owned: bool,
@@ -344,7 +346,7 @@ type nativeChannelInfo = nativeChannelInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelInfo,
        pub is_owned: bool,
@@ -374,6 +376,17 @@ impl ChannelInfo {
                ret
        }
 }
+/// Protocol features of a channel communicated during its announcement
+#[no_mangle]
+pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::ln::features::ChannelFeatures {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
+       crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Protocol features of a channel communicated during its announcement
+#[no_mangle]
+pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::ln::features::ChannelFeatures) {
+       unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) };
+}
 /// Source node of the first direction of a channel
 #[no_mangle]
 pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::c_types::PublicKey {
@@ -461,7 +474,7 @@ type nativeRoutingFees = nativeRoutingFeesImport;
 #[must_use]
 #[repr(C)]
 pub struct RoutingFees {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeRoutingFees,
        pub is_owned: bool,
@@ -556,7 +569,7 @@ type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct NodeAnnouncementInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeNodeAnnouncementInfo,
        pub is_owned: bool,
@@ -586,6 +599,17 @@ impl NodeAnnouncementInfo {
                ret
        }
 }
+/// Protocol features the node announced support for
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::ln::features::NodeFeatures {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.features;
+       crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// Protocol features the node announced support for
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::ln::features::NodeFeatures) {
+       unsafe { &mut *this_ptr.inner }.features = *unsafe { Box::from_raw(val.take_ptr()) };
+}
 /// When the last known update to the node state was issued.
 /// Value is opaque, as set in the announcement.
 #[no_mangle]
@@ -650,6 +674,20 @@ pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut N
        let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_ptr()) } }) };
        unsafe { &mut *this_ptr.inner }.announcement_message = local_val;
 }
+#[must_use]
+#[no_mangle]
+pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::c_types::ThirtyTwoBytes, mut addresses_arg: crate::c_types::derived::CVec_NetAddressZ, mut announcement_message_arg: crate::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo {
+       let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); };
+       let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_ptr()) } }) };
+       NodeAnnouncementInfo { inner: Box::into_raw(Box::new(nativeNodeAnnouncementInfo {
+               features: *unsafe { Box::from_raw(features_arg.take_ptr()) },
+               last_update: last_update_arg,
+               rgb: rgb_arg.data,
+               alias: alias_arg.data,
+               addresses: local_addresses_arg,
+               announcement_message: local_announcement_message_arg,
+       })), is_owned: true }
+}
 #[no_mangle]
 pub extern "C" fn NodeAnnouncementInfo_write(obj: *const NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z {
        crate::c_types::serialize_obj(unsafe { &(*(*obj).inner) })
@@ -670,7 +708,7 @@ type nativeNodeInfo = nativeNodeInfoImport;
 #[must_use]
 #[repr(C)]
 pub struct NodeInfo {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeNodeInfo,
        pub is_owned: bool,
index 978c24b419808987a30fb807ea68818d40826317..2195fe47daa17e7aac00620535e30c98232fb9f5 100644 (file)
@@ -15,7 +15,7 @@ type nativeRouteHop = nativeRouteHopImport;
 #[must_use]
 #[repr(C)]
 pub struct RouteHop {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeRouteHop,
        pub is_owned: bool,
@@ -69,6 +69,19 @@ pub extern "C" fn RouteHop_get_pubkey(this_ptr: &RouteHop) -> crate::c_types::Pu
 pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c_types::PublicKey) {
        unsafe { &mut *this_ptr.inner }.pubkey = val.into_rust();
 }
+/// The node_announcement features of the node at this hop. For the last hop, these may be
+/// amended to match the features present in the invoice this node generated.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::ln::features::NodeFeatures {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.node_features;
+       crate::ln::features::NodeFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The node_announcement features of the node at this hop. For the last hop, these may be
+/// amended to match the features present in the invoice this node generated.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::ln::features::NodeFeatures) {
+       unsafe { &mut *this_ptr.inner }.node_features = *unsafe { Box::from_raw(val.take_ptr()) };
+}
 /// The channel that should be used from the previous hop to reach this node.
 #[no_mangle]
 pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 {
@@ -80,6 +93,19 @@ pub extern "C" fn RouteHop_get_short_channel_id(this_ptr: &RouteHop) -> u64 {
 pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val: u64) {
        unsafe { &mut *this_ptr.inner }.short_channel_id = val;
 }
+/// The channel_announcement features of the channel that should be used from the previous hop
+/// to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::ln::features::ChannelFeatures {
+       let mut inner_val = &mut unsafe { &mut *this_ptr.inner }.channel_features;
+       crate::ln::features::ChannelFeatures { inner: unsafe { ( (&((*inner_val)) as *const _) as *mut _) }, is_owned: false }
+}
+/// The channel_announcement features of the channel that should be used from the previous hop
+/// to reach this node.
+#[no_mangle]
+pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::ln::features::ChannelFeatures) {
+       unsafe { &mut *this_ptr.inner }.channel_features = *unsafe { Box::from_raw(val.take_ptr()) };
+}
 /// The fee taken on this hop. For the last hop, this should be the full value of the payment.
 #[no_mangle]
 pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 {
@@ -104,6 +130,18 @@ pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 {
 pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) {
        unsafe { &mut *this_ptr.inner }.cltv_expiry_delta = val;
 }
+#[must_use]
+#[no_mangle]
+pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32) -> RouteHop {
+       RouteHop { inner: Box::into_raw(Box::new(nativeRouteHop {
+               pubkey: pubkey_arg.into_rust(),
+               node_features: *unsafe { Box::from_raw(node_features_arg.take_ptr()) },
+               short_channel_id: short_channel_id_arg,
+               channel_features: *unsafe { Box::from_raw(channel_features_arg.take_ptr()) },
+               fee_msat: fee_msat_arg,
+               cltv_expiry_delta: cltv_expiry_delta_arg,
+       })), is_owned: true }
+}
 
 use lightning::routing::router::Route as nativeRouteImport;
 type nativeRoute = nativeRouteImport;
@@ -113,7 +151,7 @@ type nativeRoute = nativeRouteImport;
 #[must_use]
 #[repr(C)]
 pub struct Route {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeRoute,
        pub is_owned: bool,
@@ -195,7 +233,7 @@ type nativeRouteHint = nativeRouteHintImport;
 #[must_use]
 #[repr(C)]
 pub struct RouteHint {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// Nearly everywhere, inner must be non-null, however in places where
        /// the Rust equivalent takes an Option, it may be set to null to indicate None.
        pub inner: *mut nativeRouteHint,
        pub is_owned: bool,
@@ -308,8 +346,8 @@ pub extern "C" fn RouteHint_new(mut src_node_id_arg: crate::c_types::PublicKey,
 /// equal), however the enabled/disabled bit on such channels as well as the htlc_minimum_msat
 /// *is* checked as they may change based on the receiving node.
 #[no_mangle]
-pub extern "C" fn get_route(our_node_id: crate::c_types::PublicKey, network: &crate::routing::network_graph::NetworkGraph, target: crate::c_types::PublicKey, mut first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut last_hops: crate::c_types::derived::CVec_RouteHintZ, mut final_value_msat: u64, mut final_cltv: u32, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
-       let mut local_first_hops_base = if first_hops.is_null() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { unsafe { &*item.inner } }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
+pub extern "C" fn get_route(mut our_node_id: crate::c_types::PublicKey, network: &crate::routing::network_graph::NetworkGraph, mut target: crate::c_types::PublicKey, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut last_hops: crate::c_types::derived::CVec_RouteHintZ, mut final_value_msat: u64, mut final_cltv: u32, mut logger: crate::util::logger::Logger) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
+       let mut local_first_hops_base = if first_hops == std::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { unsafe { &*item.inner } }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
        let mut local_last_hops = Vec::new(); for mut item in last_hops.as_slice().iter() { local_last_hops.push( { unsafe { &*item.inner } }); };
        let mut ret = lightning::routing::router::get_route(&our_node_id.into_rust(), unsafe { &*network.inner }, &target.into_rust(), local_first_hops, &local_last_hops[..], final_value_msat, final_cltv, logger);
        let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::routing::router::Route { inner: Box::into_raw(Box::new(o)), is_owned: true } }), Err(mut e) => crate::c_types::CResultTempl::err( { crate::ln::msgs::LightningError { inner: Box::into_raw(Box::new(e)), is_owned: true } }) };
index 53a7d940248953725d128faf78a901551a46fab3..30a42708f705f7b65a865da9f298c3c97ab8961b 100644 (file)
@@ -15,7 +15,7 @@ type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelHandshakeConfig {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelHandshakeConfig,
        pub is_owned: bool,
@@ -165,7 +165,7 @@ type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelHandshakeLimits {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelHandshakeLimits,
        pub is_owned: bool,
@@ -434,7 +434,7 @@ type nativeChannelConfig = nativeChannelConfigImport;
 #[must_use]
 #[repr(C)]
 pub struct ChannelConfig {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeChannelConfig,
        pub is_owned: bool,
@@ -595,7 +595,7 @@ type nativeUserConfig = nativeUserConfigImport;
 #[must_use]
 #[repr(C)]
 pub struct UserConfig {
-       /// Nearly everyhwere, inner must be non-null, however in places where
+       /// 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 nativeUserConfig,
        pub is_owned: bool,
index 0ed0cf296683cb64c521427d25ac3854e44ac63d..06cb4a7f879ab6318fc9aad25bf2244dfffefdbf 100644 (file)
@@ -33,7 +33,7 @@ pub enum APIError {
        ChannelUnavailable {
                err: crate::c_types::derived::CVec_u8Z,
        },
-       /// An attempt to call add/update_monitor returned an Err (ie you did this!), causing the
+       /// An attempt to call watch/update_channel returned an Err (ie you did this!), causing the
        /// attempted action to fail.
        MonitorUpdateFailed,
 }
index f7ddedef3a3e99b45f3fe8d35399fdce49b6c976..af3fbea44f84856d4d7b4aada676db3a52513f96 100644 (file)
@@ -23,17 +23,6 @@ pub mod channelmonitor;
 pub mod transaction;
 pub mod keysinterface;
 
-/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and
-/// UTXOs.
-pub trait Access: Send + Sync {
-       /// 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
-       fn get_utxo(&self, genesis_hash: &BlockHash, short_channel_id: u64) -> Result<TxOut, AccessError>;
-}
-
 /// An error when accessing the chain via [`Access`].
 ///
 /// [`Access`]: trait.Access.html
@@ -46,6 +35,17 @@ pub enum AccessError {
        UnknownTx,
 }
 
+/// The `Access` trait defines behavior for accessing chain data and state, such as blocks and
+/// UTXOs.
+pub trait Access: Send + Sync {
+       /// 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
+       fn get_utxo(&self, genesis_hash: &BlockHash, short_channel_id: u64) -> Result<TxOut, AccessError>;
+}
+
 /// The `Watch` trait defines behavior for watching on-chain activity pertaining to channels as
 /// blocks are connected and disconnected.
 ///