@@ -231,7 +231,10 @@ def java_c_types(fn_arg, ret_arr_len):
231231 assert var_is_arr_regex .match (fn_arg [8 :])
232232 arr_access = "data"
233233 elif fn_arg .startswith ("LDKWitness " ) or fn_arg == "LDKWitness" :
234- fn_arg = "uint8_t (*" + fn_arg [11 :] + ")[datalen]"
234+ if len (fn_arg ) > 12 and fn_arg [11 ] == "*" :
235+ fn_arg = "uint8_t (" + fn_arg [11 :] + ")[datalen]"
236+ else :
237+ fn_arg = "uint8_t (*" + fn_arg [11 :] + ")[datalen]"
235238 rust_obj = "LDKWitness"
236239 assert var_is_arr_regex .match (fn_arg [8 :])
237240 arr_access = "data"
@@ -323,6 +326,14 @@ def java_c_types(fn_arg, ret_arr_len):
323326 fn_ty_arg = "I"
324327 fn_arg = fn_arg [8 :].strip ()
325328 is_primitive = True
329+ elif fn_arg .startswith ("int64_t" ):
330+ mapped_type = consts .c_type_map ['int64_t' ]
331+ java_ty = mapped_type [0 ]
332+ c_ty = "int64_t"
333+ arr_ty = "int64_t"
334+ fn_ty_arg = "J"
335+ fn_arg = fn_arg [7 :].strip ()
336+ is_primitive = True
326337 elif fn_arg .startswith ("uint64_t" ) or fn_arg .startswith ("uintptr_t" ):
327338 # TODO: uintptr_t is arch-dependent :(
328339 mapped_type = consts .c_type_map ['uint64_t' ]
@@ -575,6 +586,9 @@ def map_fn_with_ref_option(line, re_match, ret_arr_len, c_call_string, doc_comme
575586 return_type_info = type_mapping_generator .map_type (method_return_type .strip () + " ret" , True , ret_arr_len , False , force_holds_ref )
576587
577588 if method_name .endswith ("_clone" ) and expected_struct not in unitary_enums :
589+ # LDKWitness is mapped as an array, so no need to implement clone
590+ if expected_struct == "LDKWitness" :
591+ return
578592 meth_line = "uint64_t " + expected_struct .replace ("LDK" , "" ) + "_clone_ptr(" + expected_struct + " *NONNULL_PTR arg)"
579593 write_c ("static inline " + meth_line + " {\n " )
580594 write_c ("\t " + return_type_info .ret_conv [0 ].replace ("\n " , "\n \t " ))
@@ -641,8 +655,8 @@ def map_fn_with_ref_option(line, re_match, ret_arr_len, c_call_string, doc_comme
641655 expected_struct in complex_enums or expected_struct in complex_enums or
642656 expected_struct in result_types or expected_struct in tuple_types ) and not is_free
643657 impl_on_utils = not impl_on_struct and (not is_free and not method_name .endswith ("_clone" ) and
644- not method_name .startswith ("TxOut" ) and not method_name .startswith ("BigEndianScalar " ) and
645- not method_name .startswith ("_" ) and
658+ not method_name .startswith ("TxOut" ) and not method_name .startswith ("TxIn " ) and
659+ not method_name .startswith ("BigEndianScalar" ) and not method_name . startswith ( " _" ) and
646660 method_name != "check_platform" and method_name != "Result_read" and
647661 not expected_struct in unitary_enums and
648662 ((not method_name .startswith ("C2Tuple_" ) and not method_name .startswith ("C3Tuple_" ))
@@ -1096,6 +1110,36 @@ def map_tuple(struct_name, field_lines):
10961110 write_c ("\t return thing->value;" )
10971111 write_c ("}" )
10981112 map_fn (fn_line + "\n " , re .compile ("(.*) (TxOut_get_value) \((.*)\)" ).match (fn_line ), None , None , None )
1113+ elif struct_name == "LDKTxIn" :
1114+ with open (f"{ sys .argv [3 ]} /structs/TxIn{ consts .file_ext } " , "w" ) as out_java_struct :
1115+ out_java_struct .write (consts .hu_struct_file_prefix )
1116+ out_java_struct .write (consts .txin_defn )
1117+ out_java_struct .write (consts .hu_struct_file_suffix )
1118+ fn_line = "struct LDKWitness TxIn_get_witness (struct LDKTxIn* thing)"
1119+ write_c (fn_line + " {" )
1120+ write_c ("\t return Witness_clone(&thing->witness);" )
1121+ write_c ("}" )
1122+ map_fn (fn_line + "\n " , re .compile ("(.*) (TxIn_get_witness) \((.*)\)" ).match (fn_line ), None , None , None )
1123+ fn_line = "struct LDKCVec_u8Z TxIn_get_script_sig (struct LDKTxIn* thing)"
1124+ write_c (fn_line + " {" )
1125+ write_c ("\t return CVec_u8Z_clone(&thing->script_sig);" )
1126+ write_c ("}" )
1127+ map_fn (fn_line + "\n " , re .compile ("(.*) (TxIn_get_script_sig) \((.*)\)" ).match (fn_line ), None , None , None )
1128+ fn_line = "LDKThirtyTwoBytes TxIn_get_previous_txid (struct LDKTxIn* thing)"
1129+ write_c (fn_line + " {" )
1130+ write_c ("\t return thing->previous_txid;" )
1131+ write_c ("}" )
1132+ map_fn (fn_line + "\n " , re .compile ("(.*) (TxIn_get_previous_txid) \((.*)\)" ).match (fn_line ), None , None , None )
1133+ fn_line = "uint32_t TxIn_get_previous_vout (struct LDKTxIn* thing)"
1134+ write_c (fn_line + " {" )
1135+ write_c ("\t return thing->previous_vout;" )
1136+ write_c ("}" )
1137+ map_fn (fn_line + "\n " , re .compile ("(.*) (TxIn_get_previous_vout) \((.*)\)" ).match (fn_line ), None , None , None )
1138+ fn_line = "uint32_t TxIn_get_sequence (struct LDKTxIn* thing)"
1139+ write_c (fn_line + " {" )
1140+ write_c ("\t return thing->sequence;" )
1141+ write_c ("}" )
1142+ map_fn (fn_line + "\n " , re .compile ("(.*) (TxIn_get_sequence) \((.*)\)" ).match (fn_line ), None , None , None )
10991143 elif struct_name == "LDKBigEndianScalar" :
11001144 with open (f"{ sys .argv [3 ]} /structs/BigEndianScalar{ consts .file_ext } " , "w" ) as out_java_struct :
11011145 out_java_struct .write (consts .hu_struct_file_prefix )
0 commit comments