Handle the somewhat half-mapped alias TransactionOutputs
[ldk-java] / genbindings.py
index 1a0f7dd198e0808364f6224c5e4eeb7bd1cb7f72..ab5b0cbf183a1372a250bd47f65de85200243aff 100755 (executable)
@@ -101,6 +101,11 @@ def java_c_types(fn_arg, ret_arr_len):
         assert var_is_arr_regex.match(fn_arg[8:])
         rust_obj = "LDKThirtyTwoBytes"
         arr_access = "data"
+    elif fn_arg.startswith("LDKTxid"):
+        fn_arg = "uint8_t (*" + fn_arg[8:] + ")[32]"
+        assert var_is_arr_regex.match(fn_arg[8:])
+        rust_obj = "LDKThirtyTwoBytes"
+        arr_access = "data"
     elif fn_arg.startswith("LDKPublicKey"):
         fn_arg = "uint8_t (*" + fn_arg[13:] + ")[33]"
         assert var_is_arr_regex.match(fn_arg[8:])
@@ -146,7 +151,7 @@ def java_c_types(fn_arg, ret_arr_len):
         rust_obj = "LDKCVec_u8Z"
         assert var_is_arr_regex.match(fn_arg[8:])
         arr_access = "data"
-    elif fn_arg.startswith("LDKTransaction"):
+    elif fn_arg.startswith("LDKTransaction ") or fn_arg == "LDKTransaction":
         fn_arg = "uint8_t (*" + fn_arg[15:] + ")[datalen]"
         rust_obj = "LDKTransaction"
         assert var_is_arr_regex.match(fn_arg[8:])
@@ -440,9 +445,11 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java:
             write_c(out_c_delta)
 
         out_java_struct = None
-        if ("LDK" + struct_meth in opaque_structs or "LDK" + struct_meth in trait_structs
-                or "LDK" + struct_meth in complex_enums or "LDKC" + struct_meth in complex_enums
-                or "LDKC" + struct_meth in result_types) and not is_free:
+        expected_struct = "LDK" + struct_meth
+        expected_cstruct = "LDKC" + struct_meth
+        if (expected_struct in opaque_structs or expected_struct in trait_structs
+                or expected_struct in complex_enums or expected_cstruct in complex_enums
+                or expected_cstruct in result_types) and not is_free:
             out_java_struct = open(f"{sys.argv[3]}/structs/{struct_meth}{consts.file_ext}", "a")
         elif method_name.startswith("C2Tuple_") and method_name.endswith("_read"):
             struct_meth = method_name.rsplit("_", 1)[0]