From 4f914d250ae903770128765403d62ce3d8f54126 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 12 Jan 2021 19:04:57 -0500 Subject: [PATCH] bindings updates --- src/main/java/org/ldk/structs/Access.java | 1 - .../java/org/ldk/structs/ChannelKeys.java | 7 - .../java/org/ldk/structs/KeysInterface.java | 1 - src/main/java/org/ldk/structs/Persist.java | 2 - .../ldk/structs/RoutingMessageHandler.java | 7 - src/main/java/org/ldk/structs/Watch.java | 2 - src/main/jni/bindings.c | 8 +- ts/bindings.c | 617 ------------------ ts/bindings.ts | 121 ---- ts/structs/Access.ts | 33 - ts/structs/BroadcasterInterface.ts | 30 - ts/structs/ChannelKeys.ts | 108 --- ts/structs/ChannelMessageHandler.ts | 123 ---- ts/structs/EventsProvider.ts | 33 - ts/structs/FeeEstimator.ts | 31 - ts/structs/Filter.ts | 35 - ts/structs/KeysInterface.ts | 60 -- ts/structs/Logger.ts | 30 - ts/structs/MessageSendEventsProvider.ts | 33 - ts/structs/Persist.ts | 45 -- ts/structs/RoutingMessageHandler.ts | 107 --- ts/structs/SocketDescriptor.ts | 47 -- ts/structs/Watch.ts | 51 -- 23 files changed, 4 insertions(+), 1528 deletions(-) diff --git a/src/main/java/org/ldk/structs/Access.java b/src/main/java/org/ldk/structs/Access.java index da510903..6b4c9a9f 100644 --- a/src/main/java/org/ldk/structs/Access.java +++ b/src/main/java/org/ldk/structs/Access.java @@ -29,7 +29,6 @@ public class Access extends CommonBase { @Override public long get_utxo(byte[] genesis_hash, long short_channel_id) { Result_TxOutAccessErrorZ ret = arg.get_utxo(genesis_hash, short_channel_id); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } }); diff --git a/src/main/java/org/ldk/structs/ChannelKeys.java b/src/main/java/org/ldk/structs/ChannelKeys.java index 76537158..b4b9b87b 100644 --- a/src/main/java/org/ldk/structs/ChannelKeys.java +++ b/src/main/java/org/ldk/structs/ChannelKeys.java @@ -55,48 +55,41 @@ public class ChannelKeys extends CommonBase { CommitmentTransaction commitment_tx_hu_conv = new CommitmentTransaction(null, commitment_tx); Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long sign_holder_commitment(long commitment_tx) { HolderCommitmentTransaction commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); Result_SignatureNoneZ ret = arg.sign_holder_commitment(commitment_tx_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long sign_holder_commitment_htlc_transactions(long commitment_tx) { HolderCommitmentTransaction commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); Result_CVec_SignatureZNoneZ ret = arg.sign_holder_commitment_htlc_transactions(commitment_tx_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long sign_justice_transaction(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, long htlc) { HTLCOutputInCommitment htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); Result_SignatureNoneZ ret = arg.sign_justice_transaction(justice_tx, input, amount, per_commitment_key, htlc_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, long htlc) { HTLCOutputInCommitment htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long sign_closing_transaction(byte[] closing_tx) { Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long sign_channel_announcement(long msg) { UnsignedChannelAnnouncement msg_hu_conv = new UnsignedChannelAnnouncement(null, msg); Result_SignatureNoneZ ret = arg.sign_channel_announcement(msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public void ready_channel(long channel_parameters) { diff --git a/src/main/java/org/ldk/structs/KeysInterface.java b/src/main/java/org/ldk/structs/KeysInterface.java index 1a715877..46148adf 100644 --- a/src/main/java/org/ldk/structs/KeysInterface.java +++ b/src/main/java/org/ldk/structs/KeysInterface.java @@ -56,7 +56,6 @@ public class KeysInterface extends CommonBase { @Override public long read_chan_signer(byte[] reader) { Result_ChanKeySignerDecodeErrorZ ret = arg.read_chan_signer(reader); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } }); diff --git a/src/main/java/org/ldk/structs/Persist.java b/src/main/java/org/ldk/structs/Persist.java index d9f5690e..754f3911 100644 --- a/src/main/java/org/ldk/structs/Persist.java +++ b/src/main/java/org/ldk/structs/Persist.java @@ -32,7 +32,6 @@ public class Persist extends CommonBase { ChannelMonitor data_hu_conv = new ChannelMonitor(null, data); Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(id_hu_conv, data_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long update_persisted_channel(long id, long update, long data) { @@ -41,7 +40,6 @@ public class Persist extends CommonBase { ChannelMonitor data_hu_conv = new ChannelMonitor(null, data); Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(id_hu_conv, update_hu_conv, data_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } }); diff --git a/src/main/java/org/ldk/structs/RoutingMessageHandler.java b/src/main/java/org/ldk/structs/RoutingMessageHandler.java index 9d6cdc0f..6e1f2214 100644 --- a/src/main/java/org/ldk/structs/RoutingMessageHandler.java +++ b/src/main/java/org/ldk/structs/RoutingMessageHandler.java @@ -41,21 +41,18 @@ public class RoutingMessageHandler extends CommonBase { NodeAnnouncement msg_hu_conv = new NodeAnnouncement(null, msg); Result_boolLightningErrorZ ret = arg.handle_node_announcement(msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long handle_channel_announcement(long msg) { ChannelAnnouncement msg_hu_conv = new ChannelAnnouncement(null, msg); Result_boolLightningErrorZ ret = arg.handle_channel_announcement(msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long handle_channel_update(long msg) { ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg); Result_boolLightningErrorZ ret = arg.handle_channel_update(msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public void handle_htlc_fail_channel_update(long update) { @@ -82,28 +79,24 @@ public class RoutingMessageHandler extends CommonBase { ReplyChannelRange msg_hu_conv = new ReplyChannelRange(null, msg); Result_NoneLightningErrorZ ret = arg.handle_reply_channel_range(their_node_id, msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long handle_reply_short_channel_ids_end(byte[] their_node_id, long msg) { ReplyShortChannelIdsEnd msg_hu_conv = new ReplyShortChannelIdsEnd(null, msg); Result_NoneLightningErrorZ ret = arg.handle_reply_short_channel_ids_end(their_node_id, msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long handle_query_channel_range(byte[] their_node_id, long msg) { QueryChannelRange msg_hu_conv = new QueryChannelRange(null, msg); Result_NoneLightningErrorZ ret = arg.handle_query_channel_range(their_node_id, msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long handle_query_short_channel_ids(byte[] their_node_id, long msg) { QueryShortChannelIds msg_hu_conv = new QueryShortChannelIds(null, msg); Result_NoneLightningErrorZ ret = arg.handle_query_short_channel_ids(their_node_id, msg_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance); diff --git a/src/main/java/org/ldk/structs/Watch.java b/src/main/java/org/ldk/structs/Watch.java index 8bc9ab05..1efd7e0e 100644 --- a/src/main/java/org/ldk/structs/Watch.java +++ b/src/main/java/org/ldk/structs/Watch.java @@ -33,7 +33,6 @@ public class Watch extends CommonBase { ChannelMonitor monitor_hu_conv = new ChannelMonitor(null, monitor); Result_NoneChannelMonitorUpdateErrZ ret = arg.watch_channel(funding_txo_hu_conv, monitor_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long update_channel(long funding_txo, long update) { @@ -41,7 +40,6 @@ public class Watch extends CommonBase { ChannelMonitorUpdate update_hu_conv = new ChannelMonitorUpdate(null, update); Result_NoneChannelMonitorUpdateErrZ ret = arg.update_channel(funding_txo_hu_conv, update_hu_conv); long result = ret != null ? ret.ptr : 0; - ret.ptr = 0; return result; } @Override public long[] release_pending_monitor_events() { diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index 2266392d..8786c90d 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -208,15 +208,15 @@ _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits"); typedef jlongArray int64_tArray; typedef jbyteArray int8_tArray; -static jclass arr_of_B_clz = NULL; static jclass arr_of_J_clz = NULL; +static jclass arr_of_B_clz = NULL; JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) { - arr_of_B_clz = (*env)->FindClass(env, "[B"); - CHECK(arr_of_B_clz != NULL); - arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz); arr_of_J_clz = (*env)->FindClass(env, "[J"); CHECK(arr_of_J_clz != NULL); arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz); + arr_of_B_clz = (*env)->FindClass(env, "[B"); + CHECK(arr_of_B_clz != NULL); + arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz); } static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; } static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) { diff --git a/ts/bindings.c b/ts/bindings.c index 0cad7c7f..704e37ae 100644 --- a/ts/bindings.c +++ b/ts/bindings.c @@ -968,80 +968,6 @@ void LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (void* ctx_TODO, uint32_t arg) CHECK(!val->result_ok); return *val->contents.err; } -static void* LDKChannelKeys_JCalls_clone(const void* this_arg) { - LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKChannelKeys LDKChannelKeys_init (void* ctx_TODO, jobject o, uint32_t pubkeys) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B"); - CHECK(calls->get_per_commitment_point_meth != NULL); - calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B"); - CHECK(calls->release_commitment_secret_meth != NULL); - calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J"); - CHECK(calls->key_derivation_params_meth != NULL); - calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J"); - CHECK(calls->sign_counterparty_commitment_meth != NULL); - calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J"); - CHECK(calls->sign_holder_commitment_meth != NULL); - calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J"); - CHECK(calls->sign_holder_commitment_htlc_transactions_meth != NULL); - calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J"); - CHECK(calls->sign_justice_transaction_meth != NULL); - calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J"); - CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL); - calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J"); - CHECK(calls->sign_closing_transaction_meth != NULL); - calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J"); - CHECK(calls->sign_channel_announcement_meth != NULL); - calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V"); - CHECK(calls->ready_channel_meth != NULL); - calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B"); - CHECK(calls->write_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, - .release_commitment_secret = release_commitment_secret_jcall, - .key_derivation_params = key_derivation_params_jcall, - .sign_counterparty_commitment = sign_counterparty_commitment_jcall, - .sign_holder_commitment = sign_holder_commitment_jcall, - .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall, - .sign_justice_transaction = sign_justice_transaction_jcall, - .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall, - .sign_closing_transaction = sign_closing_transaction_jcall, - .sign_channel_announcement = sign_channel_announcement_jcall, - .ready_channel = ready_channel_jcall, - .clone = LDKChannelKeys_JCalls_clone, - .write = write_jcall, - .free = LDKChannelKeys_JCalls_free, - .pubkeys = pubkeys_conv, - .set_pubkeys = NULL, - }; - return ret; -} -long LDKChannelKeys_1new (void* ctx_TODO, jobject o, uint32_t pubkeys) { - LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys"); - *res_ptr = LDKChannelKeys_init(env, clz, o, pubkeys); - return (long)res_ptr; -} -jobject LDKChannelKeys_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} int8_tArray ChannelKeys_1get_1per_1commitment_1point(void* ctx_TODO, uint32_t this_arg, int64_t idx) { LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg; int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") }; @@ -1478,44 +1404,6 @@ uint32_t LDKCVec_1ChannelMonitorZ_1new(void* ctx_TODO, uint32_tArray elems) { } return (long)ret; } -static void* LDKWatch_JCalls_clone(const void* this_arg) { - LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKWatch LDKWatch_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J"); - CHECK(calls->watch_channel_meth != NULL); - calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J"); - CHECK(calls->update_channel_meth != NULL); - calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J"); - CHECK(calls->release_pending_monitor_events_meth != NULL); - - LDKWatch ret = { - .this_arg = (void*) calls, - .watch_channel = watch_channel_jcall, - .update_channel = update_channel_jcall, - .release_pending_monitor_events = release_pending_monitor_events_jcall, - .free = LDKWatch_JCalls_free, - }; - return ret; -} -long LDKWatch_1new (void* ctx_TODO, jobject o) { - LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch"); - *res_ptr = LDKWatch_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKWatch_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} uint32_t Watch_1watch_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) { LDKWatch* this_arg_conv = (LDKWatch*)this_arg; LDKOutPoint funding_txo_conv; @@ -1568,38 +1456,6 @@ uint32_tArray Watch_1release_1pending_1monitor_1events(void* ctx_TODO, uint32_t return ret_arr; } -static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) { - LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V"); - CHECK(calls->broadcast_transaction_meth != NULL); - - LDKBroadcasterInterface ret = { - .this_arg = (void*) calls, - .broadcast_transaction = broadcast_transaction_jcall, - .free = LDKBroadcasterInterface_JCalls_free, - }; - return ret; -} -long LDKBroadcasterInterface_1new (void* ctx_TODO, jobject o) { - LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface"); - *res_ptr = LDKBroadcasterInterface_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKBroadcasterInterface_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKBroadcasterInterface_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} void BroadcasterInterface_1broadcast_1transaction(void* ctx_TODO, uint32_t this_arg, int8_tArray tx) { LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg; LDKTransaction tx_ref; @@ -1610,53 +1466,6 @@ void BroadcasterInterface_1broadcast_1transaction(void* ctx_TODO, uint32_t this_ (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref); } -static void* LDKKeysInterface_JCalls_clone(const void* this_arg) { - LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKKeysInterface LDKKeysInterface_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B"); - CHECK(calls->get_node_secret_meth != NULL); - calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B"); - CHECK(calls->get_destination_script_meth != NULL); - calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B"); - CHECK(calls->get_shutdown_pubkey_meth != NULL); - calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J"); - CHECK(calls->get_channel_keys_meth != NULL); - calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B"); - CHECK(calls->get_secure_random_bytes_meth != NULL); - calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J"); - CHECK(calls->read_chan_signer_meth != NULL); - - LDKKeysInterface ret = { - .this_arg = (void*) calls, - .get_node_secret = get_node_secret_jcall, - .get_destination_script = get_destination_script_jcall, - .get_shutdown_pubkey = get_shutdown_pubkey_jcall, - .get_channel_keys = get_channel_keys_jcall, - .get_secure_random_bytes = get_secure_random_bytes_jcall, - .read_chan_signer = read_chan_signer_jcall, - .free = LDKKeysInterface_JCalls_free, - }; - return ret; -} -long LDKKeysInterface_1new (void* ctx_TODO, jobject o) { - LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface"); - *res_ptr = LDKKeysInterface_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKKeysInterface_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKKeysInterface_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} int8_tArray KeysInterface_1get_1node_1secret(void* ctx_TODO, uint32_t this_arg) { LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg; int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") }; @@ -1704,38 +1513,6 @@ uint32_t KeysInterface_1read_1chan_1signer(void* ctx_TODO, uint32_t this_arg, in return (long)ret_conv; } -static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) { - LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKFeeEstimator LDKFeeEstimator_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I"); - CHECK(calls->get_est_sat_per_1000_weight_meth != NULL); - - LDKFeeEstimator ret = { - .this_arg = (void*) calls, - .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall, - .free = LDKFeeEstimator_JCalls_free, - }; - return ret; -} -long LDKFeeEstimator_1new (void* ctx_TODO, jobject o) { - LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator"); - *res_ptr = LDKFeeEstimator_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKFeeEstimator_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKFeeEstimator_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} int32_t FeeEstimator_1get_1est_1sat_1per_11000_1weight(void* ctx_TODO, uint32_t this_arg, uint32_t confirmation_target) { LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg; LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target); @@ -1743,38 +1520,6 @@ int32_t FeeEstimator_1get_1est_1sat_1per_11000_1weight(void* ctx_TODO, uint32_t return ret_val; } -static void* LDKLogger_JCalls_clone(const void* this_arg) { - LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKLogger LDKLogger_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V"); - CHECK(calls->log_meth != NULL); - - LDKLogger ret = { - .this_arg = (void*) calls, - .log = log_jcall, - .free = LDKLogger_JCalls_free, - }; - return ret; -} -long LDKLogger_1new (void* ctx_TODO, jobject o) { - LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger"); - *res_ptr = LDKLogger_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKLogger_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKLogger_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} uint32_t LDKC2Tuple_1BlockHashChannelManagerZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) { LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ"); LDKThirtyTwoBytes a_ref; @@ -2714,38 +2459,6 @@ uint32_t LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_ long err_ref = (long)err_var.inner & ~1; return err_ref; } -static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J"); - CHECK(calls->get_and_clear_pending_msg_events_meth != NULL); - - LDKMessageSendEventsProvider ret = { - .this_arg = (void*) calls, - .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall, - .free = LDKMessageSendEventsProvider_JCalls_free, - }; - return ret; -} -long LDKMessageSendEventsProvider_1new (void* ctx_TODO, jobject o) { - LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider"); - *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKMessageSendEventsProvider_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} uint32_tArray MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(void* ctx_TODO, uint32_t this_arg) { LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg; LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg); @@ -2761,38 +2474,6 @@ uint32_tArray MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(v return ret_arr; } -static void* LDKEventsProvider_JCalls_clone(const void* this_arg) { - LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKEventsProvider LDKEventsProvider_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J"); - CHECK(calls->get_and_clear_pending_events_meth != NULL); - - LDKEventsProvider ret = { - .this_arg = (void*) calls, - .get_and_clear_pending_events = get_and_clear_pending_events_jcall, - .free = LDKEventsProvider_JCalls_free, - }; - return ret; -} -long LDKEventsProvider_1new (void* ctx_TODO, jobject o) { - LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider"); - *res_ptr = LDKEventsProvider_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKEventsProvider_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKEventsProvider_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} uint32_tArray EventsProvider_1get_1and_1clear_1pending_1events(void* ctx_TODO, uint32_t this_arg) { LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg; LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg); @@ -2808,38 +2489,6 @@ uint32_tArray EventsProvider_1get_1and_1clear_1pending_1events(void* ctx_TODO, u return ret_arr; } -static void* LDKAccess_JCalls_clone(const void* this_arg) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKAccess LDKAccess_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J"); - CHECK(calls->get_utxo_meth != NULL); - - LDKAccess ret = { - .this_arg = (void*) calls, - .get_utxo = get_utxo_jcall, - .free = LDKAccess_JCalls_free, - }; - return ret; -} -long LDKAccess_1new (void* ctx_TODO, jobject o) { - LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess"); - *res_ptr = LDKAccess_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKAccess_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKAccess_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} uint32_t Access_1get_1utxo(void* ctx_TODO, uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) { LDKAccess* this_arg_conv = (LDKAccess*)this_arg; unsigned char genesis_hash_arr[32]; @@ -2851,41 +2500,6 @@ uint32_t Access_1get_1utxo(void* ctx_TODO, uint32_t this_arg, int8_tArray genesi return (long)ret_conv; } -static void* LDKFilter_JCalls_clone(const void* this_arg) { - LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKFilter LDKFilter_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V"); - CHECK(calls->register_tx_meth != NULL); - calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V"); - CHECK(calls->register_output_meth != NULL); - - LDKFilter ret = { - .this_arg = (void*) calls, - .register_tx = register_tx_jcall, - .register_output = register_output_jcall, - .free = LDKFilter_JCalls_free, - }; - return ret; -} -long LDKFilter_1new (void* ctx_TODO, jobject o) { - LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter"); - *res_ptr = LDKFilter_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKFilter_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKFilter_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} void Filter_1register_1tx(void* ctx_TODO, uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) { LDKFilter* this_arg_conv = (LDKFilter*)this_arg; unsigned char txid_arr[32]; @@ -2909,41 +2523,6 @@ void Filter_1register_1output(void* ctx_TODO, uint32_t this_arg, uint32_t outpoi (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref); } -static void* LDKPersist_JCalls_clone(const void* this_arg) { - LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKPersist LDKPersist_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J"); - CHECK(calls->persist_new_channel_meth != NULL); - calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J"); - CHECK(calls->update_persisted_channel_meth != NULL); - - LDKPersist ret = { - .this_arg = (void*) calls, - .persist_new_channel = persist_new_channel_jcall, - .update_persisted_channel = update_persisted_channel_jcall, - .free = LDKPersist_JCalls_free, - }; - return ret; -} -long LDKPersist_1new (void* ctx_TODO, jobject o) { - LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist"); - *res_ptr = LDKPersist_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKPersist_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKPersist_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} uint32_t Persist_1persist_1new_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t id, uint32_t data) { LDKPersist* this_arg_conv = (LDKPersist*)this_arg; LDKOutPoint id_conv; @@ -2977,95 +2556,6 @@ uint32_t Persist_1update_1persisted_1channel(void* ctx_TODO, uint32_t this_arg, return (long)ret_conv; } -static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) { - LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V"); - CHECK(calls->handle_open_channel_meth != NULL); - calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V"); - CHECK(calls->handle_accept_channel_meth != NULL); - calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V"); - CHECK(calls->handle_funding_created_meth != NULL); - calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V"); - CHECK(calls->handle_funding_signed_meth != NULL); - calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V"); - CHECK(calls->handle_funding_locked_meth != NULL); - calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V"); - CHECK(calls->handle_shutdown_meth != NULL); - calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V"); - CHECK(calls->handle_closing_signed_meth != NULL); - calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V"); - CHECK(calls->handle_update_add_htlc_meth != NULL); - calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V"); - CHECK(calls->handle_update_fulfill_htlc_meth != NULL); - calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V"); - CHECK(calls->handle_update_fail_htlc_meth != NULL); - calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V"); - CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL); - calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V"); - CHECK(calls->handle_commitment_signed_meth != NULL); - calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V"); - CHECK(calls->handle_revoke_and_ack_meth != NULL); - calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V"); - CHECK(calls->handle_update_fee_meth != NULL); - calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V"); - CHECK(calls->handle_announcement_signatures_meth != NULL); - calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V"); - CHECK(calls->peer_disconnected_meth != NULL); - calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V"); - CHECK(calls->peer_connected_meth != NULL); - calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V"); - CHECK(calls->handle_channel_reestablish_meth != NULL); - calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V"); - CHECK(calls->handle_error_meth != NULL); - - LDKChannelMessageHandler ret = { - .this_arg = (void*) calls, - .handle_open_channel = handle_open_channel_jcall, - .handle_accept_channel = handle_accept_channel_jcall, - .handle_funding_created = handle_funding_created_jcall, - .handle_funding_signed = handle_funding_signed_jcall, - .handle_funding_locked = handle_funding_locked_jcall, - .handle_shutdown = handle_shutdown_jcall, - .handle_closing_signed = handle_closing_signed_jcall, - .handle_update_add_htlc = handle_update_add_htlc_jcall, - .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall, - .handle_update_fail_htlc = handle_update_fail_htlc_jcall, - .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall, - .handle_commitment_signed = handle_commitment_signed_jcall, - .handle_revoke_and_ack = handle_revoke_and_ack_jcall, - .handle_update_fee = handle_update_fee_jcall, - .handle_announcement_signatures = handle_announcement_signatures_jcall, - .peer_disconnected = peer_disconnected_jcall, - .peer_connected = peer_connected_jcall, - .handle_channel_reestablish = handle_channel_reestablish_jcall, - .handle_error = handle_error_jcall, - .free = LDKChannelMessageHandler_JCalls_free, - .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider), - }; - calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg; - return ret; -} -long LDKChannelMessageHandler_1new (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) { - LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler"); - *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider); - return (long)res_ptr; -} -jobject LDKChannelMessageHandler_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKChannelMessageHandler_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} void ChannelMessageHandler_1handle_1open_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) { LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg; LDKPublicKey their_node_id_ref; @@ -3280,71 +2770,6 @@ void ChannelMessageHandler_1handle_1error(void* ctx_TODO, uint32_t this_arg, int (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv); } -static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) { - LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J"); - CHECK(calls->handle_node_announcement_meth != NULL); - calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J"); - CHECK(calls->handle_channel_announcement_meth != NULL); - calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J"); - CHECK(calls->handle_channel_update_meth != NULL); - calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V"); - CHECK(calls->handle_htlc_fail_channel_update_meth != NULL); - calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J"); - CHECK(calls->get_next_channel_announcements_meth != NULL); - calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J"); - CHECK(calls->get_next_node_announcements_meth != NULL); - calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V"); - CHECK(calls->sync_routing_table_meth != NULL); - calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J"); - CHECK(calls->handle_reply_channel_range_meth != NULL); - calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J"); - CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL); - calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J"); - CHECK(calls->handle_query_channel_range_meth != NULL); - calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J"); - CHECK(calls->handle_query_short_channel_ids_meth != NULL); - - LDKRoutingMessageHandler ret = { - .this_arg = (void*) calls, - .handle_node_announcement = handle_node_announcement_jcall, - .handle_channel_announcement = handle_channel_announcement_jcall, - .handle_channel_update = handle_channel_update_jcall, - .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall, - .get_next_channel_announcements = get_next_channel_announcements_jcall, - .get_next_node_announcements = get_next_node_announcements_jcall, - .sync_routing_table = sync_routing_table_jcall, - .handle_reply_channel_range = handle_reply_channel_range_jcall, - .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall, - .handle_query_channel_range = handle_query_channel_range_jcall, - .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall, - .free = LDKRoutingMessageHandler_JCalls_free, - .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider), - }; - calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg; - return ret; -} -long LDKRoutingMessageHandler_1new (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) { - LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler"); - *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider); - return (long)res_ptr; -} -jobject LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKRoutingMessageHandler_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} uint32_t RoutingMessageHandler_1handle_1node_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) { LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg; LDKNodeAnnouncement msg_conv; @@ -3491,48 +2916,6 @@ uint32_t RoutingMessageHandler_1handle_1query_1short_1channel_1ids(void* ctx_TOD return (long)ret_conv; } -static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) { - LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg; - atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; -} -static inline LDKSocketDescriptor LDKSocketDescriptor_init (void* ctx_TODO, jobject o) { - jclass c = (*env)->GetObjectClass(env, o); - CHECK(c != NULL); - LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls"); - atomic_init(&calls->refcnt, 1); - DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0); - calls->o = (*env)->NewWeakGlobalRef(env, o); - calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J"); - CHECK(calls->send_data_meth != NULL); - calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V"); - CHECK(calls->disconnect_socket_meth != NULL); - calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z"); - CHECK(calls->eq_meth != NULL); - calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J"); - CHECK(calls->hash_meth != NULL); - - LDKSocketDescriptor ret = { - .this_arg = (void*) calls, - .send_data = send_data_jcall, - .disconnect_socket = disconnect_socket_jcall, - .eq = eq_jcall, - .hash = hash_jcall, - .clone = LDKSocketDescriptor_JCalls_clone, - .free = LDKSocketDescriptor_JCalls_free, - }; - return ret; -} -long LDKSocketDescriptor_1new (void* ctx_TODO, jobject o) { - LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor"); - *res_ptr = LDKSocketDescriptor_init(env, clz, o); - return (long)res_ptr; -} -jobject LDKSocketDescriptor_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) { - jobject ret = (*env)->NewLocalRef(env, ((LDKSocketDescriptor_JCalls*)val)->o); - CHECK(ret != NULL); - return ret; -} int64_t SocketDescriptor_1send_1data(void* ctx_TODO, uint32_t this_arg, int8_tArray data, jboolean resume_read) { LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg; LDKu8slice data_ref; diff --git a/ts/bindings.ts b/ts/bindings.ts index 6cd8bc7f..1bbf6b47 100644 --- a/ts/bindings.ts +++ b/ts/bindings.ts @@ -271,22 +271,6 @@ public class bindings { public static native boolean LDKCResult_CVec_SignatureZNoneZ_result_ok(long arg); public static native byte[][] LDKCResult_CVec_SignatureZNoneZ_get_ok(long arg); public static native void LDKCResult_CVec_SignatureZNoneZ_get_err(long arg); - public interface LDKChannelKeys { - byte[] get_per_commitment_point(long idx); - byte[] release_commitment_secret(long idx); - uint32_t key_derivation_params(); - uint32_t sign_counterparty_commitment(uint32_t commitment_tx); - uint32_t sign_holder_commitment(uint32_t commitment_tx); - uint32_t sign_holder_commitment_htlc_transactions(uint32_t commitment_tx); - uint32_t sign_justice_transaction(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, uint32_t htlc); - uint32_t sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, uint32_t htlc); - uint32_t sign_closing_transaction(byte[] closing_tx); - uint32_t sign_channel_announcement(uint32_t msg); - void ready_channel(uint32_t channel_parameters); - byte[] write(); - } - public static native long LDKChannelKeys_new(LDKChannelKeys impl, uint32_t 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(uint32_t this_arg, long idx); // LDKThirtyTwoBytes ChannelKeys_release_commitment_secret LDKChannelKeys* this_arg, uint64_t idx @@ -394,36 +378,14 @@ public class bindings { public static native LDKNetAddress LDKNetAddress_ref_from_ptr(long ptr); public static native long LDKCVec_NetAddressZ_new(uint32_t[] elems); public static native long LDKCVec_ChannelMonitorZ_new(uint32_t[] elems); - public interface LDKWatch { - uint32_t watch_channel(uint32_t funding_txo, uint32_t monitor); - uint32_t update_channel(uint32_t funding_txo, uint32_t update); - uint32_t[] release_pending_monitor_events(); - } - public static native long LDKWatch_new(LDKWatch impl); - public static native LDKWatch LDKWatch_get_obj_from_jcalls(long val); // LDKCResult_NoneChannelMonitorUpdateErrZ Watch_watch_channel LDKWatch* this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitor monitor public static native uint32_t Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor); // LDKCResult_NoneChannelMonitorUpdateErrZ Watch_update_channel LDKWatch* this_arg, struct LDKOutPoint funding_txo, struct LDKChannelMonitorUpdate update public static native uint32_t Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update); // LDKCVec_MonitorEventZ Watch_release_pending_monitor_events LDKWatch* this_arg public static native uint32_t[] Watch_release_pending_monitor_events(uint32_t this_arg); - public interface LDKBroadcasterInterface { - void broadcast_transaction(byte[] tx); - } - public static native long LDKBroadcasterInterface_new(LDKBroadcasterInterface impl); - public static native LDKBroadcasterInterface LDKBroadcasterInterface_get_obj_from_jcalls(long val); // void BroadcasterInterface_broadcast_transaction LDKBroadcasterInterface* this_arg, struct LDKTransaction tx public static native void BroadcasterInterface_broadcast_transaction(uint32_t this_arg, byte[] tx); - public interface LDKKeysInterface { - byte[] get_node_secret(); - byte[] get_destination_script(); - byte[] get_shutdown_pubkey(); - uint32_t get_channel_keys(boolean inbound, long channel_value_satoshis); - byte[] get_secure_random_bytes(); - uint32_t read_chan_signer(byte[] reader); - } - public static native long LDKKeysInterface_new(LDKKeysInterface impl); - public static native LDKKeysInterface LDKKeysInterface_get_obj_from_jcalls(long val); // LDKSecretKey KeysInterface_get_node_secret LDKKeysInterface* this_arg public static native byte[] KeysInterface_get_node_secret(uint32_t this_arg); // LDKCVec_u8Z KeysInterface_get_destination_script LDKKeysInterface* this_arg @@ -436,18 +398,8 @@ public class bindings { public static native byte[] KeysInterface_get_secure_random_bytes(uint32_t this_arg); // LDKCResult_ChanKeySignerDecodeErrorZ KeysInterface_read_chan_signer LDKKeysInterface* this_arg, struct LDKu8slice reader public static native uint32_t KeysInterface_read_chan_signer(uint32_t this_arg, byte[] reader); - public interface LDKFeeEstimator { - int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target); - } - public static native long LDKFeeEstimator_new(LDKFeeEstimator impl); - public static native LDKFeeEstimator LDKFeeEstimator_get_obj_from_jcalls(long val); // uint32_t FeeEstimator_get_est_sat_per_1000_weight LDKFeeEstimator* this_arg, enum LDKConfirmationTarget confirmation_target public static native int FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, LDKConfirmationTarget confirmation_target); - public interface LDKLogger { - void log(String record); - } - public static native long LDKLogger_new(LDKLogger impl); - public static native LDKLogger LDKLogger_get_obj_from_jcalls(long val); public static native long LDKC2Tuple_BlockHashChannelManagerZ_new(byte[] a, uint32_t b); public static native byte[] LDKC2Tuple_BlockHashChannelManagerZ_get_a(long ptr); public static native uint32_t LDKC2Tuple_BlockHashChannelManagerZ_get_b(long ptr); @@ -557,70 +509,20 @@ public class bindings { public static native boolean LDKCResult_NetworkGraphDecodeErrorZ_result_ok(long arg); public static native uint32_t LDKCResult_NetworkGraphDecodeErrorZ_get_ok(long arg); public static native uint32_t LDKCResult_NetworkGraphDecodeErrorZ_get_err(long arg); - public interface LDKMessageSendEventsProvider { - uint32_t[] get_and_clear_pending_msg_events(); - } - public static native long LDKMessageSendEventsProvider_new(LDKMessageSendEventsProvider impl); - public static native LDKMessageSendEventsProvider LDKMessageSendEventsProvider_get_obj_from_jcalls(long val); // LDKCVec_MessageSendEventZ MessageSendEventsProvider_get_and_clear_pending_msg_events LDKMessageSendEventsProvider* this_arg public static native uint32_t[] MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg); - public interface LDKEventsProvider { - uint32_t[] get_and_clear_pending_events(); - } - public static native long LDKEventsProvider_new(LDKEventsProvider impl); - public static native LDKEventsProvider LDKEventsProvider_get_obj_from_jcalls(long val); // LDKCVec_EventZ EventsProvider_get_and_clear_pending_events LDKEventsProvider* this_arg public static native uint32_t[] EventsProvider_get_and_clear_pending_events(uint32_t this_arg); - public interface LDKAccess { - uint32_t get_utxo(byte[] genesis_hash, long short_channel_id); - } - public static native long LDKAccess_new(LDKAccess impl); - public static native LDKAccess LDKAccess_get_obj_from_jcalls(long val); // LDKCResult_TxOutAccessErrorZ Access_get_utxo LDKAccess* this_arg, const uint8_t (*genesis_hash)[32], uint64_t short_channel_id public static native uint32_t Access_get_utxo(uint32_t this_arg, byte[] genesis_hash, long short_channel_id); - public interface LDKFilter { - void register_tx(byte[] txid, byte[] script_pubkey); - void register_output(uint32_t outpoint, byte[] script_pubkey); - } - public static native long LDKFilter_new(LDKFilter impl); - public static native LDKFilter LDKFilter_get_obj_from_jcalls(long val); // void Filter_register_tx LDKFilter* this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey public static native void Filter_register_tx(uint32_t this_arg, byte[] txid, byte[] script_pubkey); // void Filter_register_output LDKFilter* this_arg, const struct LDKOutPoint *NONNULL_PTR outpoint, struct LDKu8slice script_pubkey public static native void Filter_register_output(uint32_t this_arg, uint32_t outpoint, byte[] script_pubkey); - public interface LDKPersist { - uint32_t persist_new_channel(uint32_t id, uint32_t data); - uint32_t update_persisted_channel(uint32_t id, uint32_t update, uint32_t data); - } - public static native long LDKPersist_new(LDKPersist impl); - public static native LDKPersist LDKPersist_get_obj_from_jcalls(long val); // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_persist_new_channel LDKPersist* this_arg, struct LDKOutPoint id, const struct LDKChannelMonitor *NONNULL_PTR data public static native uint32_t Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data); // LDKCResult_NoneChannelMonitorUpdateErrZ Persist_update_persisted_channel LDKPersist* this_arg, struct LDKOutPoint id, const struct LDKChannelMonitorUpdate *NONNULL_PTR update, const struct LDKChannelMonitor *NONNULL_PTR data public static native uint32_t Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data); - public interface LDKChannelMessageHandler { - void handle_open_channel(byte[] their_node_id, uint32_t their_features, uint32_t msg); - void handle_accept_channel(byte[] their_node_id, uint32_t their_features, uint32_t msg); - void handle_funding_created(byte[] their_node_id, uint32_t msg); - void handle_funding_signed(byte[] their_node_id, uint32_t msg); - void handle_funding_locked(byte[] their_node_id, uint32_t msg); - void handle_shutdown(byte[] their_node_id, uint32_t msg); - void handle_closing_signed(byte[] their_node_id, uint32_t msg); - void handle_update_add_htlc(byte[] their_node_id, uint32_t msg); - void handle_update_fulfill_htlc(byte[] their_node_id, uint32_t msg); - void handle_update_fail_htlc(byte[] their_node_id, uint32_t msg); - void handle_update_fail_malformed_htlc(byte[] their_node_id, uint32_t msg); - void handle_commitment_signed(byte[] their_node_id, uint32_t msg); - void handle_revoke_and_ack(byte[] their_node_id, uint32_t msg); - void handle_update_fee(byte[] their_node_id, uint32_t msg); - void handle_announcement_signatures(byte[] their_node_id, uint32_t msg); - void peer_disconnected(byte[] their_node_id, boolean no_connection_possible); - void peer_connected(byte[] their_node_id, uint32_t msg); - void handle_channel_reestablish(byte[] their_node_id, uint32_t msg); - void handle_error(byte[] their_node_id, uint32_t msg); - } - public static native long LDKChannelMessageHandler_new(LDKChannelMessageHandler impl, LDKMessageSendEventsProvider MessageSendEventsProvider); - public static native LDKChannelMessageHandler LDKChannelMessageHandler_get_obj_from_jcalls(long val); // void ChannelMessageHandler_handle_open_channel LDKChannelMessageHandler* this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKOpenChannel *NONNULL_PTR msg public static native void ChannelMessageHandler_handle_open_channel(uint32_t this_arg, byte[] their_node_id, uint32_t their_features, uint32_t msg); // void ChannelMessageHandler_handle_accept_channel LDKChannelMessageHandler* this_arg, struct LDKPublicKey their_node_id, struct LDKInitFeatures their_features, const struct LDKAcceptChannel *NONNULL_PTR msg @@ -659,21 +561,6 @@ public class bindings { public static native void ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, byte[] their_node_id, uint32_t msg); // void ChannelMessageHandler_handle_error LDKChannelMessageHandler* this_arg, struct LDKPublicKey their_node_id, const struct LDKErrorMessage *NONNULL_PTR msg public static native void ChannelMessageHandler_handle_error(uint32_t this_arg, byte[] their_node_id, uint32_t msg); - public interface LDKRoutingMessageHandler { - uint32_t handle_node_announcement(uint32_t msg); - uint32_t handle_channel_announcement(uint32_t msg); - uint32_t handle_channel_update(uint32_t msg); - void handle_htlc_fail_channel_update(uint32_t update); - uint32_t[] get_next_channel_announcements(long starting_point, byte batch_amount); - uint32_t[] get_next_node_announcements(byte[] starting_point, byte batch_amount); - void sync_routing_table(byte[] their_node_id, uint32_t init); - uint32_t handle_reply_channel_range(byte[] their_node_id, uint32_t msg); - uint32_t handle_reply_short_channel_ids_end(byte[] their_node_id, uint32_t msg); - uint32_t handle_query_channel_range(byte[] their_node_id, uint32_t msg); - uint32_t handle_query_short_channel_ids(byte[] their_node_id, uint32_t msg); - } - public static native long LDKRoutingMessageHandler_new(LDKRoutingMessageHandler impl, LDKMessageSendEventsProvider MessageSendEventsProvider); - public static native LDKRoutingMessageHandler LDKRoutingMessageHandler_get_obj_from_jcalls(long val); // LDKCResult_boolLightningErrorZ RoutingMessageHandler_handle_node_announcement LDKRoutingMessageHandler* this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg public static native uint32_t RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg); // LDKCResult_boolLightningErrorZ RoutingMessageHandler_handle_channel_announcement LDKRoutingMessageHandler* this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg @@ -696,14 +583,6 @@ public class bindings { public static native uint32_t RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, byte[] their_node_id, uint32_t msg); // LDKCResult_NoneLightningErrorZ RoutingMessageHandler_handle_query_short_channel_ids LDKRoutingMessageHandler* this_arg, struct LDKPublicKey their_node_id, struct LDKQueryShortChannelIds msg public static native uint32_t RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, byte[] their_node_id, uint32_t msg); - public interface LDKSocketDescriptor { - long send_data(byte[] data, boolean resume_read); - void disconnect_socket(); - boolean eq(uint32_t other_arg); - long hash(); - } - public static native long LDKSocketDescriptor_new(LDKSocketDescriptor impl); - public static native LDKSocketDescriptor LDKSocketDescriptor_get_obj_from_jcalls(long val); // uintptr_t SocketDescriptor_send_data LDKSocketDescriptor* this_arg, struct LDKu8slice data, bool resume_read public static native long SocketDescriptor_send_data(uint32_t this_arg, byte[] data, boolean resume_read); // void SocketDescriptor_disconnect_socket LDKSocketDescriptor* this_arg diff --git a/ts/structs/Access.ts b/ts/structs/Access.ts index 897b4b59..1a9e5c26 100644 --- a/ts/structs/Access.ts +++ b/ts/structs/Access.ts @@ -1,36 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class Access extends CommonBase { - final bindings.LDKAccess bindings_instance; - Access(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private Access(bindings.LDKAccess arg) { - super(bindings.LDKAccess_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.Access_free(ptr); } super.finalize(); - } - - public static interface AccessInterface { - Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id); - } - private static class LDKAccessHolder { Access held; } - public static Access new_impl(AccessInterface arg) { - final LDKAccessHolder impl_holder = new LDKAccessHolder(); - impl_holder.held = new Access(new bindings.LDKAccess() { - @Override public uint32_t get_utxo(byte[] genesis_hash, long short_channel_id) { - Result_TxOutAccessErrorZ ret = arg.get_utxo(genesis_hash, short_channel_id); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - }); - return impl_holder.held; - } public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) { uint32_t ret = bindings.Access_get_utxo(this.ptr, genesis_hash, short_channel_id); Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret); diff --git a/ts/structs/BroadcasterInterface.ts b/ts/structs/BroadcasterInterface.ts index cface616..a6f074ba 100644 --- a/ts/structs/BroadcasterInterface.ts +++ b/ts/structs/BroadcasterInterface.ts @@ -1,33 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class BroadcasterInterface extends CommonBase { - final bindings.LDKBroadcasterInterface bindings_instance; - BroadcasterInterface(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private BroadcasterInterface(bindings.LDKBroadcasterInterface arg) { - super(bindings.LDKBroadcasterInterface_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.BroadcasterInterface_free(ptr); } super.finalize(); - } - - public static interface BroadcasterInterfaceInterface { - void broadcast_transaction(byte[] tx); - } - private static class LDKBroadcasterInterfaceHolder { BroadcasterInterface held; } - public static BroadcasterInterface new_impl(BroadcasterInterfaceInterface arg) { - final LDKBroadcasterInterfaceHolder impl_holder = new LDKBroadcasterInterfaceHolder(); - impl_holder.held = new BroadcasterInterface(new bindings.LDKBroadcasterInterface() { - @Override public void broadcast_transaction(byte[] tx) { - arg.broadcast_transaction(tx); - } - }); - return impl_holder.held; - } public void broadcast_transaction(byte[] tx) { bindings.BroadcasterInterface_broadcast_transaction(this.ptr, tx); } diff --git a/ts/structs/ChannelKeys.ts b/ts/structs/ChannelKeys.ts index 39431b4e..600fe24f 100644 --- a/ts/structs/ChannelKeys.ts +++ b/ts/structs/ChannelKeys.ts @@ -1,111 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -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, 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") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.ChannelKeys_free(ptr); } super.finalize(); - } - - public static interface ChannelKeysInterface { - byte[] get_per_commitment_point(long idx); - byte[] release_commitment_secret(long idx); - TwoTuple key_derivation_params(); - Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx); - Result_SignatureNoneZ sign_holder_commitment(HolderCommitmentTransaction commitment_tx); - Result_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions(HolderCommitmentTransaction commitment_tx); - Result_SignatureNoneZ sign_justice_transaction(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc); - Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc); - Result_SignatureNoneZ sign_closing_transaction(byte[] closing_tx); - Result_SignatureNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg); - void ready_channel(ChannelTransactionParameters channel_parameters); - byte[] write(); - } - private static class LDKChannelKeysHolder { ChannelKeys held; } - public static ChannelKeys new_impl(ChannelKeysInterface arg, ChannelPublicKeys pubkeys) { - final LDKChannelKeysHolder impl_holder = new LDKChannelKeysHolder(); - impl_holder.held = new ChannelKeys(new bindings.LDKChannelKeys() { - @Override public byte[] get_per_commitment_point(long idx) { - byte[] ret = arg.get_per_commitment_point(idx); - return ret; - } - @Override public byte[] release_commitment_secret(long idx) { - byte[] ret = arg.release_commitment_secret(idx); - return ret; - } - @Override public uint32_t key_derivation_params() { - TwoTuple ret = arg.key_derivation_params(); - uint32_t result = bindings.C2Tuple_u64u64Z_new(ret.a, ret.b); - return result; - } - @Override public uint32_t sign_counterparty_commitment(uint32_t commitment_tx) { - CommitmentTransaction commitment_tx_hu_conv = new CommitmentTransaction(null, commitment_tx); - Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t sign_holder_commitment(uint32_t commitment_tx) { - HolderCommitmentTransaction commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); - Result_SignatureNoneZ ret = arg.sign_holder_commitment(commitment_tx_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t sign_holder_commitment_htlc_transactions(uint32_t commitment_tx) { - HolderCommitmentTransaction commitment_tx_hu_conv = new HolderCommitmentTransaction(null, commitment_tx); - Result_CVec_SignatureZNoneZ ret = arg.sign_holder_commitment_htlc_transactions(commitment_tx_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t sign_justice_transaction(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, uint32_t htlc) { - HTLCOutputInCommitment htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); - Result_SignatureNoneZ ret = arg.sign_justice_transaction(justice_tx, input, amount, per_commitment_key, htlc_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, uint32_t htlc) { - HTLCOutputInCommitment htlc_hu_conv = new HTLCOutputInCommitment(null, htlc); - Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t sign_closing_transaction(byte[] closing_tx) { - Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t sign_channel_announcement(uint32_t msg) { - UnsignedChannelAnnouncement msg_hu_conv = new UnsignedChannelAnnouncement(null, msg); - Result_SignatureNoneZ ret = arg.sign_channel_announcement(msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public void ready_channel(uint32_t channel_parameters) { - ChannelTransactionParameters channel_parameters_hu_conv = new ChannelTransactionParameters(null, channel_parameters); - arg.ready_channel(channel_parameters_hu_conv); - } - @Override public byte[] write() { - byte[] ret = arg.write(); - return ret; - } - }, pubkeys); - return impl_holder.held; - } public byte[] get_per_commitment_point(long idx) { byte[] ret = bindings.ChannelKeys_get_per_commitment_point(this.ptr, idx); return ret; diff --git a/ts/structs/ChannelMessageHandler.ts b/ts/structs/ChannelMessageHandler.ts index 2d65ad96..71e1a613 100644 --- a/ts/structs/ChannelMessageHandler.ts +++ b/ts/structs/ChannelMessageHandler.ts @@ -1,126 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class ChannelMessageHandler extends CommonBase { - final bindings.LDKChannelMessageHandler bindings_instance; - ChannelMessageHandler(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - 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") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.ChannelMessageHandler_free(ptr); } super.finalize(); - } - - public static interface ChannelMessageHandlerInterface { - void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg); - void handle_accept_channel(byte[] their_node_id, InitFeatures their_features, AcceptChannel msg); - void handle_funding_created(byte[] their_node_id, FundingCreated msg); - void handle_funding_signed(byte[] their_node_id, FundingSigned msg); - void handle_funding_locked(byte[] their_node_id, FundingLocked msg); - void handle_shutdown(byte[] their_node_id, Shutdown msg); - void handle_closing_signed(byte[] their_node_id, ClosingSigned msg); - void handle_update_add_htlc(byte[] their_node_id, UpdateAddHTLC msg); - void handle_update_fulfill_htlc(byte[] their_node_id, UpdateFulfillHTLC msg); - void handle_update_fail_htlc(byte[] their_node_id, UpdateFailHTLC msg); - void handle_update_fail_malformed_htlc(byte[] their_node_id, UpdateFailMalformedHTLC msg); - void handle_commitment_signed(byte[] their_node_id, CommitmentSigned msg); - void handle_revoke_and_ack(byte[] their_node_id, RevokeAndACK msg); - void handle_update_fee(byte[] their_node_id, UpdateFee msg); - void handle_announcement_signatures(byte[] their_node_id, AnnouncementSignatures msg); - void peer_disconnected(byte[] their_node_id, boolean no_connection_possible); - void peer_connected(byte[] their_node_id, Init msg); - void handle_channel_reestablish(byte[] their_node_id, ChannelReestablish msg); - void handle_error(byte[] their_node_id, ErrorMessage msg); - } - private static class LDKChannelMessageHandlerHolder { ChannelMessageHandler held; } - public static ChannelMessageHandler new_impl(ChannelMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) { - final LDKChannelMessageHandlerHolder impl_holder = new LDKChannelMessageHandlerHolder(); - impl_holder.held = new ChannelMessageHandler(new bindings.LDKChannelMessageHandler() { - @Override public void handle_open_channel(byte[] their_node_id, uint32_t their_features, uint32_t msg) { - InitFeatures their_features_hu_conv = new InitFeatures(null, their_features); - OpenChannel msg_hu_conv = new OpenChannel(null, msg); - arg.handle_open_channel(their_node_id, their_features_hu_conv, msg_hu_conv); - } - @Override public void handle_accept_channel(byte[] their_node_id, uint32_t their_features, uint32_t msg) { - InitFeatures their_features_hu_conv = new InitFeatures(null, their_features); - AcceptChannel msg_hu_conv = new AcceptChannel(null, msg); - arg.handle_accept_channel(their_node_id, their_features_hu_conv, msg_hu_conv); - } - @Override public void handle_funding_created(byte[] their_node_id, uint32_t msg) { - FundingCreated msg_hu_conv = new FundingCreated(null, msg); - arg.handle_funding_created(their_node_id, msg_hu_conv); - } - @Override public void handle_funding_signed(byte[] their_node_id, uint32_t msg) { - FundingSigned msg_hu_conv = new FundingSigned(null, msg); - arg.handle_funding_signed(their_node_id, msg_hu_conv); - } - @Override public void handle_funding_locked(byte[] their_node_id, uint32_t msg) { - FundingLocked msg_hu_conv = new FundingLocked(null, msg); - arg.handle_funding_locked(their_node_id, msg_hu_conv); - } - @Override public void handle_shutdown(byte[] their_node_id, uint32_t msg) { - Shutdown msg_hu_conv = new Shutdown(null, msg); - arg.handle_shutdown(their_node_id, msg_hu_conv); - } - @Override public void handle_closing_signed(byte[] their_node_id, uint32_t msg) { - ClosingSigned msg_hu_conv = new ClosingSigned(null, msg); - arg.handle_closing_signed(their_node_id, msg_hu_conv); - } - @Override public void handle_update_add_htlc(byte[] their_node_id, uint32_t msg) { - UpdateAddHTLC msg_hu_conv = new UpdateAddHTLC(null, msg); - arg.handle_update_add_htlc(their_node_id, msg_hu_conv); - } - @Override public void handle_update_fulfill_htlc(byte[] their_node_id, uint32_t msg) { - UpdateFulfillHTLC msg_hu_conv = new UpdateFulfillHTLC(null, msg); - arg.handle_update_fulfill_htlc(their_node_id, msg_hu_conv); - } - @Override public void handle_update_fail_htlc(byte[] their_node_id, uint32_t msg) { - UpdateFailHTLC msg_hu_conv = new UpdateFailHTLC(null, msg); - arg.handle_update_fail_htlc(their_node_id, msg_hu_conv); - } - @Override public void handle_update_fail_malformed_htlc(byte[] their_node_id, uint32_t msg) { - UpdateFailMalformedHTLC msg_hu_conv = new UpdateFailMalformedHTLC(null, msg); - arg.handle_update_fail_malformed_htlc(their_node_id, msg_hu_conv); - } - @Override public void handle_commitment_signed(byte[] their_node_id, uint32_t msg) { - CommitmentSigned msg_hu_conv = new CommitmentSigned(null, msg); - arg.handle_commitment_signed(their_node_id, msg_hu_conv); - } - @Override public void handle_revoke_and_ack(byte[] their_node_id, uint32_t msg) { - RevokeAndACK msg_hu_conv = new RevokeAndACK(null, msg); - arg.handle_revoke_and_ack(their_node_id, msg_hu_conv); - } - @Override public void handle_update_fee(byte[] their_node_id, uint32_t msg) { - UpdateFee msg_hu_conv = new UpdateFee(null, msg); - arg.handle_update_fee(their_node_id, msg_hu_conv); - } - @Override public void handle_announcement_signatures(byte[] their_node_id, uint32_t msg) { - AnnouncementSignatures msg_hu_conv = new AnnouncementSignatures(null, msg); - arg.handle_announcement_signatures(their_node_id, msg_hu_conv); - } - @Override public void peer_disconnected(byte[] their_node_id, boolean no_connection_possible) { - arg.peer_disconnected(their_node_id, no_connection_possible); - } - @Override public void peer_connected(byte[] their_node_id, uint32_t msg) { - Init msg_hu_conv = new Init(null, msg); - arg.peer_connected(their_node_id, msg_hu_conv); - } - @Override public void handle_channel_reestablish(byte[] their_node_id, uint32_t msg) { - ChannelReestablish msg_hu_conv = new ChannelReestablish(null, msg); - arg.handle_channel_reestablish(their_node_id, msg_hu_conv); - } - @Override public void handle_error(byte[] their_node_id, uint32_t msg) { - ErrorMessage msg_hu_conv = new ErrorMessage(null, msg); - arg.handle_error(their_node_id, msg_hu_conv); - } - }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance); - return impl_holder.held; - } public void handle_open_channel(byte[] their_node_id, InitFeatures their_features, OpenChannel msg) { bindings.ChannelMessageHandler_handle_open_channel(this.ptr, their_node_id, their_features == null ? 0 : their_features.ptr & ~1, msg == null ? 0 : msg.ptr & ~1); this.ptrs_to.add(their_features); diff --git a/ts/structs/EventsProvider.ts b/ts/structs/EventsProvider.ts index 02b0072b..5c7b48f4 100644 --- a/ts/structs/EventsProvider.ts +++ b/ts/structs/EventsProvider.ts @@ -1,36 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class EventsProvider extends CommonBase { - final bindings.LDKEventsProvider bindings_instance; - EventsProvider(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private EventsProvider(bindings.LDKEventsProvider arg) { - super(bindings.LDKEventsProvider_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.EventsProvider_free(ptr); } super.finalize(); - } - - public static interface EventsProviderInterface { - Event[] get_and_clear_pending_events(); - } - private static class LDKEventsProviderHolder { EventsProvider held; } - public static EventsProvider new_impl(EventsProviderInterface arg) { - final LDKEventsProviderHolder impl_holder = new LDKEventsProviderHolder(); - impl_holder.held = new EventsProvider(new bindings.LDKEventsProvider() { - @Override public uint32_t[] get_and_clear_pending_events() { - Event[] ret = arg.get_and_clear_pending_events(); - uint32_t[] result = (uint32_t[])Arrays.stream(ret).map(arr_conv_7 -> arr_conv_7.ptr).toArray(); - /* TODO 2 Event */; - return result; - } - }); - return impl_holder.held; - } public Event[] get_and_clear_pending_events() { uint32_t[] ret = bindings.EventsProvider_get_and_clear_pending_events(this.ptr); Event[] arr_conv_7_arr = new Event[ret.length]; diff --git a/ts/structs/FeeEstimator.ts b/ts/structs/FeeEstimator.ts index 27368449..b392ee7d 100644 --- a/ts/structs/FeeEstimator.ts +++ b/ts/structs/FeeEstimator.ts @@ -1,34 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class FeeEstimator extends CommonBase { - final bindings.LDKFeeEstimator bindings_instance; - FeeEstimator(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private FeeEstimator(bindings.LDKFeeEstimator arg) { - super(bindings.LDKFeeEstimator_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.FeeEstimator_free(ptr); } super.finalize(); - } - - public static interface FeeEstimatorInterface { - int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target); - } - private static class LDKFeeEstimatorHolder { FeeEstimator held; } - public static FeeEstimator new_impl(FeeEstimatorInterface arg) { - final LDKFeeEstimatorHolder impl_holder = new LDKFeeEstimatorHolder(); - impl_holder.held = new FeeEstimator(new bindings.LDKFeeEstimator() { - @Override public int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target) { - int ret = arg.get_est_sat_per_1000_weight(confirmation_target); - return ret; - } - }); - return impl_holder.held; - } public int get_est_sat_per_1000_weight(LDKConfirmationTarget confirmation_target) { int ret = bindings.FeeEstimator_get_est_sat_per_1000_weight(this.ptr, confirmation_target); return ret; diff --git a/ts/structs/Filter.ts b/ts/structs/Filter.ts index 08596b67..1e83264a 100644 --- a/ts/structs/Filter.ts +++ b/ts/structs/Filter.ts @@ -1,38 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class Filter extends CommonBase { - final bindings.LDKFilter bindings_instance; - Filter(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private Filter(bindings.LDKFilter arg) { - super(bindings.LDKFilter_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.Filter_free(ptr); } super.finalize(); - } - - public static interface FilterInterface { - void register_tx(byte[] txid, byte[] script_pubkey); - void register_output(OutPoint outpoint, byte[] script_pubkey); - } - private static class LDKFilterHolder { Filter held; } - public static Filter new_impl(FilterInterface arg) { - final LDKFilterHolder impl_holder = new LDKFilterHolder(); - impl_holder.held = new Filter(new bindings.LDKFilter() { - @Override public void register_tx(byte[] txid, byte[] script_pubkey) { - arg.register_tx(txid, script_pubkey); - } - @Override public void register_output(uint32_t outpoint, byte[] script_pubkey) { - OutPoint outpoint_hu_conv = new OutPoint(null, outpoint); - arg.register_output(outpoint_hu_conv, script_pubkey); - } - }); - return impl_holder.held; - } public void register_tx(byte[] txid, byte[] script_pubkey) { bindings.Filter_register_tx(this.ptr, txid, script_pubkey); } diff --git a/ts/structs/KeysInterface.ts b/ts/structs/KeysInterface.ts index b4e1b71d..eebd78e0 100644 --- a/ts/structs/KeysInterface.ts +++ b/ts/structs/KeysInterface.ts @@ -1,63 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class KeysInterface extends CommonBase { - final bindings.LDKKeysInterface bindings_instance; - KeysInterface(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private KeysInterface(bindings.LDKKeysInterface arg) { - super(bindings.LDKKeysInterface_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.KeysInterface_free(ptr); } super.finalize(); - } - - public static interface KeysInterfaceInterface { - byte[] get_node_secret(); - byte[] get_destination_script(); - byte[] get_shutdown_pubkey(); - ChannelKeys get_channel_keys(boolean inbound, long channel_value_satoshis); - byte[] get_secure_random_bytes(); - Result_ChanKeySignerDecodeErrorZ read_chan_signer(byte[] reader); - } - private static class LDKKeysInterfaceHolder { KeysInterface held; } - public static KeysInterface new_impl(KeysInterfaceInterface arg) { - final LDKKeysInterfaceHolder impl_holder = new LDKKeysInterfaceHolder(); - impl_holder.held = new KeysInterface(new bindings.LDKKeysInterface() { - @Override public byte[] get_node_secret() { - byte[] ret = arg.get_node_secret(); - return ret; - } - @Override public byte[] get_destination_script() { - byte[] ret = arg.get_destination_script(); - return ret; - } - @Override public byte[] get_shutdown_pubkey() { - byte[] ret = arg.get_shutdown_pubkey(); - return ret; - } - @Override public uint32_t get_channel_keys(boolean inbound, long channel_value_satoshis) { - ChannelKeys ret = arg.get_channel_keys(inbound, channel_value_satoshis); - uint32_t result = ret == null ? 0 : ret.ptr; - impl_holder.held.ptrs_to.add(ret); - return result; - } - @Override public byte[] get_secure_random_bytes() { - byte[] ret = arg.get_secure_random_bytes(); - return ret; - } - @Override public uint32_t read_chan_signer(byte[] reader) { - Result_ChanKeySignerDecodeErrorZ ret = arg.read_chan_signer(reader); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - }); - return impl_holder.held; - } public byte[] get_node_secret() { byte[] ret = bindings.KeysInterface_get_node_secret(this.ptr); return ret; diff --git a/ts/structs/Logger.ts b/ts/structs/Logger.ts index 9376fb5a..5c34318c 100644 --- a/ts/structs/Logger.ts +++ b/ts/structs/Logger.ts @@ -1,31 +1 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class Logger extends CommonBase { - final bindings.LDKLogger bindings_instance; - Logger(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private Logger(bindings.LDKLogger arg) { - super(bindings.LDKLogger_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.Logger_free(ptr); } super.finalize(); - } - - public static interface LoggerInterface { - void log(String record); - } - private static class LDKLoggerHolder { Logger held; } - public static Logger new_impl(LoggerInterface arg) { - final LDKLoggerHolder impl_holder = new LDKLoggerHolder(); - impl_holder.held = new Logger(new bindings.LDKLogger() { - @Override public void log(String record) { - arg.log(record); - } - }); - return impl_holder.held; - } } diff --git a/ts/structs/MessageSendEventsProvider.ts b/ts/structs/MessageSendEventsProvider.ts index a787a1ba..844e5cad 100644 --- a/ts/structs/MessageSendEventsProvider.ts +++ b/ts/structs/MessageSendEventsProvider.ts @@ -1,36 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class MessageSendEventsProvider extends CommonBase { - final bindings.LDKMessageSendEventsProvider bindings_instance; - MessageSendEventsProvider(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private MessageSendEventsProvider(bindings.LDKMessageSendEventsProvider arg) { - super(bindings.LDKMessageSendEventsProvider_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.MessageSendEventsProvider_free(ptr); } super.finalize(); - } - - public static interface MessageSendEventsProviderInterface { - MessageSendEvent[] get_and_clear_pending_msg_events(); - } - private static class LDKMessageSendEventsProviderHolder { MessageSendEventsProvider held; } - public static MessageSendEventsProvider new_impl(MessageSendEventsProviderInterface arg) { - final LDKMessageSendEventsProviderHolder impl_holder = new LDKMessageSendEventsProviderHolder(); - impl_holder.held = new MessageSendEventsProvider(new bindings.LDKMessageSendEventsProvider() { - @Override public uint32_t[] get_and_clear_pending_msg_events() { - MessageSendEvent[] ret = arg.get_and_clear_pending_msg_events(); - uint32_t[] result = (uint32_t[])Arrays.stream(ret).map(arr_conv_18 -> arr_conv_18.ptr).toArray(); - /* TODO 2 MessageSendEvent */; - return result; - } - }); - return impl_holder.held; - } public MessageSendEvent[] get_and_clear_pending_msg_events() { uint32_t[] ret = bindings.MessageSendEventsProvider_get_and_clear_pending_msg_events(this.ptr); MessageSendEvent[] arr_conv_18_arr = new MessageSendEvent[ret.length]; diff --git a/ts/structs/Persist.ts b/ts/structs/Persist.ts index 9b1dde6e..f55f4cf5 100644 --- a/ts/structs/Persist.ts +++ b/ts/structs/Persist.ts @@ -1,48 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class Persist extends CommonBase { - final bindings.LDKPersist bindings_instance; - Persist(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private Persist(bindings.LDKPersist arg) { - super(bindings.LDKPersist_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.Persist_free(ptr); } super.finalize(); - } - - public static interface PersistInterface { - Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data); - Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data); - } - private static class LDKPersistHolder { Persist held; } - public static Persist new_impl(PersistInterface arg) { - final LDKPersistHolder impl_holder = new LDKPersistHolder(); - impl_holder.held = new Persist(new bindings.LDKPersist() { - @Override public uint32_t persist_new_channel(uint32_t id, uint32_t data) { - OutPoint id_hu_conv = new OutPoint(null, id); - ChannelMonitor data_hu_conv = new ChannelMonitor(null, data); - Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(id_hu_conv, data_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t update_persisted_channel(uint32_t id, uint32_t update, uint32_t data) { - OutPoint id_hu_conv = new OutPoint(null, id); - ChannelMonitorUpdate update_hu_conv = new ChannelMonitorUpdate(null, update); - ChannelMonitor data_hu_conv = new ChannelMonitor(null, data); - Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(id_hu_conv, update_hu_conv, data_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - }); - return impl_holder.held; - } public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data) { uint32_t ret = bindings.Persist_persist_new_channel(this.ptr, id == null ? 0 : id.ptr & ~1, data == null ? 0 : data.ptr & ~1); Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret); diff --git a/ts/structs/RoutingMessageHandler.ts b/ts/structs/RoutingMessageHandler.ts index 84b9673a..12e7a3cf 100644 --- a/ts/structs/RoutingMessageHandler.ts +++ b/ts/structs/RoutingMessageHandler.ts @@ -1,110 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class RoutingMessageHandler extends CommonBase { - final bindings.LDKRoutingMessageHandler bindings_instance; - RoutingMessageHandler(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private RoutingMessageHandler(bindings.LDKRoutingMessageHandler arg, bindings.LDKMessageSendEventsProvider MessageSendEventsProvider) { - super(bindings.LDKRoutingMessageHandler_new(arg, MessageSendEventsProvider)); - this.ptrs_to.add(arg); - this.ptrs_to.add(MessageSendEventsProvider); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.RoutingMessageHandler_free(ptr); } super.finalize(); - } - - public static interface RoutingMessageHandlerInterface { - Result_boolLightningErrorZ handle_node_announcement(NodeAnnouncement msg); - Result_boolLightningErrorZ handle_channel_announcement(ChannelAnnouncement msg); - Result_boolLightningErrorZ handle_channel_update(ChannelUpdate msg); - void handle_htlc_fail_channel_update(HTLCFailChannelUpdate update); - ThreeTuple[] get_next_channel_announcements(long starting_point, byte batch_amount); - NodeAnnouncement[] get_next_node_announcements(byte[] starting_point, byte batch_amount); - void sync_routing_table(byte[] their_node_id, Init init); - Result_NoneLightningErrorZ handle_reply_channel_range(byte[] their_node_id, ReplyChannelRange msg); - Result_NoneLightningErrorZ handle_reply_short_channel_ids_end(byte[] their_node_id, ReplyShortChannelIdsEnd msg); - Result_NoneLightningErrorZ handle_query_channel_range(byte[] their_node_id, QueryChannelRange msg); - Result_NoneLightningErrorZ handle_query_short_channel_ids(byte[] their_node_id, QueryShortChannelIds msg); - } - private static class LDKRoutingMessageHandlerHolder { RoutingMessageHandler held; } - public static RoutingMessageHandler new_impl(RoutingMessageHandlerInterface arg, MessageSendEventsProvider.MessageSendEventsProviderInterface MessageSendEventsProvider_impl) { - final LDKRoutingMessageHandlerHolder impl_holder = new LDKRoutingMessageHandlerHolder(); - impl_holder.held = new RoutingMessageHandler(new bindings.LDKRoutingMessageHandler() { - @Override public uint32_t handle_node_announcement(uint32_t msg) { - NodeAnnouncement msg_hu_conv = new NodeAnnouncement(null, msg); - Result_boolLightningErrorZ ret = arg.handle_node_announcement(msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t handle_channel_announcement(uint32_t msg) { - ChannelAnnouncement msg_hu_conv = new ChannelAnnouncement(null, msg); - Result_boolLightningErrorZ ret = arg.handle_channel_announcement(msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t handle_channel_update(uint32_t msg) { - ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg); - Result_boolLightningErrorZ ret = arg.handle_channel_update(msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public void handle_htlc_fail_channel_update(uint32_t update) { - HTLCFailChannelUpdate update_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(update); - arg.handle_htlc_fail_channel_update(update_hu_conv); - } - @Override public uint32_t[] get_next_channel_announcements(long starting_point, byte batch_amount) { - ThreeTuple[] ret = arg.get_next_channel_announcements(starting_point, batch_amount); - uint32_t[] result = (uint32_t[])Arrays.stream(ret).map(arr_conv_63 -> bindings.C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(arr_conv_63.a == null ? 0 : arr_conv_63.a.ptr & ~1/*XXX: this.ptrs_to.add(arr_conv_63_a)*/, arr_conv_63.b == null ? 0 : arr_conv_63.b.ptr & ~1/*XXX: this.ptrs_to.add(arr_conv_63_b)*/, arr_conv_63.c == null ? 0 : arr_conv_63.c.ptr & ~1/*XXX: this.ptrs_to.add(arr_conv_63_c)*/)).toArray(); - /* TODO 2 ThreeTuple */; - return result; - } - @Override public uint32_t[] get_next_node_announcements(byte[] starting_point, byte batch_amount) { - NodeAnnouncement[] ret = arg.get_next_node_announcements(starting_point, batch_amount); - uint32_t[] result = (uint32_t[])Arrays.stream(ret).map(arr_conv_18 -> arr_conv_18 == null ? 0 : arr_conv_18.ptr & ~1).toArray(); - /* TODO 2 NodeAnnouncement */; - return result; - } - @Override public void sync_routing_table(byte[] their_node_id, uint32_t init) { - Init init_hu_conv = new Init(null, init); - arg.sync_routing_table(their_node_id, init_hu_conv); - } - @Override public uint32_t handle_reply_channel_range(byte[] their_node_id, uint32_t msg) { - ReplyChannelRange msg_hu_conv = new ReplyChannelRange(null, msg); - Result_NoneLightningErrorZ ret = arg.handle_reply_channel_range(their_node_id, msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t handle_reply_short_channel_ids_end(byte[] their_node_id, uint32_t msg) { - ReplyShortChannelIdsEnd msg_hu_conv = new ReplyShortChannelIdsEnd(null, msg); - Result_NoneLightningErrorZ ret = arg.handle_reply_short_channel_ids_end(their_node_id, msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t handle_query_channel_range(byte[] their_node_id, uint32_t msg) { - QueryChannelRange msg_hu_conv = new QueryChannelRange(null, msg); - Result_NoneLightningErrorZ ret = arg.handle_query_channel_range(their_node_id, msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t handle_query_short_channel_ids(byte[] their_node_id, uint32_t msg) { - QueryShortChannelIds msg_hu_conv = new QueryShortChannelIds(null, msg); - Result_NoneLightningErrorZ ret = arg.handle_query_short_channel_ids(their_node_id, msg_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - }, MessageSendEventsProvider.new_impl(MessageSendEventsProvider_impl).bindings_instance); - return impl_holder.held; - } public Result_boolLightningErrorZ handle_node_announcement(NodeAnnouncement msg) { uint32_t ret = bindings.RoutingMessageHandler_handle_node_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1); Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret); diff --git a/ts/structs/SocketDescriptor.ts b/ts/structs/SocketDescriptor.ts index dcced074..cb5a21ed 100644 --- a/ts/structs/SocketDescriptor.ts +++ b/ts/structs/SocketDescriptor.ts @@ -1,50 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class SocketDescriptor extends CommonBase { - final bindings.LDKSocketDescriptor bindings_instance; - SocketDescriptor(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private SocketDescriptor(bindings.LDKSocketDescriptor arg) { - super(bindings.LDKSocketDescriptor_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.SocketDescriptor_free(ptr); } super.finalize(); - } - - public static interface SocketDescriptorInterface { - long send_data(byte[] data, boolean resume_read); - void disconnect_socket(); - boolean eq(SocketDescriptor other_arg); - long hash(); - } - private static class LDKSocketDescriptorHolder { SocketDescriptor held; } - public static SocketDescriptor new_impl(SocketDescriptorInterface arg) { - final LDKSocketDescriptorHolder impl_holder = new LDKSocketDescriptorHolder(); - impl_holder.held = new SocketDescriptor(new bindings.LDKSocketDescriptor() { - @Override public long send_data(byte[] data, boolean resume_read) { - long ret = arg.send_data(data, resume_read); - return ret; - } - @Override public void disconnect_socket() { - arg.disconnect_socket(); - } - @Override public boolean eq(uint32_t other_arg) { - SocketDescriptor ret_hu_conv = new SocketDescriptor(null, other_arg); - ret_hu_conv.ptrs_to.add(this); - boolean ret = arg.eq(ret_hu_conv); - return ret; - } - @Override public long hash() { - long ret = arg.hash(); - return ret; - } - }); - return impl_holder.held; - } public long send_data(byte[] data, boolean resume_read) { long ret = bindings.SocketDescriptor_send_data(this.ptr, data, resume_read); return ret; diff --git a/ts/structs/Watch.ts b/ts/structs/Watch.ts index 931fc726..bf0fd550 100644 --- a/ts/structs/Watch.ts +++ b/ts/structs/Watch.ts @@ -1,54 +1,3 @@ - -import CommonBase from './CommonBase'; -import * as bindings from '../bindings' // TODO: figure out location - -public class Watch extends CommonBase { - final bindings.LDKWatch bindings_instance; - Watch(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private Watch(bindings.LDKWatch arg) { - super(bindings.LDKWatch_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.Watch_free(ptr); } super.finalize(); - } - - public static interface WatchInterface { - Result_NoneChannelMonitorUpdateErrZ watch_channel(OutPoint funding_txo, ChannelMonitor monitor); - Result_NoneChannelMonitorUpdateErrZ update_channel(OutPoint funding_txo, ChannelMonitorUpdate update); - MonitorEvent[] release_pending_monitor_events(); - } - private static class LDKWatchHolder { Watch held; } - public static Watch new_impl(WatchInterface arg) { - final LDKWatchHolder impl_holder = new LDKWatchHolder(); - impl_holder.held = new Watch(new bindings.LDKWatch() { - @Override public uint32_t watch_channel(uint32_t funding_txo, uint32_t monitor) { - OutPoint funding_txo_hu_conv = new OutPoint(null, funding_txo); - ChannelMonitor monitor_hu_conv = new ChannelMonitor(null, monitor); - Result_NoneChannelMonitorUpdateErrZ ret = arg.watch_channel(funding_txo_hu_conv, monitor_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t update_channel(uint32_t funding_txo, uint32_t update) { - OutPoint funding_txo_hu_conv = new OutPoint(null, funding_txo); - ChannelMonitorUpdate update_hu_conv = new ChannelMonitorUpdate(null, update); - Result_NoneChannelMonitorUpdateErrZ ret = arg.update_channel(funding_txo_hu_conv, update_hu_conv); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; - return result; - } - @Override public uint32_t[] release_pending_monitor_events() { - MonitorEvent[] ret = arg.release_pending_monitor_events(); - uint32_t[] result = (uint32_t[])Arrays.stream(ret).map(arr_conv_14 -> arr_conv_14 == null ? 0 : arr_conv_14.ptr & ~1).toArray(); - /* TODO 2 MonitorEvent */; - return result; - } - }); - return impl_holder.held; - } public Result_NoneChannelMonitorUpdateErrZ watch_channel(OutPoint funding_txo, ChannelMonitor monitor) { uint32_t ret = bindings.Watch_watch_channel(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, monitor == null ? 0 : monitor.ptr & ~1); Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret); -- 2.30.2