- default: abort();
- }
-}
-uint32_t __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_ok(uint32_t arg) {
- LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
- CHECK(val->result_ok);
- LDKLockedChannelMonitor res_var = (*val->contents.result);
- uint64_t res_ref = 0;
- CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
- CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
- res_ref = (uint64_t)res_var.inner & ~1;
- return res_ref;
-}
-void __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
- LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
- CHECK(!val->result_ok);
- return *val->contents.err;
-}
-static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
- LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
- for (size_t i = 0; i < ret.datalen; i++) {
- ret.data[i] = OutPoint_clone(&orig->data[i]);
- }
- return ret;
-}
-typedef struct LDKMessageSendEventsProvider_JCalls {
- atomic_size_t refcnt;
- uint32_t get_and_clear_pending_msg_events_meth;
-} LDKMessageSendEventsProvider_JCalls;
-static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
- LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
- if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
- js_free(j_calls->get_and_clear_pending_msg_events_meth);
- FREE(j_calls);
- }
-}
-LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
- LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
- uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
- LDKCVec_MessageSendEventZ ret_constr;
- ret_constr.datalen = *((uint32_t*)ret);
- if (ret_constr.datalen > 0)
- ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ 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];
- void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
- CHECK_ACCESS(ret_conv_18_ptr);
- LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
- FREE((void*)ret_conv_18);
- ret_constr.data[s] = ret_conv_18_conv;
- }
- return ret_constr;
-}
-static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
- LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
- atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
-}
-static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
- LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
- atomic_init(&calls->refcnt, 1);
- //TODO: Assign calls->o from o
-
- LDKMessageSendEventsProvider ret = {
- .this_arg = (void*) calls,
- .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
- .free = LDKMessageSendEventsProvider_JCalls_free,
- };
- return ret;
-}
-long __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
- LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
- *res_ptr = LDKMessageSendEventsProvider_init(o);
- return (long)res_ptr;
-}
-uint32_tArray __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
- LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
- uint32_tArray ret_arr = NULL;
- 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++) {
- LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
- *ret_conv_18_copy = ret_var.data[s];
- uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
- ret_arr_ptr[s] = ret_conv_18_ref;
- }
-
- FREE(ret_var.data);
- return ret_arr;
-}
-
-typedef struct LDKEventHandler_JCalls {
- atomic_size_t refcnt;
- uint32_t handle_event_meth;
-} LDKEventHandler_JCalls;
-static void LDKEventHandler_JCalls_free(void* this_arg) {
- LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
- if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
- js_free(j_calls->handle_event_meth);
- FREE(j_calls);
- }
-}
-void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
- LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
- LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
- *ret_event = Event_clone(event);
- js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event);
-}
-static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
- LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
- atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
-}
-static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
- LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
- atomic_init(&calls->refcnt, 1);
- //TODO: Assign calls->o from o
-
- LDKEventHandler ret = {
- .this_arg = (void*) calls,
- .handle_event = handle_event_LDKEventHandler_jcall,
- .free = LDKEventHandler_JCalls_free,
- };
- return ret;
-}
-long __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
- LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
- *res_ptr = LDKEventHandler_init(o);
- return (long)res_ptr;
-}
-void __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
- LDKEvent* event_conv = (LDKEvent*)event;
- (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
-}
-
-typedef struct LDKEventsProvider_JCalls {
- atomic_size_t refcnt;
- uint32_t process_pending_events_meth;
-} LDKEventsProvider_JCalls;
-static void LDKEventsProvider_JCalls_free(void* this_arg) {
- LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
- if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
- js_free(j_calls->process_pending_events_meth);
- FREE(j_calls);
- }
-}
-void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
- LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
- LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
- *handler_ret = handler;
- js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
-}
-static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
- LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
- atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
-}
-static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
- LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
- atomic_init(&calls->refcnt, 1);
- //TODO: Assign calls->o from o
-
- LDKEventsProvider ret = {
- .this_arg = (void*) calls,
- .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
- .free = LDKEventsProvider_JCalls_free,
- };
- return ret;
-}
-long __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
- LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
- *res_ptr = LDKEventsProvider_init(o);
- return (long)res_ptr;
-}
-void __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
- void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
- CHECK_ACCESS(handler_ptr);
- LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
- (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_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_cloned(LDKListen* new_obj) {
- LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
- atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
-}
-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) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
- 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) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
- 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 = NULL;
- 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 c = 0; c < txdata_var.datalen; c++) {
- LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
- *txdata_conv_28_conv = txdata_var.data[c];
- txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
- }
-
- 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_cloned(LDKConfirm* new_obj) {
- LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
- atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
-}
-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) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
- 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 c = 0; c < txdata_constr.datalen; c++) {
- uint32_t txdata_conv_28 = txdata_vals[c];
- void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
- CHECK_ACCESS(txdata_conv_28_ptr);
- LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
- txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
- txdata_constr.data[c] = txdata_conv_28_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) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
- 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) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
- 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) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
- LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
- ptrArray ret_arr = NULL;
- 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 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 channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
- LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
- LDKOutPoint channel_id_var = channel_id;
- uint64_t channel_id_ref = 0;
- CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
- CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
- channel_id_ref = (uint64_t)channel_id_var.inner;
- if (channel_id_var.is_owned) {
- channel_id_ref |= 1;
- }
- LDKChannelMonitor data_var = *data;
- uint64_t data_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
- data_ref = (uint64_t)data_var.inner;
- if (data_var.is_owned) {
- data_ref |= 1;
- }
- LDKMonitorUpdateId update_id_var = update_id;
- uint64_t update_id_ref = 0;
- CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
- CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
- update_id_ref = (uint64_t)update_id_var.inner;
- if (update_id_var.is_owned) {
- update_id_ref |= 1;
- }
- uint32_t ret = js_invoke_function_3(j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
- void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
- CHECK_ACCESS(ret_ptr);
- LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
- FREE((void*)ret);
- return ret_conv;
-}
-LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
- LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
- LDKOutPoint channel_id_var = channel_id;
- uint64_t channel_id_ref = 0;
- CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
- CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
- channel_id_ref = (uint64_t)channel_id_var.inner;
- if (channel_id_var.is_owned) {
- channel_id_ref |= 1;
- }
- LDKChannelMonitorUpdate update_var = *update;
- uint64_t update_ref = 0;
- if ((uint64_t)update_var.inner > 4096) {
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
- update_ref = (uint64_t)update_var.inner;
- if (update_var.is_owned) {
- update_ref |= 1;
- }
- }
- LDKChannelMonitor data_var = *data;
- uint64_t data_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
- data_ref = (uint64_t)data_var.inner;
- if (data_var.is_owned) {
- data_ref |= 1;
- }
- LDKMonitorUpdateId update_id_var = update_id;
- uint64_t update_id_ref = 0;
- CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
- CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
- update_id_ref = (uint64_t)update_id_var.inner;
- if (update_id_var.is_owned) {
- update_id_ref |= 1;
- }
- uint32_t ret = js_invoke_function_4(j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
- void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
- CHECK_ACCESS(ret_ptr);
- LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
- FREE((void*)ret);
- return ret_conv;
-}
-static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
- LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
- atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
-}
-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 channel_id, uint32_t data, uint32_t update_id) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
- LDKOutPoint channel_id_conv;
- channel_id_conv.inner = (void*)(channel_id & (~1));
- channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
- channel_id_conv = OutPoint_clone(&channel_id_conv);
- LDKChannelMonitor data_conv;
- data_conv.inner = (void*)(data & (~1));
- data_conv.is_owned = false;
- CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
- LDKMonitorUpdateId update_id_conv;
- update_id_conv.inner = (void*)(update_id & (~1));
- update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
- update_id_conv = MonitorUpdateId_clone(&update_id_conv);
- LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
- *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
- return (uint64_t)ret_conv;
-}
-
-uint32_t __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t channel_id, uint32_t update, uint32_t data, uint32_t update_id) {
- void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
- if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
- LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
- LDKOutPoint channel_id_conv;
- channel_id_conv.inner = (void*)(channel_id & (~1));
- channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
- channel_id_conv = OutPoint_clone(&channel_id_conv);
- LDKChannelMonitorUpdate update_conv;
- update_conv.inner = (void*)(update & (~1));
- update_conv.is_owned = false;
- CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
- LDKChannelMonitor data_conv;
- data_conv.inner = (void*)(data & (~1));
- data_conv.is_owned = false;
- CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
- LDKMonitorUpdateId update_id_conv;
- update_id_conv.inner = (void*)(update_id & (~1));
- update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
- CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
- update_id_conv = MonitorUpdateId_clone(&update_id_conv);
- LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
- *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_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;
- uint64_t their_features_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
- their_features_ref = (uint64_t)their_features_var.inner;
- if (their_features_var.is_owned) {
- their_features_ref |= 1;
- }
- LDKOpenChannel msg_var = *msg;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- 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;
- uint64_t their_features_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
- their_features_ref = (uint64_t)their_features_var.inner;
- if (their_features_var.is_owned) {
- their_features_ref |= 1;
- }
- LDKAcceptChannel msg_var = *msg;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- 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;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- 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;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- 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;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- 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;
- uint64_t their_features_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
- their_features_ref = (uint64_t)their_features_var.inner;
- if (their_features_var.is_owned) {
- their_features_ref |= 1;
- }
- LDKShutdown msg_var = *msg;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- 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;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- 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;
- uint64_t msg_ref = 0;
- 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.
- CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
- msg_ref = (uint64_t)msg_var.inner;
- if (msg_var.is_owned) {
- msg_ref |= 1;
+ case LDKMessageSendEvent_SendFundingCreated: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
+ LDKFundingCreated msg_var = obj->send_funding_created.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingSigned: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
+ LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingLocked: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
+ LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendAnnouncementSignatures: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
+ LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_UpdateHTLCs: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
+ LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+ uint64_t updates_ref = 0;
+ CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
+ updates_ref = (uint64_t)updates_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
+ }
+ case LDKMessageSendEvent_SendRevokeAndACK: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
+ LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendClosingSigned: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
+ LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendShutdown: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
+ LDKShutdown msg_var = obj->send_shutdown.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendChannelReestablish: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
+ LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
+ LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+ uint64_t update_msg_ref = 0;
+ CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
+ update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
+ }
+ case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
+ LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_BroadcastChannelUpdate: {
+ LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendChannelUpdate: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
+ LDKChannelUpdate msg_var = obj->send_channel_update.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_HandleError: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
+ uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
+ return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
+ }
+ case LDKMessageSendEvent_SendChannelRangeQuery: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
+ LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendShortIdsQuery: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
+ LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendReplyChannelRange: {
+ int8_tArray node_id_arr = init_int8_tArray(33);
+ memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
+ LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
+ uint64_t msg_ref = 0;
+ 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.
+ CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
+ }
+ default: abort();