X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fbindings.c;h=d5fb16587dbaddc754157b94ac58c917f8f9ba2e;hb=aacd3307d5682030df56136abfda6e4e8ee307a3;hp=665c4f05a6d7e354760ddf64d6149046250259af;hpb=348009c7987109e810e7e31db6110fb71879fbc3;p=ldk-java diff --git a/ts/bindings.c b/ts/bindings.c index 665c4f05..d5fb1658 100644 --- a/ts/bindings.c +++ b/ts/bindings.c @@ -326,6 +326,21 @@ static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) { memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen); return ret; } +struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) { return CVec_u8Z_clone(&thing->script_pubkey);}int8_tArray __attribute__((visibility("default"))) TS_TxOut_get_script_pubkey(uint32_t thing) { + LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1); + LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +uint64_t TxOut_get_value (struct LDKTxOut* thing) { return thing->value;}int64_t __attribute__((visibility("default"))) TS_TxOut_get_value(uint32_t thing) { + LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1); + int64_t ret_val = TxOut_get_value(thing_conv); + return ret_val; +} + jboolean __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok; } @@ -594,6 +609,48 @@ void __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_ CHECK(!val->result_ok); return *val->contents.err; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t arg) { + LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + LDKShutdownScript res_var = (*val->contents.result); + 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. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) { + LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} +jboolean __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_result_ok(uint32_t arg) { + return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t arg) { + LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1); + CHECK(val->result_ok); + LDKShutdownScript res_var = (*val->contents.result); + 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. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) { + LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKInvalidShutdownScript err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_NoneErrorZ*)arg)->result_ok; } @@ -1486,7 +1543,7 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_L if (commitment_tx_var.is_owned) { commitment_tx_ref |= 1; } - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref); + uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1501,7 +1558,7 @@ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htl if (commitment_tx_var.is_owned) { commitment_tx_ref |= 1; } - LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref); + uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref); LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1514,7 +1571,7 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const vo Transaction_free(justice_tx_var); int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32); - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr); + uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr); LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1535,7 +1592,7 @@ LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void if (htlc_var.is_owned) { htlc_ref |= 1; } - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref); + uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref); LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1556,7 +1613,7 @@ LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(c if (htlc_var.is_owned) { htlc_ref |= 1; } - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref); + uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref); LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1567,7 +1624,7 @@ LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen); Transaction_free(closing_tx_var); - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr); + uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr); LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1582,7 +1639,7 @@ LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void if (msg_var.is_owned) { msg_ref |= 1; } - LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref); + uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref); LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -1599,10 +1656,9 @@ void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransaction } js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref); } -static void* LDKBaseSign_JCalls_clone(const void* this_arg) { - LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg; +static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) { + LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) { LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls"); @@ -1800,11 +1856,10 @@ LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) { memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen); return ret_ref; } -static void* LDKSign_JCalls_clone(const void* this_arg) { - LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg; +static void LDKSign_JCalls_cloned(LDKSign* new_obj) { + LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) { LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls"); @@ -1819,7 +1874,7 @@ static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TOD LDKSign ret = { .this_arg = (void*) calls, .write = write_LDKSign_jcall, - .clone = LDKSign_JCalls_clone, + .cloned = LDKSign_JCalls_cloned, .free = LDKSign_JCalls_free, .BaseSign = LDKBaseSign_init(BaseSign, pubkeys), }; @@ -2067,6 +2122,13 @@ uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint case LDKAPIError_MonitorUpdateFailed: { return 0 /* LDKAPIError - MonitorUpdateFailed */; } + case LDKAPIError_IncompatibleShutdownScript: { + LDKShutdownScript script_var = obj->incompatible_shutdown_script.script; + CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t script_ref = (uint64_t)script_var.inner & ~1; + return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref; + } default: abort(); } } @@ -2190,6 +2252,22 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFa uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_result_ok(uint32_t arg) { + return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok; +} +int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_ok(uint32_t arg) { + LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1); + CHECK(val->result_ok); + int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32); + return res_arr; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_err(uint32_t arg) { + LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1); + CHECK(!val->result_ok); + uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1; + return err_ref; +} uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) { LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1); switch(obj->tag) { @@ -2337,7 +2415,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* if (monitor_var.is_owned) { monitor_ref |= 1; } - LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref); + uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_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; @@ -2358,7 +2436,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void if (update_var.is_owned) { update_ref |= 1; } - LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref); + uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_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; @@ -2381,10 +2459,9 @@ LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* } return ret_constr; } -static void* LDKWatch_JCalls_clone(const void* this_arg) { - LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg; +static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) { + LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) { LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls"); @@ -2469,10 +2546,9 @@ void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, L Transaction_free(tx_var); js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr); } -static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) { - LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg; +static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) { + LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) { LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls"); @@ -2505,7 +2581,7 @@ typedef struct LDKKeysInterface_JCalls { atomic_size_t refcnt; uint32_t get_node_secret_meth; uint32_t get_destination_script_meth; - uint32_t get_shutdown_pubkey_meth; + uint32_t get_shutdown_scriptpubkey_meth; uint32_t get_channel_signer_meth; uint32_t get_secure_random_bytes_meth; uint32_t read_chan_signer_meth; @@ -2516,7 +2592,7 @@ static void LDKKeysInterface_JCalls_free(void* this_arg) { if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) { js_free(j_calls->get_node_secret_meth); js_free(j_calls->get_destination_script_meth); - js_free(j_calls->get_shutdown_pubkey_meth); + js_free(j_calls->get_shutdown_scriptpubkey_meth); js_free(j_calls->get_channel_signer_meth); js_free(j_calls->get_secure_random_bytes_meth); js_free(j_calls->read_chan_signer_meth); @@ -2541,19 +2617,20 @@ LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen); return ret_ref; } -LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) { +LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - int8_tArray ret = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth); - LDKPublicKey ret_ref; - CHECK(*((uint32_t*)ret) == 33); - memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33); - return ret_ref; + uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth); + LDKShutdownScript ret_conv; + ret_conv.inner = (void*)(ret & (~1)); + ret_conv.is_owned = (ret & 1) || (ret == 0); + ret_conv = ShutdownScript_clone(&ret_conv); + return ret_conv; } LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) { LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; - LDKSign* ret = (LDKSign*)js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis); + uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis); LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1); - ret_conv = Sign_clone(ret); + ret_conv = Sign_clone(&ret_conv); return ret_conv; } LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) { @@ -2569,7 +2646,7 @@ LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* LDKu8slice reader_var = reader; int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen); - LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr); + uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr); LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1)); return ret_conv; @@ -2580,15 +2657,14 @@ LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const v int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen); CVec_u8Z_free(invoice_preimage_var); - LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr); + uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr); LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1)); return ret_conv; } -static void* LDKKeysInterface_JCalls_clone(const void* this_arg) { - LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg; +static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) { + LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) { LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls"); @@ -2599,7 +2675,7 @@ static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Referenc .this_arg = (void*) calls, .get_node_secret = get_node_secret_LDKKeysInterface_jcall, .get_destination_script = get_destination_script_LDKKeysInterface_jcall, - .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall, + .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall, .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall, .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall, .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall, @@ -2629,11 +2705,16 @@ int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_destina return ret_arr; } -int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) { +uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) { LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1); - int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33); - return ret_arr; + LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; } uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) { @@ -2687,10 +2768,9 @@ uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target); return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv); } -static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) { - LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg; +static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) { + LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) { LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls"); @@ -2733,10 +2813,9 @@ void log_LDKLogger_jcall(const void* this_arg, const char* record) { jstring record_conv = str_ref_to_ts(record_str, strlen(record_str)); js_invoke_function_1(j_calls->log_meth, record_conv); } -static void* LDKLogger_JCalls_clone(const void* this_arg) { - LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg; +static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) { + LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) { LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls"); @@ -3290,6 +3369,24 @@ static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCV } return ret; } +uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) { + LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1); + switch(obj->tag) { + case LDKPaymentPurpose_InvoicePayment: { + int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32); + int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32); + return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id; + } + case LDKPaymentPurpose_SpontaneousPayment: { + int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32); + return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr; + } + default: abort(); + } +} uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) { LDKEvent *obj = (LDKEvent*)(ptr & ~1); switch(obj->tag) { @@ -3304,11 +3401,8 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_ case LDKEvent_PaymentReceived: { int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32); - int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_received.payment_preimage.data, 32); - int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32); - return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->payment_received.amt; (void) obj->payment_received.user_payment_id; + uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1; + return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref; } case LDKEvent_PaymentSent: { int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); @@ -3333,6 +3427,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_ } return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr; } + case LDKEvent_PaymentForwarded: { + uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1; + return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx; + } default: abort(); } } @@ -4048,6 +4146,27 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDeco uint64_t err_ref = (uint64_t)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) { + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + LDKClosingSignedFeeRange res_var = (*val->contents.result); + 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. + uint64_t res_ref = (uint64_t)res_var.inner & ~1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) { + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t err_ref = (uint64_t)err_var.inner & ~1; + return err_ref; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok; } @@ -4675,10 +4794,9 @@ LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsP } return ret_constr; } -static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) { - LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg; +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); - return (void*) this_arg; } static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) { LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls"); @@ -4730,10 +4848,9 @@ void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) { uint64_t event_ref = (uint64_t)event_copy; js_invoke_function_1(j_calls->handle_event_meth, event_ref); } -static void* LDKEventHandler_JCalls_clone(const void* this_arg) { - LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg; +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); - return (void*) this_arg; } static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) { LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls"); @@ -4775,10 +4892,9 @@ void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEve *ret = handler; js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)ret); } -static void* LDKEventsProvider_JCalls_clone(const void* this_arg) { - LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg; +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); - return (void*) this_arg; } static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) { LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls"); @@ -4818,15 +4934,14 @@ LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, cons LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32); - LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); + uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id); LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1); ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1)); return ret_conv; } -static void* LDKAccess_JCalls_clone(const void* this_arg) { - LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg; +static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) { + LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg; atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release); - return (void*) this_arg; } static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) { LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls"); @@ -4882,10 +4997,9 @@ void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* h 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; +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); - return (void*) this_arg; } static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) { LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls"); @@ -4985,10 +5099,9 @@ LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) { } return ret_constr; } -static void* LDKConfirm_JCalls_clone(const void* this_arg) { - LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg; +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); - return (void*) this_arg; } static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) { LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls"); @@ -5095,15 +5208,14 @@ LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void 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); + uint32_t ret = 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; +static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) { + LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->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"); @@ -5177,7 +5289,7 @@ LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(con 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); + uint32_t ret = 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; @@ -5207,15 +5319,14 @@ LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcal 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); + uint32_t ret = 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; +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); - return (void*) this_arg; } static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) { LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls"); @@ -5610,11 +5721,10 @@ void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublic } 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; +static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) { + LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->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"); @@ -5924,7 +6034,7 @@ LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler 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); + uint32_t ret = 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; @@ -5939,7 +6049,7 @@ LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHand 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); + uint32_t ret = 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; @@ -5954,7 +6064,7 @@ LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jc 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); + uint32_t ret = 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; @@ -6029,7 +6139,7 @@ LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandl 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); + uint32_t ret = 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; @@ -6045,7 +6155,7 @@ LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMess 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); + uint32_t ret = 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; @@ -6061,7 +6171,7 @@ LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandl 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); + uint32_t ret = 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; @@ -6077,16 +6187,15 @@ LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageH 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); + uint32_t ret = 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; +static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) { + LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->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"); @@ -6294,10 +6403,9 @@ 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; +static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) { + LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->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"); @@ -6310,7 +6418,7 @@ static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Re .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall, .eq = eq_LDKSocketDescriptor_jcall, .hash = hash_LDKSocketDescriptor_jcall, - .clone = LDKSocketDescriptor_JCalls_clone, + .cloned = LDKSocketDescriptor_JCalls_cloned, .free = LDKSocketDescriptor_JCalls_free, }; return ret; @@ -6361,15 +6469,14 @@ LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const voi 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); + uint32_t ret = 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; +static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) { + LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->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"); @@ -6424,12 +6531,14 @@ uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint 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); + Str_free(ret_str); 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); + Str_free(ret_str); return ret_conv; } @@ -6442,6 +6551,16 @@ void __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _re Transaction_free(_res_ref); } +uint32_t __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) { + LDKCVec_u8Z script_pubkey_ref; + script_pubkey_ref.datalen = *((uint32_t*)script_pubkey); + script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen); + LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut"); + *ret_ref = TxOut_new(script_pubkey_ref, value); + return (uint64_t)ret_ref; +} + void __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) { if ((_res & 1) != 0) return; LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1); @@ -6927,6 +7046,67 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) { + LDKShutdownScript o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + o_conv = ShutdownScript_clone(&o_conv); + LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ"); + *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_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_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ"); + *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_ShutdownScriptDecodeErrorZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) { + LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1); + LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ"); + *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) { + LDKShutdownScript o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + o_conv = ShutdownScript_clone(&o_conv); + LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ"); + *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) { + LDKInvalidShutdownScript e_conv; + e_conv.inner = (void*)(e & (~1)); + e_conv.is_owned = (e & 1) || (e == 0); + // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript + LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ"); + *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() { LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ"); *ret_conv = CResult_NoneErrorZ_ok(); @@ -8061,6 +8241,36 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailu return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_ok(int8_tArray o) { + LDKThirtyTwoBytes o_ref; + CHECK(*((uint32_t*)o) == 32); + memcpy(o_ref.data, (uint8_t*)(o + 4), 32); + LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); + *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_err(uint32_t e) { + LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1); + LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); + *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_PaymentHashPaymentSendFailureZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_clone(uint32_t orig) { + LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1); + LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); + *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + void __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) { LDKCVec_NetAddressZ _res_constr; _res_constr.datalen = *((uint32_t*)_res); @@ -9761,6 +9971,40 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeE return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) { + LDKClosingSignedFeeRange o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + o_conv = ClosingSignedFeeRange_clone(&o_conv); + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ"); + *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_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_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ"); + *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv); + return (uint64_t)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) { + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1); + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ"); + *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) { LDKCommitmentSigned o_conv; o_conv.inner = (void*)(o & (~1)); @@ -10710,6 +10954,44 @@ uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreatio return (uint64_t)ret_conv; } +void __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) { + if ((this_ptr & 1) != 0) return; + LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1); + FREE((void*)this_ptr); + PaymentPurpose_free(this_ptr_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) { + LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig; + LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose"); + *ret_copy = PaymentPurpose_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) { + LDKThirtyTwoBytes payment_preimage_ref; + CHECK(*((uint32_t*)payment_preimage) == 32); + memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32); + LDKThirtyTwoBytes payment_secret_ref; + CHECK(*((uint32_t*)payment_secret) == 32); + memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32); + LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose"); + *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) { + LDKThirtyTwoBytes a_ref; + CHECK(*((uint32_t*)a) == 32); + memcpy(a_ref.data, (uint8_t*)(a + 4), 32); + LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose"); + *ret_copy = PaymentPurpose_spontaneous_payment(a_ref); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + void __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1); @@ -10725,6 +11007,86 @@ uint32_t __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) { return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_Event_funding_generation_ready(int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) { + LDKThirtyTwoBytes temporary_channel_id_ref; + CHECK(*((uint32_t*)temporary_channel_id) == 32); + memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32); + LDKCVec_u8Z output_script_ref; + output_script_ref.datalen = *((uint32_t*)output_script); + output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) { + LDKThirtyTwoBytes payment_hash_ref; + CHECK(*((uint32_t*)payment_hash) == 32); + memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); + LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_preimage) { + LDKThirtyTwoBytes payment_preimage_ref; + CHECK(*((uint32_t*)payment_preimage) == 32); + memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_payment_sent(payment_preimage_ref); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Event_payment_failed(int8_tArray payment_hash, jboolean rejected_by_dest) { + LDKThirtyTwoBytes payment_hash_ref; + CHECK(*((uint32_t*)payment_hash) == 32); + memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) { + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_pending_htlcs_forwardable(time_forwardable); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) { + LDKCVec_SpendableOutputDescriptorZ outputs_constr; + outputs_constr.datalen = *((uint32_t*)outputs); + if (outputs_constr.datalen > 0) + outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements"); + else + outputs_constr.data = NULL; + uint32_t* outputs_vals = (uint32_t*)(outputs + 4); + for (size_t b = 0; b < outputs_constr.datalen; b++) { + uint32_t outputs_conv_27 = outputs_vals[b]; + LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1); + outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1)); + outputs_constr.data[b] = outputs_conv_27_conv; + } + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_spendable_outputs(outputs_constr); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) { + LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1); + LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent"); + *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + int8_tArray __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) { LDKEvent* obj_conv = (LDKEvent*)obj; LDKCVec_u8Z ret_var = Event_write(obj_conv); @@ -10749,7 +11111,273 @@ uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint3 return ret_ref; } -void __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) { +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKAcceptChannel msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = AcceptChannel_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKOpenChannel msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = OpenChannel_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKFundingCreated msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = FundingCreated_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKFundingSigned msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = FundingSigned_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKFundingLocked msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = FundingLocked_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKAnnouncementSignatures msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = AnnouncementSignatures_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKCommitmentUpdate updates_conv; + updates_conv.inner = (void*)(updates & (~1)); + updates_conv.is_owned = (updates & 1) || (updates == 0); + updates_conv = CommitmentUpdate_clone(&updates_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKRevokeAndACK msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = RevokeAndACK_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKClosingSigned msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ClosingSigned_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKShutdown msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = Shutdown_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKChannelReestablish msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelReestablish_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) { + LDKChannelAnnouncement msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelAnnouncement_clone(&msg_conv); + LDKChannelUpdate update_msg_conv; + update_msg_conv.inner = (void*)(update_msg & (~1)); + update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0); + update_msg_conv = ChannelUpdate_clone(&update_msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) { + LDKNodeAnnouncement msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = NodeAnnouncement_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) { + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelUpdate_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelUpdate_clone(&msg_conv); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_payment_failure_network_update(uint32_t update) { + LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(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); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(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); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(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); + LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent"); + *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1); FREE((void*)this_ptr); @@ -10785,6 +11413,56 @@ uint32_t __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) { + LDKStr err_conv = str_ref_to_owned_c(err); + LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError"); + *ret_copy = APIError_apimisuse_error(err_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) { + LDKStr err_conv = str_ref_to_owned_c(err); + LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError"); + *ret_copy = APIError_fee_rate_too_high(err_conv, feerate); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) { + LDKStr err_conv = str_ref_to_owned_c(err); + LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError"); + *ret_copy = APIError_route_error(err_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) { + LDKStr err_conv = str_ref_to_owned_c(err); + LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError"); + *ret_copy = APIError_channel_unavailable(err_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() { + LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError"); + *ret_copy = APIError_monitor_update_failed(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) { + LDKShutdownScript script_conv; + script_conv.inner = (void*)(script & (~1)); + script_conv.is_owned = (script & 1) || (script == 0); + script_conv = ShutdownScript_clone(&script_conv); + LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError"); + *ret_copy = APIError_incompatible_shutdown_script(script_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) { LDKu8slice msg_ref; msg_ref.datalen = *((uint32_t*)msg); @@ -10826,6 +11504,31 @@ uint32_t __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) { return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_Level_trace() { + uint32_t ret_conv = LDKLevel_to_js(Level_trace()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Level_debug() { + uint32_t ret_conv = LDKLevel_to_js(Level_debug()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Level_info() { + uint32_t ret_conv = LDKLevel_to_js(Level_info()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Level_warn() { + uint32_t ret_conv = LDKLevel_to_js(Level_warn()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Level_error() { + uint32_t ret_conv = LDKLevel_to_js(Level_error()); + return ret_conv; +} + jboolean __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) { LDKLevel* a_conv = (LDKLevel*)(a & ~1); LDKLevel* b_conv = (LDKLevel*)(b & ~1); @@ -11173,19 +11876,49 @@ jboolean __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upf LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv); + jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val); +} + +int64_t __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val); +} + +int64_t __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv); return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) { +void __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val); + ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val); } -uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) { - LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); +uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) { + LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -11455,6 +12188,16 @@ uint32_t __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t o return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_AccessError_unknown_chain() { + uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_AccessError_unknown_tx() { + uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx()); + return ret_conv; +} + void __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1); @@ -11619,6 +12362,28 @@ uint32_t __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uin return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_ConfirmationTarget_background() { + uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() { + uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() { + uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority()); + return ret_conv; +} + +jboolean __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) { + LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1); + LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1); + jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv); + return ret_val; +} + void __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1); @@ -11753,6 +12518,16 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clon return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() { + uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() { + uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure()); + return ret_conv; +} + void __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) { LDKMonitorUpdateError this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -11789,6 +12564,28 @@ uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) { + LDKHTLCUpdate a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = (a & 1) || (a == 0); + a_conv = HTLCUpdate_clone(&a_conv); + LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent"); + *ret_copy = MonitorEvent_htlcevent(a_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_broadcasted(uint32_t a) { + LDKOutPoint a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = (a & 1) || (a == 0); + a_conv = OutPoint_clone(&a_conv); + LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent"); + *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + void __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) { LDKHTLCUpdate this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -12586,6 +13383,40 @@ uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_cl return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) { + LDKOutPoint outpoint_conv; + outpoint_conv.inner = (void*)(outpoint & (~1)); + outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0); + outpoint_conv = OutPoint_clone(&outpoint_conv); + LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1); + LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor"); + *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) { + LDKDelayedPaymentOutputDescriptor a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = (a & 1) || (a == 0); + a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv); + LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor"); + *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) { + LDKStaticPaymentOutputDescriptor a_conv; + a_conv.inner = (void*)(a & (~1)); + a_conv.is_owned = (a & 1) || (a == 0); + a_conv = StaticPaymentOutputDescriptor_clone(&a_conv); + LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor"); + *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + int8_tArray __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) { LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj; LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv); @@ -13513,6 +14344,74 @@ uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uin return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) { + LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1); + LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); + *ret_copy = PaymentSendFailure_parameter_error(a_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) { + LDKCVec_CResult_NoneAPIErrorZZ a_constr; + a_constr.datalen = *((uint32_t*)a); + if (a_constr.datalen > 0) + a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements"); + else + a_constr.data = NULL; + uint32_t* a_vals = (uint32_t*)(a + 4); + for (size_t w = 0; w < a_constr.datalen; w++) { + uint32_t a_conv_22 = a_vals[w]; + LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1); + a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1)); + a_constr.data[w] = a_conv_22_conv; + } + LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); + *ret_copy = PaymentSendFailure_path_parameter_error(a_constr); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) { + LDKCVec_APIErrorZ a_constr; + a_constr.datalen = *((uint32_t*)a); + if (a_constr.datalen > 0) + a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements"); + else + a_constr.data = NULL; + uint32_t* a_vals = (uint32_t*)(a + 4); + for (size_t k = 0; k < a_constr.datalen; k++) { + uint32_t a_conv_10 = a_vals[k]; + LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1); + a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1)); + a_constr.data[k] = a_conv_10_conv; + } + LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); + *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray a) { + LDKCVec_CResult_NoneAPIErrorZZ a_constr; + a_constr.datalen = *((uint32_t*)a); + if (a_constr.datalen > 0) + a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements"); + else + a_constr.data = NULL; + uint32_t* a_vals = (uint32_t*)(a + 4); + for (size_t w = 0; w < a_constr.datalen; w++) { + uint32_t a_conv_22 = a_vals[w]; + LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1); + a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1)); + a_constr.data[w] = a_conv_22_conv; + } + LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure"); + *ret_copy = PaymentSendFailure_partial_failure(a_constr); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, uint32_t params) { LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1); LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1); @@ -13622,6 +14521,19 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_close_channel return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_ChannelManager_close_channel_with_target_feerate(uint32_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + unsigned char channel_id_arr[32]; + CHECK(*((uint32_t*)channel_id) == 32); + memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32); + unsigned char (*channel_id_ref)[32] = &channel_id_arr; + LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); + *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -13660,6 +14572,21 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelManager_send_payment( return (uint64_t)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKRoute route_conv; + route_conv.inner = (void*)(route & (~1)); + route_conv.is_owned = false; + LDKThirtyTwoBytes payment_preimage_ref; + CHECK(*((uint32_t*)payment_preimage) == 32); + memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32); + LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ"); + *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -14140,6 +15067,7 @@ jstring __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_ this_ptr_conv.is_owned = false; LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -15215,6 +16143,68 @@ uint32_t __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig return ret_ref; } +void __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) { + LDKClosingSignedFeeRange this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ClosingSignedFeeRange_free(this_obj_conv); +} + +int64_t __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) { + LDKClosingSignedFeeRange this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) { + LDKClosingSignedFeeRange this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val); +} + +int64_t __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) { + LDKClosingSignedFeeRange this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) { + LDKClosingSignedFeeRange this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val); +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) { + LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) { + LDKClosingSignedFeeRange orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + void __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) { LDKClosingSigned this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -15275,14 +16265,43 @@ void __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint ClosingSigned_set_signature(&this_ptr_conv, val_ref); } -uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) { +uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) { + LDKClosingSigned this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) { + LDKClosingSigned this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKClosingSignedFeeRange val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = ClosingSignedFeeRange_clone(&val_conv); + ClosingSigned_set_fee_range(&this_ptr_conv, val_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, uint32_t fee_range_arg) { LDKThirtyTwoBytes channel_id_arg_ref; CHECK(*((uint32_t*)channel_id_arg) == 32); memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32); LDKSignature signature_arg_ref; CHECK(*((uint32_t*)signature_arg) == 64); memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64); - LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref); + LDKClosingSignedFeeRange fee_range_arg_conv; + fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1)); + fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0); + fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv); + LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv); CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. uint64_t ret_ref = (uint64_t)ret_var.inner; @@ -16178,6 +17197,46 @@ uint32_t __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t or return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) { + LDKFourBytes addr_ref; + CHECK(*((uint32_t*)addr) == 4); + memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4); + LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress"); + *ret_copy = NetAddress_ipv4(addr_ref, port); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) { + LDKSixteenBytes addr_ref; + CHECK(*((uint32_t*)addr) == 16); + memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16); + LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress"); + *ret_copy = NetAddress_ipv6(addr_ref, port); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray addr, int16_t port) { + LDKTenBytes addr_ref; + CHECK(*((uint32_t*)addr) == 10); + memcpy(addr_ref.data, (uint8_t*)(addr + 4), 10); + LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress"); + *ret_copy = NetAddress_onion_v2(addr_ref, port); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) { + LDKThirtyTwoBytes ed25519_pubkey_ref; + CHECK(*((uint32_t*)ed25519_pubkey) == 32); + memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32); + LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress"); + *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + int8_tArray __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) { LDKNetAddress* obj_conv = (LDKNetAddress*)obj; LDKCVec_u8Z ret_var = NetAddress_write(obj_conv); @@ -17422,6 +18481,43 @@ uint32_t __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t o return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) { + LDKErrorMessage msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ErrorMessage_clone(&msg_conv); + LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction"); + *ret_copy = ErrorAction_disconnect_peer(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() { + LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction"); + *ret_copy = ErrorAction_ignore_error(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) { + LDKLevel a_conv = LDKLevel_from_js(a); + LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction"); + *ret_copy = ErrorAction_ignore_and_log(a_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) { + LDKErrorMessage msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ErrorMessage_clone(&msg_conv); + LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction"); + *ret_copy = ErrorAction_send_error_message(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + void __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) { LDKLightningError this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -17435,6 +18531,7 @@ jstring __attribute__((visibility("default"))) TS_LightningError_get_err(uint32 this_ptr_conv.is_owned = false; LDKStr ret_str = LightningError_get_err(&this_ptr_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -17744,6 +18841,34 @@ uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone( return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_update_message(uint32_t msg) { + LDKChannelUpdate msg_conv; + msg_conv.inner = (void*)(msg & (~1)); + msg_conv.is_owned = (msg & 1) || (msg == 0); + msg_conv = ChannelUpdate_clone(&msg_conv); + LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); + *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) { + LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); + *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) { + LDKPublicKey node_id_ref; + CHECK(*((uint32_t*)node_id) == 33); + memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33); + LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate"); + *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + void __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1); @@ -17818,23 +18943,43 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8 return (uint64_t)ret_conv; } -int8_tArray __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) { - LDKClosingSigned obj_conv; +int8_tArray __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) { + LDKClosingSigned obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ"); + *ret_conv = ClosingSigned_read(ser_ref); + return (uint64_t)ret_conv; +} + +int8_tArray __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) { + LDKClosingSignedFeeRange obj_conv; obj_conv.inner = (void*)(obj & (~1)); obj_conv.is_owned = false; - LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv); + LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv); int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); CVec_u8Z_free(ret_var); return ret_arr; } -uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) { +uint32_t __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = *((uint32_t*)ser); ser_ref.data = (int8_t*)(ser + 4); - LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ"); - *ret_conv = ClosingSigned_read(ser_ref); + LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ"); + *ret_conv = ClosingSignedFeeRange_read(ser_ref); return (uint64_t)ret_conv; } @@ -20428,6 +21573,191 @@ uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tA return (uint64_t)ret_conv; } +void __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) { + LDKShutdownScript this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + ShutdownScript_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) { + LDKShutdownScript orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) { + LDKInvalidShutdownScript this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + InvalidShutdownScript_free(this_obj_conv); +} + +int8_tArray __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) { + LDKInvalidShutdownScript this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + return ret_arr; +} + +void __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) { + LDKInvalidShutdownScript this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCVec_u8Z val_ref; + val_ref.datalen = *((uint32_t*)val); + val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen); + InvalidShutdownScript_set_script(&this_ptr_conv, val_ref); +} + +uint32_t __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) { + LDKCVec_u8Z script_arg_ref; + script_arg_ref.datalen = *((uint32_t*)script_arg); + script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen); + LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +int8_tArray __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) { + LDKShutdownScript obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +uint32_t __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ"); + *ret_conv = ShutdownScript_read(ser_ref); + return (uint64_t)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_ShutdownScript_new_p2pkh(int8_tArray pubkey_hash) { + unsigned char pubkey_hash_arr[20]; + CHECK(*((uint32_t*)pubkey_hash) == 20); + memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20); + unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr; + LDKShutdownScript ret_var = ShutdownScript_new_p2pkh(pubkey_hash_ref); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ShutdownScript_new_p2sh(int8_tArray script_hash) { + unsigned char script_hash_arr[20]; + CHECK(*((uint32_t*)script_hash) == 20); + memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 20); + unsigned char (*script_hash_ref)[20] = &script_hash_arr; + LDKShutdownScript ret_var = ShutdownScript_new_p2sh(script_hash_ref); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) { + unsigned char pubkey_hash_arr[20]; + CHECK(*((uint32_t*)pubkey_hash) == 20); + memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20); + unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr; + LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) { + unsigned char script_hash_arr[32]; + CHECK(*((uint32_t*)script_hash) == 32); + memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32); + unsigned char (*script_hash_ref)[32] = &script_hash_arr; + LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref); + CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t ret_ref = (uint64_t)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) { + LDKu8slice program_ref; + program_ref.datalen = *((uint32_t*)program); + program_ref.data = (int8_t*)(program + 4); + LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ"); + *ret_conv = ShutdownScript_new_witness_program(version, program_ref); + return (uint64_t)ret_conv; +} + +int8_tArray __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) { + LDKShutdownScript this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); + this_arg_conv = ShutdownScript_clone(&this_arg_conv); + LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv); + int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen); + CVec_u8Z_free(ret_var); + return ret_arr; +} + +int8_tArray __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) { + LDKShutdownScript this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33); + return ret_arr; +} + +jboolean __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) { + LDKShutdownScript this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKInitFeatures features_conv; + features_conv.inner = (void*)(features & (~1)); + features_conv.is_owned = false; + jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv); + return ret_val; +} + void __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) { LDKRouteHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -20910,6 +22240,56 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) { + LDKPublicKey our_node_id_ref; + CHECK(*((uint32_t*)our_node_id) == 33); + memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33); + LDKNetworkGraph network_conv; + network_conv.inner = (void*)(network & (~1)); + network_conv.is_owned = false; + LDKPublicKey payee_ref; + CHECK(*((uint32_t*)payee) == 33); + memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33); + LDKCVec_ChannelDetailsZ first_hops_constr; + LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL; + if (first_hops != 0) { + first_hops_constr.datalen = *((uint32_t*)first_hops); + if (first_hops_constr.datalen > 0) + first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + first_hops_constr.data = NULL; + uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4); + for (size_t q = 0; q < first_hops_constr.datalen; q++) { + uint32_t first_hops_conv_16 = first_hops_vals[q]; + LDKChannelDetails first_hops_conv_16_conv; + first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1)); + first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0); + first_hops_constr.data[q] = first_hops_conv_16_conv; + } + first_hops_ptr = &first_hops_constr; + } + LDKCVec_RouteHintZ last_hops_constr; + last_hops_constr.datalen = *((uint32_t*)last_hops); + if (last_hops_constr.datalen > 0) + last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements"); + else + last_hops_constr.data = NULL; + uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4); + for (size_t l = 0; l < last_hops_constr.datalen; l++) { + uint32_t last_hops_conv_11 = last_hops_vals[l]; + LDKRouteHint last_hops_conv_11_conv; + last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1)); + last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0); + last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv); + last_hops_constr.data[l] = last_hops_conv_11_conv; + } + LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); + LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ"); + *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv); + if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); } + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_t payee_features, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) { LDKPublicKey our_node_id_ref; CHECK(*((uint32_t*)our_node_id) == 33); @@ -20925,18 +22305,22 @@ uint32_t __attribute__((visibility("default"))) TS_get_route(int8_tArray our_no payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0); payee_features_conv = InvoiceFeatures_clone(&payee_features_conv); LDKCVec_ChannelDetailsZ first_hops_constr; - first_hops_constr.datalen = *((uint32_t*)first_hops); - if (first_hops_constr.datalen > 0) - first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); - else - first_hops_constr.data = NULL; - uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4); - for (size_t q = 0; q < first_hops_constr.datalen; q++) { - uint32_t first_hops_conv_16 = first_hops_vals[q]; - LDKChannelDetails first_hops_conv_16_conv; - first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1)); - first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0); - first_hops_constr.data[q] = first_hops_conv_16_conv; + LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL; + if (first_hops != 0) { + first_hops_constr.datalen = *((uint32_t*)first_hops); + if (first_hops_constr.datalen > 0) + first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements"); + else + first_hops_constr.data = NULL; + uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4); + for (size_t q = 0; q < first_hops_constr.datalen; q++) { + uint32_t first_hops_conv_16 = first_hops_vals[q]; + LDKChannelDetails first_hops_conv_16_conv; + first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1)); + first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0); + first_hops_constr.data[q] = first_hops_conv_16_conv; + } + first_hops_ptr = &first_hops_constr; } LDKCVec_RouteHintZ last_hops_constr; last_hops_constr.datalen = *((uint32_t*)last_hops); @@ -20955,8 +22339,8 @@ uint32_t __attribute__((visibility("default"))) TS_get_route(int8_tArray our_no } LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1); LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ"); - *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv); - FREE(first_hops_constr.data); + *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv); + if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); } return (uint64_t)ret_conv; } @@ -22105,6 +23489,7 @@ jstring __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_ this_arg_conv.is_owned = false; LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -22174,6 +23559,16 @@ uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_start(ui return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) { + LDKBackgroundProcessor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0); + // Warning: we need a move here but no clone is available for LDKBackgroundProcessor + LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ"); + *ret_conv = BackgroundProcessor_join(this_arg_conv); + return (uint64_t)ret_conv; +} + uint32_t __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) { LDKBackgroundProcessor this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); @@ -22404,6 +23799,26 @@ uint32_t __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_SiPrefix_milli() { + uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SiPrefix_micro() { + uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SiPrefix_nano() { + uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SiPrefix_pico() { + uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico()); + return ret_conv; +} + jboolean __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) { LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1); LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1); @@ -22423,6 +23838,31 @@ uint32_t __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_Currency_bitcoin() { + uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() { + uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Currency_regtest() { + uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Currency_simnet() { + uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_Currency_signet() { + uint32_t ret_conv = LDKCurrency_to_js(Currency_signet()); + return ret_conv; +} + jboolean __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) { LDKCurrency* a_conv = (LDKCurrency*)(a & ~1); LDKCurrency* b_conv = (LDKCurrency*)(b & ~1); @@ -22605,6 +24045,38 @@ uint32_t __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) { + + LDKCVec_u8Z program_ref; + program_ref.datalen = *((uint32_t*)program); + program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes"); + memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen); + LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback"); + *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) { + LDKTwentyBytes a_ref; + CHECK(*((uint32_t*)a) == 20); + memcpy(a_ref.data, (uint8_t*)(a + 4), 20); + LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback"); + *ret_copy = Fallback_pub_key_hash(a_ref); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) { + LDKTwentyBytes a_ref; + CHECK(*((uint32_t*)a) == 20); + memcpy(a_ref.data, (uint8_t*)(a + 4), 20); + LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback"); + *ret_copy = Fallback_script_hash(a_ref); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + jboolean __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) { LDKFallback* a_conv = (LDKFallback*)a; LDKFallback* b_conv = (LDKFallback*)b; @@ -23105,6 +24577,7 @@ jstring __attribute__((visibility("default"))) TS_Description_into_inner(uint32 this_arg_conv = Description_clone(&this_arg_conv); LDKStr ret_str = Description_into_inner(this_arg_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -23167,6 +24640,26 @@ uint32_t __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_CreationError_description_too_long() { + uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CreationError_route_too_long() { + uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() { + uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() { + uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds()); + return ret_conv; +} + jboolean __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) { LDKCreationError* a_conv = (LDKCreationError*)(a & ~1); LDKCreationError* b_conv = (LDKCreationError*)(b & ~1); @@ -23178,6 +24671,7 @@ jstring __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t LDKCreationError* o_conv = (LDKCreationError*)(o & ~1); LDKStr ret_str = CreationError_to_str(o_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -23187,6 +24681,46 @@ uint32_t __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t return ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SemanticError_no_description() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SemanticError_invalid_features() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id()); + return ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() { + uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature()); + return ret_conv; +} + jboolean __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) { LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1); LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1); @@ -23198,6 +24732,7 @@ jstring __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1); LDKStr ret_str = SemanticError_to_str(o_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -23216,6 +24751,21 @@ uint32_t __attribute__((visibility("default"))) TS_SignOrCreationError_clone(ui return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() { + LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError"); + *ret_copy = SignOrCreationError_sign_error(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) { + LDKCreationError a_conv = LDKCreationError_from_js(a); + LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError"); + *ret_copy = SignOrCreationError_creation_error(a_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + jboolean __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) { LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a; LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b; @@ -23227,6 +24777,7 @@ jstring __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(ui LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o; LDKStr ret_str = SignOrCreationError_to_str(o_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -23270,6 +24821,7 @@ jstring __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) { o_conv.is_owned = false; LDKStr ret_str = Invoice_to_str(&o_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -23279,6 +24831,7 @@ jstring __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint3 o_conv.is_owned = false; LDKStr ret_str = SignedRawInvoice_to_str(&o_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -23286,6 +24839,7 @@ jstring __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) { LDKCurrency* o_conv = (LDKCurrency*)(o & ~1); LDKStr ret_str = Currency_to_str(o_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; } @@ -23293,6 +24847,7 @@ jstring __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) { LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1); LDKStr ret_str = SiPrefix_to_str(o_conv); jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len); + Str_free(ret_str); return ret_conv; }