+long __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
+ LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
+ *res_ptr = LDKAccess_init(o);
+ return (long)res_ptr;
+}
+uint32_t __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
+ LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
+ unsigned char genesis_hash_arr[32];
+ CHECK(*((uint32_t*)genesis_hash) == 32);
+ memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
+ unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
+ LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
+ *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
+ return (uint64_t)ret_conv;
+}
+
+typedef struct LDKListen_JCalls {
+ atomic_size_t refcnt;
+ uint32_t block_connected_meth;
+ uint32_t block_disconnected_meth;
+} LDKListen_JCalls;
+static void LDKListen_JCalls_free(void* this_arg) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->block_connected_meth);
+ js_free(j_calls->block_disconnected_meth);
+ FREE(j_calls);
+ }
+}
+void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
+ LDKu8slice block_var = block;
+ int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
+ js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
+}
+void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
+ int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(header_arr + 4), *header, 80);
+ js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
+}
+static void* LDKListen_JCalls_clone(const void* this_arg) {
+ LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
+ LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKListen ret = {
+ .this_arg = (void*) calls,
+ .block_connected = block_connected_LDKListen_jcall,
+ .block_disconnected = block_disconnected_LDKListen_jcall,
+ .free = LDKListen_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
+ LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
+ *res_ptr = LDKListen_init(o);
+ return (long)res_ptr;
+}
+void __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
+ LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+ LDKu8slice block_ref;
+ block_ref.datalen = *((uint32_t*)block);
+ block_ref.data = (int8_t*)(block + 4);
+ (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
+}
+
+void __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
+ LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
+ unsigned char header_arr[80];
+ CHECK(*((uint32_t*)header) == 80);
+ memcpy(header_arr, (uint8_t*)(header + 4), 80);
+ unsigned char (*header_ref)[80] = &header_arr;
+ (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
+}
+
+typedef struct LDKConfirm_JCalls {
+ atomic_size_t refcnt;
+ uint32_t transactions_confirmed_meth;
+ uint32_t transaction_unconfirmed_meth;
+ uint32_t best_block_updated_meth;
+ uint32_t get_relevant_txids_meth;
+} LDKConfirm_JCalls;
+static void LDKConfirm_JCalls_free(void* this_arg) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->transactions_confirmed_meth);
+ js_free(j_calls->transaction_unconfirmed_meth);
+ js_free(j_calls->best_block_updated_meth);
+ js_free(j_calls->get_relevant_txids_meth);
+ FREE(j_calls);
+ }
+}
+void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(header_arr + 4), *header, 80);
+ LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
+ uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
+ for (size_t e = 0; e < txdata_var.datalen; e++) {
+ LDKC2Tuple_usizeTransactionZ* txdata_conv_30_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
+ *txdata_conv_30_ref = txdata_var.data[e];
+ txdata_arr_ptr[e] = (uint64_t)txdata_conv_30_ref;
+ }
+ FREE(txdata_var.data);
+ js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
+}
+void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
+ js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
+}
+void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(header_arr + 4), *header, 80);
+ js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
+}
+LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
+ LDKCVec_TxidZ ret_constr;
+ ret_constr.datalen = *((uint32_t*)ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
+ else
+ ret_constr.data = NULL;
+ int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
+ for (size_t m = 0; m < ret_constr.datalen; m++) {
+ int8_tArray ret_conv_12 = ret_vals[m];
+ LDKThirtyTwoBytes ret_conv_12_ref;
+ CHECK(*((uint32_t*)ret_conv_12) == 32);
+ memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
+ ret_constr.data[m] = ret_conv_12_ref;
+ }
+ return ret_constr;
+}
+static void* LDKConfirm_JCalls_clone(const void* this_arg) {
+ LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
+ LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKConfirm ret = {
+ .this_arg = (void*) calls,
+ .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
+ .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
+ .best_block_updated = best_block_updated_LDKConfirm_jcall,
+ .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
+ .free = LDKConfirm_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
+ LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
+ *res_ptr = LDKConfirm_init(o);
+ return (long)res_ptr;
+}
+void __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
+ LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+ unsigned char header_arr[80];
+ CHECK(*((uint32_t*)header) == 80);
+ memcpy(header_arr, (uint8_t*)(header + 4), 80);
+ unsigned char (*header_ref)[80] = &header_arr;
+ LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
+ txdata_constr.datalen = *((uint32_t*)txdata);
+ if (txdata_constr.datalen > 0)
+ txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
+ else
+ txdata_constr.data = NULL;
+ uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
+ for (size_t e = 0; e < txdata_constr.datalen; e++) {
+ uint32_t txdata_conv_30 = txdata_vals[e];
+ LDKC2Tuple_usizeTransactionZ txdata_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1);
+ txdata_conv_30_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_30) & ~1));
+ txdata_constr.data[e] = txdata_conv_30_conv;
+ }
+ (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
+}
+
+void __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
+ LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+ unsigned char txid_arr[32];
+ CHECK(*((uint32_t*)txid) == 32);
+ memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
+ unsigned char (*txid_ref)[32] = &txid_arr;
+ (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
+}
+
+void __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
+ LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+ unsigned char header_arr[80];
+ CHECK(*((uint32_t*)header) == 80);
+ memcpy(header_arr, (uint8_t*)(header + 4), 80);
+ unsigned char (*header_ref)[80] = &header_arr;
+ (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
+}
+
+ptrArray __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
+ LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
+ LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
+ ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+ int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
+ for (size_t m = 0; m < ret_var.datalen; m++) {
+ int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
+ ret_arr_ptr[m] = ret_conv_12_arr;
+ }
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKFilter_JCalls {
+ atomic_size_t refcnt;
+ uint32_t register_tx_meth;
+ uint32_t register_output_meth;
+} LDKFilter_JCalls;
+static void LDKFilter_JCalls_free(void* this_arg) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->register_tx_meth);
+ js_free(j_calls->register_output_meth);
+ FREE(j_calls);
+ }
+}
+void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
+ LDKu8slice script_pubkey_var = script_pubkey;
+ int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
+ js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
+}
+LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ LDKWatchedOutput output_var = output;
+ CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t output_ref = (uint64_t)output_var.inner;
+ if (output_var.is_owned) {
+ output_ref |= 1;
+ }
+ LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)js_invoke_function_1(j_calls->register_output_meth, output_ref);
+ LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
+ ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
+ return 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 (/*TODO: JS Object Reference */void* o) {
+ LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKFilter ret = {
+ .this_arg = (void*) calls,
+ .register_tx = register_tx_LDKFilter_jcall,
+ .register_output = register_output_LDKFilter_jcall,
+ .free = LDKFilter_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
+ LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
+ *res_ptr = LDKFilter_init(o);
+ return (long)res_ptr;
+}
+void __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
+ LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
+ unsigned char txid_arr[32];
+ CHECK(*((uint32_t*)txid) == 32);
+ memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
+ unsigned char (*txid_ref)[32] = &txid_arr;
+ LDKu8slice script_pubkey_ref;
+ script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
+ script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
+ (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
+ LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
+ LDKWatchedOutput output_conv;
+ output_conv.inner = (void*)(output & (~1));
+ output_conv.is_owned = (output & 1) || (output == 0);
+ output_conv = WatchedOutput_clone(&output_conv);
+ LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
+ *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
+ uint64_t ret_ref = (uint64_t)ret_copy;
+ return ret_ref;
+}
+
+typedef struct LDKPersist_JCalls {
+ atomic_size_t refcnt;
+ uint32_t persist_new_channel_meth;
+ uint32_t update_persisted_channel_meth;
+} LDKPersist_JCalls;
+static void LDKPersist_JCalls_free(void* this_arg) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->persist_new_channel_meth);
+ js_free(j_calls->update_persisted_channel_meth);
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ LDKOutPoint id_var = id;
+ CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t id_ref = (uint64_t)id_var.inner;
+ if (id_var.is_owned) {
+ id_ref |= 1;
+ }
+ LDKChannelMonitor data_var = *data;
+ data_var = ChannelMonitor_clone(data);
+ CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t data_ref = (uint64_t)data_var.inner;
+ if (data_var.is_owned) {
+ data_ref |= 1;
+ }
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
+ LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
+ LDKOutPoint id_var = id;
+ CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t id_ref = (uint64_t)id_var.inner;
+ if (id_var.is_owned) {
+ id_ref |= 1;
+ }
+ LDKChannelMonitorUpdate update_var = *update;
+ update_var = ChannelMonitorUpdate_clone(update);
+ CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t update_ref = (uint64_t)update_var.inner;
+ if (update_var.is_owned) {
+ update_ref |= 1;
+ }
+ LDKChannelMonitor data_var = *data;
+ data_var = ChannelMonitor_clone(data);
+ CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t data_ref = (uint64_t)data_var.inner;
+ if (data_var.is_owned) {
+ data_ref |= 1;
+ }
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+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 (/*TODO: JS Object Reference */void* o) {
+ LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKPersist ret = {
+ .this_arg = (void*) calls,
+ .persist_new_channel = persist_new_channel_LDKPersist_jcall,
+ .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
+ .free = LDKPersist_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
+ LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
+ *res_ptr = LDKPersist_init(o);
+ return (long)res_ptr;
+}
+uint32_t __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
+ LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
+ LDKOutPoint id_conv;
+ id_conv.inner = (void*)(id & (~1));
+ id_conv.is_owned = (id & 1) || (id == 0);
+ id_conv = OutPoint_clone(&id_conv);
+ LDKChannelMonitor data_conv;
+ data_conv.inner = (void*)(data & (~1));
+ data_conv.is_owned = false;
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
+ LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
+ LDKOutPoint id_conv;
+ id_conv.inner = (void*)(id & (~1));
+ id_conv.is_owned = (id & 1) || (id == 0);
+ id_conv = OutPoint_clone(&id_conv);
+ LDKChannelMonitorUpdate update_conv;
+ update_conv.inner = (void*)(update & (~1));
+ update_conv.is_owned = false;
+ LDKChannelMonitor data_conv;
+ data_conv.inner = (void*)(data & (~1));
+ data_conv.is_owned = false;
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
+ return (uint64_t)ret_conv;
+}
+
+typedef struct LDKChannelMessageHandler_JCalls {
+ atomic_size_t refcnt;
+ LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
+ uint32_t handle_open_channel_meth;
+ uint32_t handle_accept_channel_meth;
+ uint32_t handle_funding_created_meth;
+ uint32_t handle_funding_signed_meth;
+ uint32_t handle_funding_locked_meth;
+ uint32_t handle_shutdown_meth;
+ uint32_t handle_closing_signed_meth;
+ uint32_t handle_update_add_htlc_meth;
+ uint32_t handle_update_fulfill_htlc_meth;
+ uint32_t handle_update_fail_htlc_meth;
+ uint32_t handle_update_fail_malformed_htlc_meth;
+ uint32_t handle_commitment_signed_meth;
+ uint32_t handle_revoke_and_ack_meth;
+ uint32_t handle_update_fee_meth;
+ uint32_t handle_announcement_signatures_meth;
+ uint32_t peer_disconnected_meth;
+ uint32_t peer_connected_meth;
+ uint32_t handle_channel_reestablish_meth;
+ uint32_t handle_channel_update_meth;
+ uint32_t handle_error_meth;
+} LDKChannelMessageHandler_JCalls;
+static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->handle_open_channel_meth);
+ js_free(j_calls->handle_accept_channel_meth);
+ js_free(j_calls->handle_funding_created_meth);
+ js_free(j_calls->handle_funding_signed_meth);
+ js_free(j_calls->handle_funding_locked_meth);
+ js_free(j_calls->handle_shutdown_meth);
+ js_free(j_calls->handle_closing_signed_meth);
+ js_free(j_calls->handle_update_add_htlc_meth);
+ js_free(j_calls->handle_update_fulfill_htlc_meth);
+ js_free(j_calls->handle_update_fail_htlc_meth);
+ js_free(j_calls->handle_update_fail_malformed_htlc_meth);
+ js_free(j_calls->handle_commitment_signed_meth);
+ js_free(j_calls->handle_revoke_and_ack_meth);
+ js_free(j_calls->handle_update_fee_meth);
+ js_free(j_calls->handle_announcement_signatures_meth);
+ js_free(j_calls->peer_disconnected_meth);
+ js_free(j_calls->peer_connected_meth);
+ js_free(j_calls->handle_channel_reestablish_meth);
+ js_free(j_calls->handle_channel_update_meth);
+ js_free(j_calls->handle_error_meth);
+ FREE(j_calls);
+ }
+}
+void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKInitFeatures their_features_var = their_features;
+ CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKOpenChannel msg_var = *msg;
+ msg_var = OpenChannel_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
+}
+void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKInitFeatures their_features_var = their_features;
+ CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKAcceptChannel msg_var = *msg;
+ msg_var = AcceptChannel_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
+}
+void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKFundingCreated msg_var = *msg;
+ msg_var = FundingCreated_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
+}
+void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKFundingSigned msg_var = *msg;
+ msg_var = FundingSigned_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
+}
+void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKFundingLocked msg_var = *msg;
+ msg_var = FundingLocked_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
+}
+void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKInitFeatures their_features_var = *their_features;
+ their_features_var = InitFeatures_clone(their_features);
+ CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t their_features_ref = (uint64_t)their_features_var.inner;
+ if (their_features_var.is_owned) {
+ their_features_ref |= 1;
+ }
+ LDKShutdown msg_var = *msg;
+ msg_var = Shutdown_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
+}
+void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKClosingSigned msg_var = *msg;
+ msg_var = ClosingSigned_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKUpdateAddHTLC msg_var = *msg;
+ msg_var = UpdateAddHTLC_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKUpdateFulfillHTLC msg_var = *msg;
+ msg_var = UpdateFulfillHTLC_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKUpdateFailHTLC msg_var = *msg;
+ msg_var = UpdateFailHTLC_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKUpdateFailMalformedHTLC msg_var = *msg;
+ msg_var = UpdateFailMalformedHTLC_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
+}
+void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKCommitmentSigned msg_var = *msg;
+ msg_var = CommitmentSigned_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
+}
+void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKRevokeAndACK msg_var = *msg;
+ msg_var = RevokeAndACK_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
+}
+void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKUpdateFee msg_var = *msg;
+ msg_var = UpdateFee_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
+}
+void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKAnnouncementSignatures msg_var = *msg;
+ msg_var = AnnouncementSignatures_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
+}
+void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
+}
+void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKInit msg_var = *msg;
+ msg_var = Init_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
+}
+void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKChannelReestablish msg_var = *msg;
+ msg_var = ChannelReestablish_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
+}
+void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKChannelUpdate msg_var = *msg;
+ msg_var = ChannelUpdate_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
+}
+void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
+ LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKErrorMessage msg_var = *msg;
+ msg_var = ErrorMessage_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
+}
+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 (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
+ LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKChannelMessageHandler ret = {
+ .this_arg = (void*) calls,
+ .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
+ .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
+ .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
+ .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
+ .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
+ .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
+ .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
+ .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
+ .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
+ .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
+ .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
+ .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
+ .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
+ .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
+ .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
+ .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
+ .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
+ .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
+ .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
+ .handle_error = handle_error_LDKChannelMessageHandler_jcall,
+ .free = LDKChannelMessageHandler_JCalls_free,
+ .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
+ };
+ calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
+ LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
+ *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
+ return (long)res_ptr;
+}
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKInitFeatures their_features_conv;
+ their_features_conv.inner = (void*)(their_features & (~1));
+ their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
+ their_features_conv = InitFeatures_clone(&their_features_conv);
+ LDKOpenChannel msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKInitFeatures their_features_conv;
+ their_features_conv.inner = (void*)(their_features & (~1));
+ their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
+ their_features_conv = InitFeatures_clone(&their_features_conv);
+ LDKAcceptChannel msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKFundingCreated msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKFundingSigned msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKFundingLocked msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKInitFeatures their_features_conv;
+ their_features_conv.inner = (void*)(their_features & (~1));
+ their_features_conv.is_owned = false;
+ LDKShutdown msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKClosingSigned msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKUpdateAddHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKUpdateFulfillHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKUpdateFailHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKUpdateFailMalformedHTLC msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKCommitmentSigned msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKRevokeAndACK msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKUpdateFee msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKAnnouncementSignatures msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKInit msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKChannelReestablish msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKChannelUpdate msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKErrorMessage msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
+}
+
+typedef struct LDKRoutingMessageHandler_JCalls {
+ atomic_size_t refcnt;
+ LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
+ uint32_t handle_node_announcement_meth;
+ uint32_t handle_channel_announcement_meth;
+ uint32_t handle_channel_update_meth;
+ uint32_t handle_htlc_fail_channel_update_meth;
+ uint32_t get_next_channel_announcements_meth;
+ uint32_t get_next_node_announcements_meth;
+ uint32_t sync_routing_table_meth;
+ uint32_t handle_reply_channel_range_meth;
+ uint32_t handle_reply_short_channel_ids_end_meth;
+ uint32_t handle_query_channel_range_meth;
+ uint32_t handle_query_short_channel_ids_meth;
+} LDKRoutingMessageHandler_JCalls;
+static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->handle_node_announcement_meth);
+ js_free(j_calls->handle_channel_announcement_meth);
+ js_free(j_calls->handle_channel_update_meth);
+ js_free(j_calls->handle_htlc_fail_channel_update_meth);
+ js_free(j_calls->get_next_channel_announcements_meth);
+ js_free(j_calls->get_next_node_announcements_meth);
+ js_free(j_calls->sync_routing_table_meth);
+ js_free(j_calls->handle_reply_channel_range_meth);
+ js_free(j_calls->handle_reply_short_channel_ids_end_meth);
+ js_free(j_calls->handle_query_channel_range_meth);
+ js_free(j_calls->handle_query_short_channel_ids_meth);
+ FREE(j_calls);
+ }
+}
+LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ LDKNodeAnnouncement msg_var = *msg;
+ msg_var = NodeAnnouncement_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ LDKChannelAnnouncement msg_var = *msg;
+ msg_var = ChannelAnnouncement_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ LDKChannelUpdate msg_var = *msg;
+ msg_var = ChannelUpdate_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
+ LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ uint64_t ret_update = (uint64_t)update;
+ js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
+}
+LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
+ ret_constr.datalen = *((uint32_t*)ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
+ else
+ ret_constr.data = NULL;
+ uint32_t* ret_vals = (uint32_t*)(ret + 4);
+ for (size_t l = 0; l < ret_constr.datalen; l++) {
+ uint32_t ret_conv_63 = ret_vals[l];
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
+ ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
+ ret_constr.data[l] = ret_conv_63_conv;
+ }
+ return ret_constr;
+}
+LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
+ uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
+ LDKCVec_NodeAnnouncementZ ret_constr;
+ ret_constr.datalen = *((uint32_t*)ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
+ else
+ ret_constr.data = NULL;
+ uint32_t* ret_vals = (uint32_t*)(ret + 4);
+ for (size_t s = 0; s < ret_constr.datalen; s++) {
+ uint32_t ret_conv_18 = ret_vals[s];
+ LDKNodeAnnouncement ret_conv_18_conv;
+ ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
+ ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
+ ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
+ ret_constr.data[s] = ret_conv_18_conv;
+ }
+ return ret_constr;
+}
+void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKInit init_var = *init;
+ init_var = Init_clone(init);
+ CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t init_ref = (uint64_t)init_var.inner;
+ if (init_var.is_owned) {
+ init_ref |= 1;
+ }
+ js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
+}
+LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKReplyChannelRange msg_var = msg;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKReplyShortChannelIdsEnd msg_var = msg;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKQueryChannelRange msg_var = msg;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
+ LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
+ int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
+ LDKQueryShortChannelIds msg_var = msg;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
+ LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_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 (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
+ LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKRoutingMessageHandler ret = {
+ .this_arg = (void*) calls,
+ .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
+ .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
+ .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
+ .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
+ .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
+ .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
+ .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
+ .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
+ .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
+ .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
+ .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
+ .free = LDKRoutingMessageHandler_JCalls_free,
+ .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
+ };
+ calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
+ LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
+ *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
+ return (long)res_ptr;
+}
+uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKNodeAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKChannelAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKChannelUpdate msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
+ (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
+}
+
+uint32_tArray __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
+ uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
+ for (size_t l = 0; l < ret_var.datalen; l++) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
+ *ret_conv_63_ref = ret_var.data[l];
+ ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
+ }
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+uint32_tArray __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey starting_point_ref;
+ CHECK(*((uint32_t*)starting_point) == 33);
+ memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
+ LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
+ uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
+ for (size_t s = 0; s < ret_var.datalen; s++) {
+ LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
+ CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
+ if (ret_conv_18_var.is_owned) {
+ ret_conv_18_ref |= 1;
+ }
+ ret_arr_ptr[s] = ret_conv_18_ref;
+ }
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+void __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKInit init_conv;
+ init_conv.inner = (void*)(init & (~1));
+ init_conv.is_owned = false;
+ (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKReplyChannelRange msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ msg_conv = ReplyChannelRange_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKReplyShortChannelIdsEnd msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKQueryChannelRange msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ msg_conv = QueryChannelRange_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
+ LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
+ LDKPublicKey their_node_id_ref;
+ CHECK(*((uint32_t*)their_node_id) == 33);
+ memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
+ LDKQueryShortChannelIds msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = (msg & 1) || (msg == 0);
+ msg_conv = QueryShortChannelIds_clone(&msg_conv);
+ LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
+ *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+typedef struct LDKSocketDescriptor_JCalls {
+ atomic_size_t refcnt;
+ uint32_t send_data_meth;
+ uint32_t disconnect_socket_meth;
+ uint32_t eq_meth;
+ uint32_t hash_meth;
+} LDKSocketDescriptor_JCalls;
+static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->send_data_meth);
+ js_free(j_calls->disconnect_socket_meth);
+ js_free(j_calls->eq_meth);
+ js_free(j_calls->hash_meth);
+ FREE(j_calls);
+ }
+}
+uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ LDKu8slice data_var = data;
+ int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
+ return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
+}
+void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ js_invoke_function_0(j_calls->disconnect_socket_meth);
+}
+bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+ *other_arg_clone = SocketDescriptor_clone(other_arg);
+ return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
+}
+uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
+ LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
+ return js_invoke_function_0(j_calls->hash_meth);
+}
+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 (/*TODO: JS Object Reference */void* o) {
+ LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKSocketDescriptor ret = {
+ .this_arg = (void*) calls,
+ .send_data = send_data_LDKSocketDescriptor_jcall,
+ .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
+ .eq = eq_LDKSocketDescriptor_jcall,
+ .hash = hash_LDKSocketDescriptor_jcall,
+ .clone = LDKSocketDescriptor_JCalls_clone,
+ .free = LDKSocketDescriptor_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
+ LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
+ *res_ptr = LDKSocketDescriptor_init(o);
+ return (long)res_ptr;
+}
+int64_t __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
+ LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+ LDKu8slice data_ref;
+ data_ref.datalen = *((uint32_t*)data);
+ data_ref.data = (int8_t*)(data + 4);
+ int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
+ return ret_val;
+}
+
+void __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
+ LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+ (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
+}
+
+int64_t __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
+ LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
+ int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
+ return ret_val;
+}
+
+typedef struct LDKChannelManagerPersister_JCalls {
+ atomic_size_t refcnt;
+ uint32_t persist_manager_meth;
+} LDKChannelManagerPersister_JCalls;
+static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
+ LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->persist_manager_meth);
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
+ LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
+ LDKChannelManager channel_manager_var = *channel_manager;
+ // Warning: we may need a move here but no clone is available for LDKChannelManager
+ CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
+ if (channel_manager_var.is_owned) {
+ channel_manager_ref |= 1;
+ }
+ LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
+ LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+static void* LDKChannelManagerPersister_JCalls_clone(const void* this_arg) {
+ LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
+ LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKChannelManagerPersister ret = {
+ .this_arg = (void*) calls,
+ .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
+ .free = LDKChannelManagerPersister_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
+ LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
+ *res_ptr = LDKChannelManagerPersister_init(o);
+ return (long)res_ptr;
+}
+uint32_t __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
+ LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
+ LDKChannelManager channel_manager_conv;
+ channel_manager_conv.inner = (void*)(channel_manager & (~1));
+ channel_manager_conv.is_owned = false;
+ LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
+ *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
+ LDKFallback *obj = (LDKFallback*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKFallback_SegWitProgram: {
+ uint8_t version_val = obj->seg_wit_program.version._0;
+ LDKCVec_u8Z program_var = obj->seg_wit_program.program;
+ int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
+ return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
+ }
+ case LDKFallback_PubKeyHash: {
+ int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
+ return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
+ }
+ case LDKFallback_ScriptHash: {
+ int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
+ return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
+ }
+ default: abort();
+ }
+}
+jstring __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
+ LDKStr ret_str = _ldk_get_compiled_version();
+ jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
+ return ret_conv;
+}
+
+jstring __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
+ LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
+ jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
+ return ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
+ LDKTransaction _res_ref;
+ _res_ref.datalen = *((uint32_t*)_res);
+ _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
+ memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
+ _res_ref.data_is_owned = true;
+ Transaction_free(_res_ref);
+}
+
+void __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
+ if ((_res & 1) != 0) return;
+ LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
+ FREE((void*)_res);
+ TxOut_free(_res_conv);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
+ LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
+ LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+ *ret_ref = TxOut_clone(orig_conv);
+ return (uint64_t)ret_ref;
+}
+
+void __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
+ LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
+ Str_free(dummy);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
+ LDKSecretKey o_ref;
+ CHECK(*((uint32_t*)o) == 32);
+ memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
+ LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
+ *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
+ LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
+ LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
+ *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
+ if ((_res & 1) != 0) return;
+ LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
+ FREE((void*)_res);
+ CResult_SecretKeyErrorZ_free(_res_conv);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
+ LDKPublicKey o_ref;
+ CHECK(*((uint32_t*)o) == 33);
+ memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
+ LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
+ *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
+ LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
+ LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
+ *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
+ if ((_res & 1) != 0) return;
+ LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
+ FREE((void*)_res);
+ CResult_PublicKeyErrorZ_free(_res_conv);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
+ LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
+ LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
+ *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
+ LDKTxCreationKeys o_conv;
+ o_conv.inner = (void*)(o & (~1));
+ o_conv.is_owned = (o & 1) || (o == 0);
+ o_conv = TxCreationKeys_clone(&o_conv);
+ LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
+ *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
+ LDKDecodeError e_conv;
+ e_conv.inner = (void*)(e & (~1));
+ e_conv.is_owned = (e & 1) || (e == 0);
+ e_conv = DecodeError_clone(&e_conv);
+ LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
+ *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
+ if ((_res & 1) != 0) return;
+ LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+ FREE((void*)_res);
+ CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
+ LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
+ LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
+ *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
+ LDKChannelPublicKeys o_conv;
+ o_conv.inner = (void*)(o & (~1));
+ o_conv.is_owned = (o & 1) || (o == 0);
+ o_conv = ChannelPublicKeys_clone(&o_conv);
+ LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
+ *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
+ LDKDecodeError e_conv;
+ e_conv.inner = (void*)(e & (~1));
+ e_conv.is_owned = (e & 1) || (e == 0);
+ e_conv = DecodeError_clone(&e_conv);
+ LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
+ *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
+ if ((_res & 1) != 0) return;
+ LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
+ FREE((void*)_res);
+ CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
+ LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
+ LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
+ *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
+ LDKTxCreationKeys o_conv;
+ o_conv.inner = (void*)(o & (~1));
+ o_conv.is_owned = (o & 1) || (o == 0);
+ o_conv = TxCreationKeys_clone(&o_conv);
+ LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
+ *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
+ LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
+ LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
+ *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
+ if ((_res & 1) != 0) return;
+ LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
+ FREE((void*)_res);
+ CResult_TxCreationKeysErrorZ_free(_res_conv);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
+ LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
+ LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
+ *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
+ return (uint64_t)ret_conv;