public static native byte[] get_u8_slice_bytes(long slice_ptr);
public static native long bytes_to_u8_vec(byte[] bytes);
public static native long vec_slice_len(long vec);
+ public static native long new_empty_slice_vec();
""")
out_c.write("""
LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
return (long)vec->datalen;
}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * _env, jclass _b) {
+ // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
+ LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
+ vec->data = NULL;
+ vec->datalen = 0;
+ return (long)vec;
+}
// We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
_Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
public static native byte[] get_u8_slice_bytes(long slice_ptr);
public static native long bytes_to_u8_vec(byte[] bytes);
public static native long vec_slice_len(long vec);
+ public static native long new_empty_slice_vec();
public static native long LDKSecretKey_new();
LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
return (long)vec->datalen;
}
+JNIEXPORT long JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * _env, jclass _b) {
+ // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
+ _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
+ LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
+ vec->data = NULL;
+ vec->datalen = 0;
+ return (long)vec;
+}
// We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
_Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len
(JNIEnv *, jclass, jlong);
+/*
+ * Class: org_ldk_impl_bindings
+ * Method: new_empty_slice_vec
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec
+ (JNIEnv *, jclass);
+
/*
* Class: org_ldk_impl_bindings
* Method: LDKSecretKey_new
this.chain_monitor = bindings.LDKWatch_new(new bindings.LDKWatch() {
@Override
public long watch_channel(long funding_txo, long monitor) {
- return 0;
+ return bindings.CResult_NoneChannelMonitorUpdateErrZ_ok();
}
@Override
public long update_channel(long funding_txo, long update) {
- return 0;
+ return bindings.CResult_NoneChannelMonitorUpdateErrZ_ok();
}
@Override
public long release_pending_monitor_events() {
- return 0;
+ return bindings.new_empty_slice_vec();
}
});
do_read_event(list, peer2.peer_manager, descriptor2, bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_get_inner(init_vec));
bindings.CResult_CVec_u8ZPeerHandleErrorZ_free(init_vec);
- while (!list.isEmpty()) {
- list.poll().join();
- }
+ while (!list.isEmpty()) { list.poll().join(); }
+
+ long cc_res = bindings.ChannelManager_create_channel(peer1.chan_manager, bindings.ChannelManager_get_our_node_id(peer2.chan_manager), 10000, 1000, 0, bindings.LDKUserConfig_optional_none());
+ assert bindings.LDKCResult_NoneAPIErrorZ_result_ok(cc_res);
+ bindings.CResult_NoneAPIErrorZ_free(cc_res);
+
+ bindings.PeerManager_process_events(peer1.peer_manager);
+ while (!list.isEmpty()) { list.poll().join(); }
+ bindings.PeerManager_process_events(peer2.peer_manager);
+ while (!list.isEmpty()) { list.poll().join(); }
+
+ long peer1_chans = bindings.ChannelManager_list_channels(peer1.chan_manager);
+ long peer2_chans = bindings.ChannelManager_list_channels(peer2.chan_manager);
+ assert bindings.vec_slice_len(peer1_chans) == 1;
+ assert bindings.vec_slice_len(peer2_chans) == 1;
+ bindings.CVec_ChannelDetailsZ_free(peer1_chans);
+ bindings.CVec_ChannelDetailsZ_free(peer2_chans);
peer1.free();
peer2.free();