From: Matt Corallo Date: Fri, 12 Mar 2021 16:49:27 +0000 (-0500) Subject: Update bindings to latest upstream + ChannelMonitor_clone patch X-Git-Tag: v0.0.98~10^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-java;a=commitdiff_plain;h=7926bd31d1152339c3f1e26b5f70900981c53599 Update bindings to latest upstream + ChannelMonitor_clone patch --- diff --git a/liblightningjni_debug.so b/liblightningjni_debug.so new file mode 100755 index 00000000..57752d51 Binary files /dev/null and b/liblightningjni_debug.so differ diff --git a/liblightningjni_release.so b/liblightningjni_release.so index 3db2dbaf..5fec76cc 100755 Binary files a/liblightningjni_release.so and b/liblightningjni_release.so differ diff --git a/src/main/java/org/ldk/impl/bindings.java b/src/main/java/org/ldk/impl/bindings.java index 0a94d538..99196cc4 100644 --- a/src/main/java/org/ldk/impl/bindings.java +++ b/src/main/java/org/ldk/impl/bindings.java @@ -237,6 +237,9 @@ public class bindings { public static native boolean LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(long arg); + public static native long LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(long arg); + public static native long LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(long arg); public static native boolean LDKCResult_ChannelConfigDecodeErrorZ_result_ok(long arg); public static native long LDKCResult_ChannelConfigDecodeErrorZ_get_ok(long arg); public static native long LDKCResult_ChannelConfigDecodeErrorZ_get_err(long arg); @@ -1023,6 +1026,12 @@ public class bindings { public static native long CResult_ChannelFeaturesDecodeErrorZ_err(long e); // void CResult_ChannelFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelFeaturesDecodeErrorZ _res); public static native void CResult_ChannelFeaturesDecodeErrorZ_free(long _res); + // struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); + public static native long CResult_InvoiceFeaturesDecodeErrorZ_ok(long o); + // struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + public static native long CResult_InvoiceFeaturesDecodeErrorZ_err(long e); + // void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); + public static native void CResult_InvoiceFeaturesDecodeErrorZ_free(long _res); // struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); public static native long CResult_ChannelConfigDecodeErrorZ_ok(long o); // struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_err(struct LDKDecodeError e); @@ -3005,8 +3014,8 @@ public class bindings { public static native void PeerManager_socket_disconnected(long this_arg, long descriptor); // void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, bool no_connection_possible); public static native void PeerManager_disconnect_by_node_id(long this_arg, byte[] node_id, boolean no_connection_possible); - // void PeerManager_timer_tick_occured(const struct LDKPeerManager *NONNULL_PTR this_arg); - public static native void PeerManager_timer_tick_occured(long this_arg); + // void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); + public static native void PeerManager_timer_tick_occurred(long this_arg); // struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); public static native byte[] build_commitment_secret(byte[] commitment_seed, long idx); // struct LDKCResult_SecretKeyErrorZ derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); @@ -3255,12 +3264,16 @@ public class bindings { public static native long NodeFeatures_clone(long orig); // struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); public static native long ChannelFeatures_clone(long orig); + // struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); + public static native long InvoiceFeatures_clone(long orig); // void InitFeatures_free(struct LDKInitFeatures this_obj); public static native void InitFeatures_free(long this_obj); // void NodeFeatures_free(struct LDKNodeFeatures this_obj); public static native void NodeFeatures_free(long this_obj); // void ChannelFeatures_free(struct LDKChannelFeatures this_obj); public static native void ChannelFeatures_free(long this_obj); + // void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); + public static native void InvoiceFeatures_free(long this_obj); // MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); public static native long InitFeatures_empty(); // MUST_USE_RES struct LDKInitFeatures InitFeatures_known(void); @@ -3273,18 +3286,26 @@ public class bindings { public static native long ChannelFeatures_empty(); // MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_known(void); public static native long ChannelFeatures_known(); + // MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); + public static native long InvoiceFeatures_empty(); + // MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); + public static native long InvoiceFeatures_known(); // struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); public static native byte[] InitFeatures_write(long obj); // struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); public static native byte[] NodeFeatures_write(long obj); // struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); public static native byte[] ChannelFeatures_write(long obj); + // struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); + public static native byte[] InvoiceFeatures_write(long obj); // struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); public static native long InitFeatures_read(byte[] ser); // struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); public static native long NodeFeatures_read(byte[] ser); // struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); public static native long ChannelFeatures_read(byte[] ser); + // struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); + public static native long InvoiceFeatures_read(byte[] ser); // void RouteHop_free(struct LDKRouteHop this_obj); public static native void RouteHop_free(long this_obj); // struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); @@ -3347,8 +3368,8 @@ public class bindings { public static native void RouteHint_set_cltv_expiry_delta(long this_ptr, short val); // struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); public static native long RouteHint_clone(long orig); - // struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); - public static native long get_route(byte[] our_node_id, long network, byte[] payee, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger); + // struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); + public static native long get_route(byte[] our_node_id, long network, byte[] payee, long payee_features, long[] first_hops, long[] last_hops, long final_value_msat, int final_cltv, long logger); // void NetworkGraph_free(struct LDKNetworkGraph this_obj); public static native void NetworkGraph_free(long this_obj); // struct LDKNetworkGraph NetworkGraph_clone(const struct LDKNetworkGraph *NONNULL_PTR orig); diff --git a/src/main/java/org/ldk/structs/ChannelConfig.java b/src/main/java/org/ldk/structs/ChannelConfig.java index f465f6cf..c7a095bb 100644 --- a/src/main/java/org/ldk/structs/ChannelConfig.java +++ b/src/main/java/org/ldk/structs/ChannelConfig.java @@ -133,7 +133,7 @@ public class ChannelConfig extends CommonBase { } /** - * Creates a "default" ChannelConfig. See other documentaiton for details on what this implies. + * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used. */ public static ChannelConfig constructor_default() { long ret = bindings.ChannelConfig_default(); diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java index 3bab616c..2b1a7eee 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeConfig.java @@ -128,7 +128,7 @@ public class ChannelHandshakeConfig extends CommonBase { } /** - * Creates a "default" ChannelHandshakeConfig. See other documentaiton for details on what this implies. + * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. */ public static ChannelHandshakeConfig constructor_default() { long ret = bindings.ChannelHandshakeConfig_default(); diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java index e154ab0a..619b1051 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java @@ -243,8 +243,8 @@ public class ChannelHandshakeLimits extends CommonBase { * Not checking this value would be a security issue, as our peer would be able to set it to * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. * - * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value - * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ public short get_their_to_self_delay() { short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr); @@ -257,8 +257,8 @@ public class ChannelHandshakeLimits extends CommonBase { * Not checking this value would be a security issue, as our peer would be able to set it to * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. * - * Default value: MAX_LOCAL_BREAKDOWN_TIMEOUT (1008), which we also enforce as a maximum value - * so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts) + * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * reduce the loss of having useless locked funds (if your peer accepts) */ public void set_their_to_self_delay(short val) { bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val); @@ -285,7 +285,7 @@ public class ChannelHandshakeLimits extends CommonBase { } /** - * Creates a "default" ChannelHandshakeLimits. See other documentaiton for details on what this implies. + * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. */ public static ChannelHandshakeLimits constructor_default() { long ret = bindings.ChannelHandshakeLimits_default(); diff --git a/src/main/java/org/ldk/structs/PeerManager.java b/src/main/java/org/ldk/structs/PeerManager.java index 4a73a3a6..10341911 100644 --- a/src/main/java/org/ldk/structs/PeerManager.java +++ b/src/main/java/org/ldk/structs/PeerManager.java @@ -169,8 +169,8 @@ public class PeerManager extends CommonBase { * It will send pings to each peer and disconnect those which did not respond to the last round of pings. * Will most likely call send_data on all of the registered descriptors, thus, be very careful with reentrancy issues! */ - public void timer_tick_occured() { - bindings.PeerManager_timer_tick_occured(this.ptr); + public void timer_tick_occurred() { + bindings.PeerManager_timer_tick_occurred(this.ptr); } } diff --git a/src/main/java/org/ldk/structs/UserConfig.java b/src/main/java/org/ldk/structs/UserConfig.java index 7bf96f59..f3657641 100644 --- a/src/main/java/org/ldk/structs/UserConfig.java +++ b/src/main/java/org/ldk/structs/UserConfig.java @@ -99,7 +99,7 @@ public class UserConfig extends CommonBase { } /** - * Creates a "default" UserConfig. See other documentaiton for details on what this implies. + * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used. */ public static UserConfig constructor_default() { long ret = bindings.UserConfig_default(); diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index 5c05a422..b36f9c34 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -112,15 +112,15 @@ static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len FREE(err_buf); return err_conv; } -static jclass arr_of_J_clz = NULL; static jclass arr_of_B_clz = NULL; +static jclass arr_of_J_clz = NULL; JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) { - arr_of_J_clz = (*env)->FindClass(env, "[J"); - CHECK(arr_of_J_clz != NULL); - arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz); arr_of_B_clz = (*env)->FindClass(env, "[B"); CHECK(arr_of_B_clz != NULL); arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz); + arr_of_J_clz = (*env)->FindClass(env, "[J"); + CHECK(arr_of_J_clz != NULL); + arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz); } static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; } static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) { @@ -1298,6 +1298,27 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeatures long err_ref = (long)err_var.inner & ~1; return err_ref; } +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { + return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + LDKInvoiceFeatures res_var = (*val->contents.result); + CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long res_ref = (long)res_var.inner & ~1; + return res_ref; +} +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) { + LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref = (long)err_var.inner & ~1; + return err_ref; +} JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) { return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok; } @@ -7138,6 +7159,33 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecode CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { + LDKInvoiceFeatures o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + o_conv = InvoiceFeatures_clone(&o_conv); + LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ"); + *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv); + return (long)ret_conv; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_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_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ"); + *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv); + return (long)ret_conv; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) { LDKChannelConfig o_conv; o_conv.inner = (void*)(o & (~1)); @@ -17246,11 +17294,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1by_1n PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible); } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured(JNIEnv *env, jclass clz, int64_t this_arg) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) { LDKPeerManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - PeerManager_timer_tick_occured(&this_arg_conv); + PeerManager_timer_tick_occurred(&this_arg_conv); } JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) { @@ -18683,6 +18731,20 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIE return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKInvoiceFeatures orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv); + CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long ret_ref = (long)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKInitFeatures this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -18704,6 +18766,13 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv * ChannelFeatures_free(this_obj_conv); } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKInvoiceFeatures this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + InvoiceFeatures_free(this_obj_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) { LDKInitFeatures ret_var = InitFeatures_empty(); CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -18770,6 +18839,28 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIE return ret_ref; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) { + LDKInvoiceFeatures ret_var = InvoiceFeatures_empty(); + CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long ret_ref = (long)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) { + LDKInvoiceFeatures ret_var = InvoiceFeatures_known(); + CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long ret_ref = (long)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) { LDKInitFeatures obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -18803,6 +18894,17 @@ JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write( return ret_arr; } +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) { + LDKInvoiceFeatures obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv); + int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen); + (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data); + CVec_u8Z_free(ret_var); + return ret_arr; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = (*env)->GetArrayLength(env, ser); @@ -18833,6 +18935,16 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEn return (long)ret_conv; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = (*env)->GetArrayLength(env, ser); + ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL); + LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ"); + *ret_conv = InvoiceFeatures_read(ser_ref); + (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0); + return (long)ret_conv; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKRouteHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -19197,7 +19309,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *en return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jclass clz, int8_tArray our_node_id, int64_t network, int8_tArray payee, int64_t payee_features, int64_tArray first_hops, int64_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, int64_t logger) { LDKPublicKey our_node_id_ref; CHECK((*env)->GetArrayLength(env, our_node_id) == 33); (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form); @@ -19207,6 +19319,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jcl LDKPublicKey payee_ref; CHECK((*env)->GetArrayLength(env, payee) == 33); (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form); + LDKInvoiceFeatures payee_features_conv; + payee_features_conv.inner = (void*)(payee_features & (~1)); + 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 = (*env)->GetArrayLength(env, first_hops); if (first_hops_constr.datalen > 0) @@ -19244,7 +19360,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_get_1route(JNIEnv *env, jcl LDKLogger_JCalls_clone(logger_conv.this_arg); } LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ"); - *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv); + *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); return (long)ret_conv; } diff --git a/src/main/jni/org_ldk_impl_bindings.h b/src/main/jni/org_ldk_impl_bindings.h index 918e0b03..c102c708 100644 --- a/src/main/jni/org_ldk_impl_bindings.h +++ b/src/main/jni/org_ldk_impl_bindings.h @@ -703,6 +703,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDe JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1result_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKCResult_ChannelConfigDecodeErrorZ_result_ok @@ -3903,6 +3927,30 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecod JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: CResult_InvoiceFeaturesDecodeErrorZ_ok + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_InvoiceFeaturesDecodeErrorZ_err + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: CResult_InvoiceFeaturesDecodeErrorZ_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CResult_ChannelConfigDecodeErrorZ_ok @@ -11833,10 +11881,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1by_1n /* * Class: org_ldk_impl_bindings - * Method: PeerManager_timer_tick_occured + * Method: PeerManager_timer_tick_occurred * Signature: (J)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occured +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred (JNIEnv *, jclass, jlong); /* @@ -12831,6 +12879,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceFeatures_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: InitFeatures_free @@ -12855,6 +12911,14 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceFeatures_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: InitFeatures_empty @@ -12903,6 +12967,22 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceFeatures_empty + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceFeatures_known + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known + (JNIEnv *, jclass); + /* * Class: org_ldk_impl_bindings * Method: InitFeatures_write @@ -12927,6 +13007,14 @@ JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceFeatures_write + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: InitFeatures_read @@ -12951,6 +13039,14 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read (JNIEnv *, jclass, jbyteArray); +/* + * Class: org_ldk_impl_bindings + * Method: InvoiceFeatures_read + * Signature: ([B)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read + (JNIEnv *, jclass, jbyteArray); + /* * Class: org_ldk_impl_bindings * Method: RouteHop_free @@ -13202,10 +13298,10 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone /* * Class: org_ldk_impl_bindings * Method: get_route - * Signature: ([BJ[B[J[JJIJ)J + * Signature: ([BJ[BJ[J[JJIJ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_get_1route - (JNIEnv *, jclass, jbyteArray, jlong, jbyteArray, jlongArray, jlongArray, jlong, jint, jlong); + (JNIEnv *, jclass, jbyteArray, jlong, jbyteArray, jlong, jlongArray, jlongArray, jlong, jint, jlong); /* * Class: org_ldk_impl_bindings diff --git a/ts/bindings.c b/ts/bindings.c index d6b93137..b39872cb 100644 --- a/ts/bindings.c +++ b/ts/bindings.c @@ -913,6 +913,27 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDe long err_ref = (long)err_var.inner & ~1; return err_ref; } +jboolean __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) { + return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) { + LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1); + CHECK(val->result_ok); + LDKInvoiceFeatures res_var = (*val->contents.result); + CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long res_ref = (long)res_var.inner & ~1; + return res_ref; +} +uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) { + LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1); + CHECK(!val->result_ok); + LDKDecodeError err_var = (*val->contents.err); + CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long err_ref = (long)err_var.inner & ~1; + return err_ref; +} jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) { return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok; } @@ -6076,6 +6097,33 @@ void __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErr CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv); } +uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) { + LDKInvoiceFeatures o_conv; + o_conv.inner = (void*)(o & (~1)); + o_conv.is_owned = (o & 1) || (o == 0); + o_conv = InvoiceFeatures_clone(&o_conv); + LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ"); + *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv); + return (long)ret_conv; +} + +uint32_t __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_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_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ"); + *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv); + return (long)ret_conv; +} + +void __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv); +} + uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) { LDKChannelConfig o_conv; o_conv.inner = (void*)(o & (~1)); @@ -15964,11 +16012,11 @@ void __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_i PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible); } -void __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occured(uint32_t this_arg) { +void __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) { LDKPeerManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); this_arg_conv.is_owned = false; - PeerManager_timer_tick_occured(&this_arg_conv); + PeerManager_timer_tick_occurred(&this_arg_conv); } int8_tArray __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) { @@ -17393,6 +17441,20 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32 return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) { + LDKInvoiceFeatures orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv); + CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long ret_ref = (long)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + void __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) { LDKInitFeatures this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -17414,6 +17476,13 @@ void __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t th ChannelFeatures_free(this_obj_conv); } +void __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) { + LDKInvoiceFeatures this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + InvoiceFeatures_free(this_obj_conv); +} + uint32_t __attribute__((visibility("default"))) TS_InitFeatures_empty() { LDKInitFeatures ret_var = InitFeatures_empty(); CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -17480,6 +17549,28 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelFeatures_known() { return ret_ref; } +uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() { + LDKInvoiceFeatures ret_var = InvoiceFeatures_empty(); + CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long ret_ref = (long)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_known() { + LDKInvoiceFeatures ret_var = InvoiceFeatures_known(); + CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + long ret_ref = (long)ret_var.inner; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + int8_tArray __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) { LDKInitFeatures obj_conv; obj_conv.inner = (void*)(obj & (~1)); @@ -17513,6 +17604,17 @@ int8_tArray __attribute__((visibility("default"))) TS_ChannelFeatures_write(uin return ret_arr; } +int8_tArray __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) { + LDKInvoiceFeatures obj_conv; + obj_conv.inner = (void*)(obj & (~1)); + obj_conv.is_owned = false; + LDKCVec_u8Z ret_var = InvoiceFeatures_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_InitFeatures_read(int8_tArray ser) { LDKu8slice ser_ref; ser_ref.datalen = *((uint32_t*)ser); @@ -17540,6 +17642,15 @@ uint32_t __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tA return (long)ret_conv; } +uint32_t __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) { + LDKu8slice ser_ref; + ser_ref.datalen = *((uint32_t*)ser); + ser_ref.data = (int8_t*)(ser + 4); + LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ"); + *ret_conv = InvoiceFeatures_read(ser_ref); + return (long)ret_conv; +} + void __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) { LDKRouteHop this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -17903,7 +18014,7 @@ uint32_t __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t ori return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_get_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) { +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); memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33); @@ -17913,6 +18024,10 @@ uint32_t __attribute__((visibility("default"))) TS_get_route(int8_tArray our_no LDKPublicKey payee_ref; CHECK(*((uint32_t*)payee) == 33); memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33); + LDKInvoiceFeatures payee_features_conv; + payee_features_conv.inner = (void*)(payee_features & (~1)); + 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) @@ -17944,7 +18059,7 @@ 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, &first_hops_constr, last_hops_constr, final_value_msat, final_cltv, logger_conv); + *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); return (long)ret_conv; } diff --git a/ts/bindings.ts b/ts/bindings.ts index 326a84e2..efa5422f 100644 --- a/ts/bindings.ts +++ b/ts/bindings.ts @@ -352,6 +352,9 @@ public static native long new_empty_slice_vec(); public static native boolean LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(long arg); + public static native boolean LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(long arg); + public static native number LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(long arg); + public static native number LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(long arg); public static native boolean LDKCResult_ChannelConfigDecodeErrorZ_result_ok(long arg); public static native number LDKCResult_ChannelConfigDecodeErrorZ_get_ok(long arg); public static native number LDKCResult_ChannelConfigDecodeErrorZ_get_err(long arg); @@ -2242,6 +2245,30 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_ChannelFeaturesDecodeErrorZ_free(_res); // debug statements here } + // struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_ok(struct LDKInvoiceFeatures o); + export function CResult_InvoiceFeaturesDecodeErrorZ_ok(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_InvoiceFeaturesDecodeErrorZ_ok(o); + return nativeResponseValue; + } + // struct LDKCResult_InvoiceFeaturesDecodeErrorZ CResult_InvoiceFeaturesDecodeErrorZ_err(struct LDKDecodeError e); + export function CResult_InvoiceFeaturesDecodeErrorZ_err(e: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_InvoiceFeaturesDecodeErrorZ_err(e); + return nativeResponseValue; + } + // void CResult_InvoiceFeaturesDecodeErrorZ_free(struct LDKCResult_InvoiceFeaturesDecodeErrorZ _res); + export function CResult_InvoiceFeaturesDecodeErrorZ_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.CResult_InvoiceFeaturesDecodeErrorZ_free(_res); + // debug statements here + } // struct LDKCResult_ChannelConfigDecodeErrorZ CResult_ChannelConfigDecodeErrorZ_ok(struct LDKChannelConfig o); export function CResult_ChannelConfigDecodeErrorZ_ok(o: number): number { if(!isWasmInitialized) { @@ -10170,12 +10197,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.PeerManager_disconnect_by_node_id(this_arg, encodeArray(node_id), no_connection_possible); // debug statements here } - // void PeerManager_timer_tick_occured(const struct LDKPeerManager *NONNULL_PTR this_arg); - export function PeerManager_timer_tick_occured(this_arg: number): void { + // void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); + export function PeerManager_timer_tick_occurred(this_arg: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.PeerManager_timer_tick_occured(this_arg); + const nativeResponseValue = wasm.PeerManager_timer_tick_occurred(this_arg); // debug statements here } // struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); @@ -11170,6 +11197,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelFeatures_clone(orig); return nativeResponseValue; } + // struct LDKInvoiceFeatures InvoiceFeatures_clone(const struct LDKInvoiceFeatures *NONNULL_PTR orig); + export function InvoiceFeatures_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InvoiceFeatures_clone(orig); + return nativeResponseValue; + } // void InitFeatures_free(struct LDKInitFeatures this_obj); export function InitFeatures_free(this_obj: number): void { if(!isWasmInitialized) { @@ -11194,6 +11229,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelFeatures_free(this_obj); // debug statements here } + // void InvoiceFeatures_free(struct LDKInvoiceFeatures this_obj); + export function InvoiceFeatures_free(this_obj: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InvoiceFeatures_free(this_obj); + // debug statements here + } // MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); export function InitFeatures_empty(): number { if(!isWasmInitialized) { @@ -11242,6 +11285,22 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelFeatures_known(); return nativeResponseValue; } + // MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_empty(void); + export function InvoiceFeatures_empty(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InvoiceFeatures_empty(); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKInvoiceFeatures InvoiceFeatures_known(void); + export function InvoiceFeatures_known(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InvoiceFeatures_known(); + return nativeResponseValue; + } // struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); export function InitFeatures_write(obj: number): Uint8Array { if(!isWasmInitialized) { @@ -11266,6 +11325,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelFeatures_write(obj); return decodeArray(nativeResponseValue); } + // struct LDKCVec_u8Z InvoiceFeatures_write(const struct LDKInvoiceFeatures *NONNULL_PTR obj); + export function InvoiceFeatures_write(obj: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InvoiceFeatures_write(obj); + return decodeArray(nativeResponseValue); + } // struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); export function InitFeatures_read(ser: Uint8Array): number { if(!isWasmInitialized) { @@ -11290,6 +11357,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelFeatures_read(encodeArray(ser)); return nativeResponseValue; } + // struct LDKCResult_InvoiceFeaturesDecodeErrorZ InvoiceFeatures_read(struct LDKu8slice ser); + export function InvoiceFeatures_read(ser: Uint8Array): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.InvoiceFeatures_read(encodeArray(ser)); + return nativeResponseValue; + } // void RouteHop_free(struct LDKRouteHop this_obj); export function RouteHop_free(this_obj: number): void { if(!isWasmInitialized) { @@ -11538,12 +11613,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.RouteHint_clone(orig); return nativeResponseValue; } - // struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); - export function get_route(our_node_id: Uint8Array, network: number, payee: Uint8Array, first_hops: number[], last_hops: number[], final_value_msat: number, final_cltv: number, logger: number): number { + // struct LDKCResult_RouteLightningErrorZ get_route(struct LDKPublicKey our_node_id, const struct LDKNetworkGraph *NONNULL_PTR network, struct LDKPublicKey payee, struct LDKInvoiceFeatures payee_features, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKCVec_RouteHintZ last_hops, uint64_t final_value_msat, uint32_t final_cltv, struct LDKLogger logger); + export function get_route(our_node_id: Uint8Array, network: number, payee: Uint8Array, payee_features: number, first_hops: number[], last_hops: number[], final_value_msat: number, final_cltv: number, logger: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.get_route(encodeArray(our_node_id), network, encodeArray(payee), first_hops, last_hops, final_value_msat, final_cltv, logger); + const nativeResponseValue = wasm.get_route(encodeArray(our_node_id), network, encodeArray(payee), payee_features, first_hops, last_hops, final_value_msat, final_cltv, logger); return nativeResponseValue; } // void NetworkGraph_free(struct LDKNetworkGraph this_obj); diff --git a/ts/structs/PeerManager.ts b/ts/structs/PeerManager.ts index cc01f8bd..b6fd014f 100644 --- a/ts/structs/PeerManager.ts +++ b/ts/structs/PeerManager.ts @@ -74,8 +74,8 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.PeerManager_disconnect_by_node_id(this.ptr, node_id, no_connection_possible); } - public void timer_tick_occured() { - bindings.PeerManager_timer_tick_occured(this.ptr); + public void timer_tick_occurred() { + bindings.PeerManager_timer_tick_occurred(this.ptr); } }