+ elif struct_name == "LDKTxIn":
+ with open(f"{sys.argv[3]}/structs/TxIn{consts.file_ext}", "w") as out_java_struct:
+ out_java_struct.write(consts.hu_struct_file_prefix)
+ out_java_struct.write(consts.txin_defn)
+ out_java_struct.write(consts.hu_struct_file_suffix)
+ fn_line = "struct LDKWitness TxIn_get_witness (struct LDKTxIn* thing)"
+ write_c(fn_line + " {")
+ write_c("\treturn Witness_clone(&thing->witness);")
+ write_c("}")
+ map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_witness) \((.*)\)").match(fn_line), None, None, None)
+ fn_line = "struct LDKCVec_u8Z TxIn_get_script_sig (struct LDKTxIn* thing)"
+ write_c(fn_line + " {")
+ write_c("\treturn CVec_u8Z_clone(&thing->script_sig);")
+ write_c("}")
+ map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_script_sig) \((.*)\)").match(fn_line), None, None, None)
+ fn_line = "LDKThirtyTwoBytes TxIn_get_previous_txid (struct LDKTxIn* thing)"
+ write_c(fn_line + " {")
+ write_c("\treturn thing->previous_txid;")
+ write_c("}")
+ map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_previous_txid) \((.*)\)").match(fn_line), None, None, None)
+ fn_line = "uint32_t TxIn_get_previous_vout (struct LDKTxIn* thing)"
+ write_c(fn_line + " {")
+ write_c("\treturn thing->previous_vout;")
+ write_c("}")
+ map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_previous_vout) \((.*)\)").match(fn_line), None, None, None)
+ fn_line = "uint32_t TxIn_get_sequence (struct LDKTxIn* thing)"
+ write_c(fn_line + " {")
+ write_c("\treturn thing->sequence;")
+ write_c("}")
+ map_fn(fn_line + "\n", re.compile("(.*) (TxIn_get_sequence) \((.*)\)").match(fn_line), None, None, None)
+ elif struct_name == "LDKBigEndianScalar":
+ with open(f"{sys.argv[3]}/structs/BigEndianScalar{consts.file_ext}", "w") as out_java_struct:
+ out_java_struct.write(consts.hu_struct_file_prefix)
+ out_java_struct.write(consts.scalar_defn)
+ out_java_struct.write(consts.hu_struct_file_suffix)
+ fn_line = "struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing)"
+ write_c(fn_line + " {\n")
+ write_c("\tLDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };\n")
+ write_c("\treturn ret;\n")
+ write_c("}\n")
+ map_fn(fn_line + "\n", re.compile("(.*) (BigEndianScalar_get_bytes) \((.*)\)").match(fn_line), None, None, None)
+
+ # We need to be able to FREE a heap-allocated BigEndianScalar, but because
+ # there's nothing heap-allocated inside it the C bindings don't bother
+ # exposing a `_free` method. Instead, we have to manually write one here,
+ # though it doesn't need to do anything, the autogenerated wrapper will do
+ # the required FREE.
+ fn_line = "static void BigEndianScalar_free (struct LDKBigEndianScalar thing)"
+ write_c(fn_line + " {}\n")
+ map_fn(fn_line + "\n", re.compile("static (.*) (BigEndianScalar_free) \((.*)\)").match(fn_line), None, None, None)