arg_conv_info.print_name()
if arg_conv_info.arg_name == "this_ptr" or arg_conv_info.arg_name == "this_arg":
takes_self = True
- if arg_conv_info.passed_as_ptr and not arg_conv_info.rust_obj in opaque_structs:
- if not arg_conv_info.rust_obj in trait_structs and not arg_conv_info.rust_obj in unitary_enums:
- args_known = False
if arg_conv_info.arg_conv is not None and "Warning" in arg_conv_info.arg_conv:
if arg_conv_info.rust_obj in constructor_fns:
assert not is_free
out_c.write("\tatomic_size_t refcnt;\n")
out_c.write("\tJavaVM *vm;\n")
out_c.write("\tjweak o;\n")
+ field_var_convs = []
for var_line in field_var_lines:
if var_line.group(1) in trait_structs:
out_c.write("\t" + var_line.group(1) + "_JCalls* " + var_line.group(2) + ";\n")
+ field_var_convs.append(None)
+ else:
+ field_var_convs.append(map_type(var_line.group(1) + " " + var_line.group(2), False, None, False, False))
for fn_line in trait_fn_lines:
if fn_line.group(2) != "free" and fn_line.group(2) != "clone":
out_c.write("\tjmethodID " + fn_line.group(2) + "_meth;\n")
out_java_trait.write("\tfinal bindings." + struct_name + " bindings_instance;\n")
out_java_trait.write("\t" + struct_name.replace("LDK", "") + "(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }\n")
out_java_trait.write("\tprivate " + struct_name.replace("LDK", "") + "(bindings." + struct_name + " arg")
- for var_line in field_var_lines:
+ for idx, var_line in enumerate(field_var_lines):
if var_line.group(1) in trait_structs:
out_java_trait.write(", bindings." + var_line.group(1) + " " + var_line.group(2))
+ else:
+ out_java_trait.write(", " + field_var_convs[idx].java_hu_ty + " " + var_line.group(2))
out_java_trait.write(") {\n")
out_java_trait.write("\t\tsuper(bindings." + struct_name + "_new(arg")
- for var_line in field_var_lines:
+ for idx, var_line in enumerate(field_var_lines):
if var_line.group(1) in trait_structs:
out_java_trait.write(", " + var_line.group(2))
+ elif field_var_convs[idx].from_hu_conv is not None:
+ out_java_trait.write(", " + field_var_convs[idx].from_hu_conv[0])
+ else:
+ out_java_trait.write(", " + var_line.group(2))
out_java_trait.write("));\n")
out_java_trait.write("\t\tthis.ptrs_to.add(arg);\n")
+ for idx, var_line in enumerate(field_var_lines):
+ if var_line.group(1) in trait_structs:
+ out_java_trait.write("\t\tthis.ptrs_to.add(" + var_line.group(2) + ");\n")
+ elif field_var_convs[idx].from_hu_conv is not None and field_var_convs[idx].from_hu_conv[1] != "":
+ out_java_trait.write("\t\t" + field_var_convs[idx].from_hu_conv[1] + ";\n")
out_java_trait.write("\t\tthis.bindings_instance = arg;\n")
out_java_trait.write("\t}\n")
out_java_trait.write("\t@Override @SuppressWarnings(\"deprecation\")\n")
out_java_trait.write("\t}\n\n")
java_trait_constr = "\tpublic " + struct_name.replace("LDK", "") + "(" + struct_name.replace("LDK", "") + "Interface arg"
- for var_line in field_var_lines:
+ for idx, var_line in enumerate(field_var_lines):
if var_line.group(1) in trait_structs:
# Ideally we'd be able to take any instance of the interface, but our C code can only represent
# Java-implemented version, so we require users pass a Java implementation here :/
java_trait_constr = java_trait_constr + ", " + var_line.group(1).replace("LDK", "") + "." + var_line.group(1).replace("LDK", "") + "Interface " + var_line.group(2)
+ else:
+ java_trait_constr = java_trait_constr + ", " + field_var_convs[idx].java_hu_ty + " " + var_line.group(2)
java_trait_constr = java_trait_constr + ") {\n\t\tthis(new bindings." + struct_name + "() {\n"
out_java_trait.write("\tpublic static interface " + struct_name.replace("LDK", "") + "Interface {\n")
out_java.write("\tpublic interface " + struct_name + " {\n")
for var_line in field_var_lines:
if var_line.group(1) in trait_structs:
java_trait_constr = java_trait_constr + ", new " + var_line.group(2) + "(" + var_line.group(2) + ").bindings_instance"
+ else:
+ java_trait_constr = java_trait_constr + ", " + var_line.group(2)
out_java_trait.write("\t}\n")
out_java_trait.write(java_trait_constr + ");\n\t}\n")
out_java.write("\tpublic static native long " + struct_name + "_new(" + struct_name + " impl")
out_c.write("static inline " + struct_name + " " + struct_name + "_init (JNIEnv * env, jclass _a, jobject o")
- for var_line in field_var_lines:
+ for idx, var_line in enumerate(field_var_lines):
if var_line.group(1) in trait_structs:
out_java.write(", " + var_line.group(1) + " " + var_line.group(2))
out_c.write(", jobject " + var_line.group(2))
+ else:
+ out_java.write(", " + field_var_convs[idx].java_ty + " " + var_line.group(2))
+ out_c.write(", " + field_var_convs[idx].c_ty + " " + var_line.group(2))
out_java.write(");\n")
out_c.write(") {\n")
if fn_line.group(2) != "free" and fn_line.group(2) != "clone":
out_c.write("\tcalls->" + fn_line.group(2) + "_meth = (*env)->GetMethodID(env, c, \"" + fn_line.group(2) + "\", \"" + java_meth_descr + "\");\n")
out_c.write("\tCHECK(calls->" + fn_line.group(2) + "_meth != NULL);\n")
+ for idx, var_line in enumerate(field_var_lines):
+ if field_var_convs[idx] is not None and field_var_convs[idx].arg_conv is not None:
+ out_c.write("\n\t" + field_var_convs[idx].arg_conv.replace("\n", "\n\t") +"\n")
out_c.write("\n\t" + struct_name + " ret = {\n")
out_c.write("\t\t.this_arg = (void*) calls,\n")
for fn_line in trait_fn_lines:
else:
clone_fns.add(struct_name + "_clone")
out_c.write("\t\t.clone = " + struct_name + "_JCalls_clone,\n")
- for var_line in field_var_lines:
+ for idx, var_line in enumerate(field_var_lines):
if var_line.group(1) in trait_structs:
out_c.write("\t\t." + var_line.group(2) + " = " + var_line.group(1) + "_init(env, _a, " + var_line.group(2) + "),\n")
+ elif field_var_convs[idx].arg_conv_name is not None:
+ out_c.write("\t\t." + var_line.group(2) + " = " + field_var_convs[idx].arg_conv_name + ",\n")
+ out_c.write("\t\t.set_" + var_line.group(2) + " = NULL,\n")
+ else:
+ out_c.write("\t\t." + var_line.group(2) + " = " + var_line.group(2) + ",\n")
+ out_c.write("\t\t.set_" + var_line.group(2) + " = NULL,\n")
out_c.write("\t};\n")
for var_line in field_var_lines:
if var_line.group(1) in trait_structs:
out_c.write("}\n")
out_c.write("JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_" + struct_name.replace("_", "_1") + "_1new (JNIEnv * env, jclass _a, jobject o")
- for var_line in field_var_lines:
+ for idx, var_line in enumerate(field_var_lines):
if var_line.group(1) in trait_structs:
out_c.write(", jobject " + var_line.group(2))
+ else:
+ out_c.write(", " + field_var_convs[idx].c_ty + " " + var_line.group(2))
out_c.write(") {\n")
out_c.write("\t" + struct_name + " *res_ptr = MALLOC(sizeof(" + struct_name + "), \"" + struct_name + "\");\n")
out_c.write("\t*res_ptr = " + struct_name + "_init(env, _a, o")
for var_line in field_var_lines:
- if var_line.group(1) in trait_structs:
- out_c.write(", " + var_line.group(2))
+ out_c.write(", " + var_line.group(2))
out_c.write(");\n")
out_c.write("\treturn (long)res_ptr;\n")
out_c.write("}\n")
if fn_line.group(2) != "free" and fn_line.group(2) != "clone" and fn_line.group(2) != "eq" and not is_log:
dummy_line = fn_line.group(1) + struct_name.replace("LDK", "") + "_" + fn_line.group(2) + " " + struct_name + "* this_arg" + fn_line.group(4) + "\n"
map_fn(dummy_line, re.compile("([A-Za-z_0-9]*) *([A-Za-z_0-9]*) *(.*)").match(dummy_line), None, "(this_arg_conv->" + fn_line.group(2) + ")(this_arg_conv->this_arg")
+ for idx, var_line in enumerate(field_var_lines):
+ if var_line.group(1) not in trait_structs:
+ out_c.write(var_line.group(1) + " " + struct_name + "_set_get_" + var_line.group(2) + "(" + struct_name + "* this_arg) {\n")
+ out_c.write("\tif (this_arg->set_" + var_line.group(2) + " != NULL)\n")
+ out_c.write("\t\tthis_arg->set_" + var_line.group(2) + "(this_arg);\n")
+ out_c.write("\treturn this_arg->" + var_line.group(2) + ";\n")
+ out_c.write("}\n")
+ dummy_line = var_line.group(1) + " " + struct_name.replace("LDK", "") + "_get_" + var_line.group(2) + " " + struct_name + "* this_arg" + fn_line.group(4) + "\n"
+ map_fn(dummy_line, re.compile("([A-Za-z_0-9]*) *([A-Za-z_0-9]*) *(.*)").match(dummy_line), None, struct_name + "_set_get_" + var_line.group(2) + "(this_arg_conv")
out_c.write("""#include \"org_ldk_impl_bindings.h\"
#include <rust_types.h>
while (it->ptr != ptr) {
p = it; it = it->next;
if (it == NULL) {
- fprintf(stderr, "Tried to free unknown pointer %p!\\n", ptr);
+ fprintf(stderr, "Tried to free unknown pointer %p at:\\n", ptr);
+ void* bt[BT_MAX];
+ int bt_len = backtrace(bt, BT_MAX);
+ backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
+ fprintf(stderr, "\\n\\n");
+ DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
return; // addrsan should catch malloc-unknown and print more info than we have
}
}
assert(line_indicates_trait_regex.match(" void *(*clone)(const void *this_arg);"))
line_field_var_regex = re.compile("^ ([A-Za-z_0-9]*) ([A-Za-z_0-9]*);$")
assert(line_field_var_regex.match(" LDKMessageSendEventsProvider MessageSendEventsProvider;"))
+ assert(line_field_var_regex.match(" LDKChannelPublicKeys pubkeys;"))
struct_name_regex = re.compile("^typedef (struct|enum|union) (MUST_USE_STRUCT )?(LDK[A-Za-z_0-9]*) {$")
assert(struct_name_regex.match("typedef struct LDKCVecTempl_u8 {"))
assert(struct_name_regex.match("typedef enum LDKNetwork {"))
long sign_channel_announcement(long msg);
void on_accept(long channel_points, short counterparty_selected_contest_delay, short holder_selected_contest_delay);
}
- public static native long LDKChannelKeys_new(LDKChannelKeys impl);
+ public static native long LDKChannelKeys_new(LDKChannelKeys impl, long pubkeys);
public static native LDKChannelKeys LDKChannelKeys_get_obj_from_jcalls(long val);
// LDKPublicKey ChannelKeys_get_per_commitment_point LDKChannelKeys* this_arg, uint64_t idx
public static native byte[] ChannelKeys_get_per_commitment_point(long this_arg, long idx);
public static native long ChannelKeys_sign_channel_announcement(long this_arg, long msg);
// void ChannelKeys_on_accept LDKChannelKeys* this_arg, const LDKChannelPublicKeys *channel_points, uint16_t counterparty_selected_contest_delay, uint16_t holder_selected_contest_delay
public static native void ChannelKeys_on_accept(long this_arg, long channel_points, short counterparty_selected_contest_delay, short holder_selected_contest_delay);
+ // LDKChannelPublicKeys ChannelKeys_get_pubkeys LDKChannelKeys* this_arg
+ public static native long ChannelKeys_get_pubkeys(long this_arg);
public static native long[] LDKCVecTempl_MonitorEvent_arr_info(long vec_ptr);
public static native long LDKCVecTempl_MonitorEvent_new(long[] elems);
public interface LDKWatch {
}
});
}
- // Skipped BroadcasterInterface_broadcast_transaction
+ public void broadcast_transaction(Transaction tx) {
+ bindings.BroadcasterInterface_broadcast_transaction(this.ptr, tx.ptr);
+ }
+
}
public class ChannelKeys extends CommonBase {
final bindings.LDKChannelKeys bindings_instance;
ChannelKeys(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
- private ChannelKeys(bindings.LDKChannelKeys arg) {
- super(bindings.LDKChannelKeys_new(arg));
+ private ChannelKeys(bindings.LDKChannelKeys arg, ChannelPublicKeys pubkeys) {
+ super(bindings.LDKChannelKeys_new(arg, pubkeys == null ? 0 : pubkeys.ptr & ~1));
this.ptrs_to.add(arg);
+ this.ptrs_to.add(pubkeys);
this.bindings_instance = arg;
}
@Override @SuppressWarnings("deprecation")
Result_SignatureNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg);
void on_accept(ChannelPublicKeys channel_points, short counterparty_selected_contest_delay, short holder_selected_contest_delay);
}
- public ChannelKeys(ChannelKeysInterface arg) {
+ public ChannelKeys(ChannelKeysInterface arg, ChannelPublicKeys pubkeys) {
this(new bindings.LDKChannelKeys() {
@Override public byte[] get_per_commitment_point(long idx) {
byte[] ret = arg.get_per_commitment_point(idx);
ChannelPublicKeys channel_points_hu_conv = new ChannelPublicKeys(null, channel_points);
arg.on_accept(channel_points_hu_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
}
- });
+ }, pubkeys);
}
public byte[] get_per_commitment_point(long idx) {
byte[] ret = bindings.ChannelKeys_get_per_commitment_point(this.ptr, idx);
}
// Skipped ChannelKeys_key_derivation_params
- // Skipped ChannelKeys_sign_counterparty_commitment
+ public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(int feerate_per_kw, Transaction commitment_tx, PreCalculatedTxCreationKeys keys, HTLCOutputInCommitment[] htlcs) {
+ long ret = bindings.ChannelKeys_sign_counterparty_commitment(this.ptr, feerate_per_kw, commitment_tx.ptr, keys == null ? 0 : keys.ptr & ~1, Arrays.stream(htlcs).mapToLong(arr_conv_24 -> arr_conv_24 == null ? 0 : arr_conv_24.ptr & ~1).toArray());
+ Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(this);
+ this.ptrs_to.add(keys);
+ /* TODO 2 HTLCOutputInCommitment */;
+ return ret_hu_conv;
+ }
+
public Result_SignatureNoneZ sign_holder_commitment(HolderCommitmentTransaction holder_commitment_tx) {
long ret = bindings.ChannelKeys_sign_holder_commitment(this.ptr, holder_commitment_tx == null ? 0 : holder_commitment_tx.ptr & ~1);
Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
return ret_hu_conv;
}
- // Skipped ChannelKeys_sign_justice_transaction
- // Skipped ChannelKeys_sign_counterparty_htlc_transaction
- // Skipped ChannelKeys_sign_closing_transaction
+ public Result_SignatureNoneZ sign_justice_transaction(Transaction justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc) {
+ long ret = bindings.ChannelKeys_sign_justice_transaction(this.ptr, justice_tx.ptr, input, amount, per_commitment_key, htlc == null ? 0 : htlc.ptr & ~1);
+ Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(this);
+ this.ptrs_to.add(htlc);
+ return ret_hu_conv;
+ }
+
+ public Result_SignatureNoneZ sign_counterparty_htlc_transaction(Transaction htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc) {
+ long ret = bindings.ChannelKeys_sign_counterparty_htlc_transaction(this.ptr, htlc_tx.ptr, input, amount, per_commitment_point, htlc == null ? 0 : htlc.ptr & ~1);
+ Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(this);
+ this.ptrs_to.add(htlc);
+ return ret_hu_conv;
+ }
+
+ public Result_SignatureNoneZ sign_closing_transaction(Transaction closing_tx) {
+ long ret = bindings.ChannelKeys_sign_closing_transaction(this.ptr, closing_tx.ptr);
+ Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
+ ret_hu_conv.ptrs_to.add(this);
+ return ret_hu_conv;
+ }
+
public Result_SignatureNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) {
long ret = bindings.ChannelKeys_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
this.ptrs_to.add(channel_points);
}
+ public ChannelPublicKeys get_pubkeys() {
+ long ret = bindings.ChannelKeys_get_pubkeys(this.ptr);
+ ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
+ return ret_hu_conv;
+ }
+
}
private ChannelMessageHandler(bindings.LDKChannelMessageHandler arg, bindings.LDKMessageSendEventsProvider MessageSendEventsProvider) {
super(bindings.LDKChannelMessageHandler_new(arg, MessageSendEventsProvider));
this.ptrs_to.add(arg);
+ this.ptrs_to.add(MessageSendEventsProvider);
this.bindings_instance = arg;
}
@Override @SuppressWarnings("deprecation")
}
// Skipped HolderCommitmentTransaction_get_unsigned_tx
- // Skipped HolderCommitmentTransaction_set_unsigned_tx
+ public void set_unsigned_tx(Transaction val) {
+ bindings.HolderCommitmentTransaction_set_unsigned_tx(this.ptr, val.ptr);
+ }
+
public byte[] get_counterparty_sig() {
byte[] ret = bindings.HolderCommitmentTransaction_get_counterparty_sig(this.ptr);
return ret;
/* TODO 2 TwoTuple<HTLCOutputInCommitment, byte[]> */;
}
- // Skipped HolderCommitmentTransaction_new_missing_holder_sig
+ public static HolderCommitmentTransaction constructor_new_missing_holder_sig(Transaction unsigned_tx, byte[] counterparty_sig, byte[] holder_funding_key, byte[] counterparty_funding_key, TxCreationKeys keys, int feerate_per_kw, TwoTuple<HTLCOutputInCommitment, byte[]>[] htlc_data) {
+ long ret = bindings.HolderCommitmentTransaction_new_missing_holder_sig(unsigned_tx.ptr, counterparty_sig, holder_funding_key, counterparty_funding_key, keys == null ? 0 : keys.ptr & ~1, feerate_per_kw, Arrays.stream(htlc_data).mapToLong(arr_conv_42 -> bindings.C2Tuple_HTLCOutputInCommitmentSignatureZ_new(arr_conv_42.a == null ? 0 : arr_conv_42.a.ptr & ~1/*XXX: this.ptrs_to.add(arr_conv_42_a)*/, arr_conv_42.b)).toArray());
+ HolderCommitmentTransaction ret_hu_conv = new HolderCommitmentTransaction(null, ret);
+ ret_hu_conv.ptrs_to.add(keys);
+ /* TODO 2 TwoTuple<HTLCOutputInCommitment, byte[]> */;
+ return ret_hu_conv;
+ }
+
public TxCreationKeys trust_key_derivation() {
long ret = bindings.HolderCommitmentTransaction_trust_key_derivation(this.ptr);
TxCreationKeys ret_hu_conv = new TxCreationKeys(null, ret);
bindings.InMemoryChannelKeys_set_commitment_seed(this.ptr, val);
}
- // Skipped InMemoryChannelKeys_new
+ public static InMemoryChannelKeys constructor_new(byte[] funding_key, byte[] revocation_base_key, byte[] payment_key, byte[] delayed_payment_base_key, byte[] htlc_base_key, byte[] commitment_seed, long channel_value_satoshis, TwoTuple<Long, Long> key_derivation_params) {
+ long ret = bindings.InMemoryChannelKeys_new(funding_key, revocation_base_key, payment_key, delayed_payment_base_key, htlc_base_key, commitment_seed, channel_value_satoshis, bindings.C2Tuple_u64u64Z_new(key_derivation_params.a, key_derivation_params.b));
+ InMemoryChannelKeys ret_hu_conv = new InMemoryChannelKeys(null, ret);
+ return ret_hu_conv;
+ }
+
public ChannelPublicKeys counterparty_pubkeys() {
long ret = bindings.InMemoryChannelKeys_counterparty_pubkeys(this.ptr);
ChannelPublicKeys ret_hu_conv = new ChannelPublicKeys(null, ret);
return ret_hu_conv;
}
- // Skipped LightningError_set_action
- // Skipped LightningError_new
+ public void set_action(ErrorAction val) {
+ bindings.LightningError_set_action(this.ptr, val.ptr);
+ }
+
+ public static LightningError constructor_new(byte[] err_arg, ErrorAction action_arg) {
+ long ret = bindings.LightningError_new(err_arg, action_arg.ptr);
+ LightningError ret_hu_conv = new LightningError(null, ret);
+ return ret_hu_conv;
+ }
+
}
return ret_hu_conv;
}
- // Skipped RoutingMessageHandler_handle_htlc_fail_channel_update
+ public void handle_htlc_fail_channel_update(HTLCFailChannelUpdate update) {
+ bindings.RoutingMessageHandler_handle_htlc_fail_channel_update(this.ptr, update == null ? 0 : update.ptr & ~1);
+ this.ptrs_to.add(update);
+ }
+
public ThreeTuple<ChannelAnnouncement, ChannelUpdate, ChannelUpdate>[] get_next_channel_announcements(long starting_point, byte batch_amount) {
long[] ret = bindings.RoutingMessageHandler_get_next_channel_announcements(this.ptr, starting_point, batch_amount);
ThreeTuple<ChannelAnnouncement, ChannelUpdate, ChannelUpdate>[] arr_conv_63_arr = new ThreeTuple[ret.length];
while (it->ptr != ptr) {
p = it; it = it->next;
if (it == NULL) {
- fprintf(stderr, "Tried to free unknown pointer %p!\n", ptr);
+ fprintf(stderr, "Tried to free unknown pointer %p at:\n", ptr);
+ void* bt[BT_MAX];
+ int bt_len = backtrace(bt, BT_MAX);
+ backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
+ fprintf(stderr, "\n\n");
+ DO_ASSERT(mtx_unlock(&allocation_mtx) == thrd_success);
return; // addrsan should catch malloc-unknown and print more info than we have
}
}
atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
return (void*) this_arg;
}
-static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o) {
+static inline LDKChannelKeys LDKChannelKeys_init (JNIEnv * env, jclass _a, jobject o, jlong pubkeys) {
jclass c = (*env)->GetObjectClass(env, o);
CHECK(c != NULL);
LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
calls->on_accept_meth = (*env)->GetMethodID(env, c, "on_accept", "(JSS)V");
CHECK(calls->on_accept_meth != NULL);
+ LDKChannelPublicKeys pubkeys_conv;
+ pubkeys_conv.inner = (void*)(pubkeys & (~1));
+ pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
+ if (pubkeys_conv.inner != NULL)
+ pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
+
LDKChannelKeys ret = {
.this_arg = (void*) calls,
.get_per_commitment_point = get_per_commitment_point_jcall,
.on_accept = on_accept_jcall,
.clone = LDKChannelKeys_JCalls_clone,
.free = LDKChannelKeys_JCalls_free,
+ .pubkeys = pubkeys_conv,
+ .set_pubkeys = NULL,
};
return ret;
}
-JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o) {
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new (JNIEnv * env, jclass _a, jobject o, jlong pubkeys) {
LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
- *res_ptr = LDKChannelKeys_init(env, _a, o);
+ *res_ptr = LDKChannelKeys_init(env, _a, o, pubkeys);
return (long)res_ptr;
}
JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1get_1obj_1from_1jcalls (JNIEnv * env, jclass _a, jlong val) {
(this_arg_conv->on_accept)(this_arg_conv->this_arg, &channel_points_conv, counterparty_selected_contest_delay, holder_selected_contest_delay);
}
+LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
+ if (this_arg->set_pubkeys != NULL)
+ this_arg->set_pubkeys(this_arg);
+ return this_arg->pubkeys;
+}
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1pubkeys(JNIEnv * _env, jclass _b, jlong this_arg) {
+ LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
+ LDKChannelPublicKeys ret = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
+ return ((long)ret.inner) | (ret.is_owned ? 1 : 0);
+}
+
JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCVecTempl_1MonitorEvent_1arr_1info(JNIEnv *env, jclass _b, jlong ptr) {
LDKCVecTempl_MonitorEvent *vec = (LDKCVecTempl_MonitorEvent*)ptr;
jlongArray ret = (*env)->NewLongArray(env, vec->datalen);
LDKChannelDetails arr_conv_16_conv;
arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
+ if (arr_conv_16_conv.inner != NULL)
+ arr_conv_16_conv = ChannelDetails_clone(&arr_conv_16_conv);
first_hops_constr.data[q] = arr_conv_16_conv;
}
(*_env)->ReleaseLongArrayElements (_env, first_hops, first_hops_vals, 0);
/*
* Class: org_ldk_impl_bindings
* Method: LDKChannelKeys_new
- * Signature: (Lorg/ldk/impl/bindings/LDKChannelKeys;)J
+ * Signature: (Lorg/ldk/impl/bindings/LDKChannelKeys;J)J
*/
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKChannelKeys_1new
- (JNIEnv *, jclass, jobject);
+ (JNIEnv *, jclass, jobject, jlong);
/*
* Class: org_ldk_impl_bindings
JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1on_1accept
(JNIEnv *, jclass, jlong, jlong, jshort, jshort);
+/*
+ * Class: org_ldk_impl_bindings
+ * Method: ChannelKeys_get_pubkeys
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelKeys_1get_1pubkeys
+ (JNIEnv *, jclass, jlong);
+
/*
* Class: org_ldk_impl_bindings
* Method: LDKCVecTempl_MonitorEvent_arr_info