From: Matt Corallo Date: Sat, 10 Jul 2021 00:17:29 +0000 (+0000) Subject: Update auto-generated bindings to LDK v0.0.99 X-Git-Tag: v0.0.99.1~3^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=12c3ea6f32816f379249a75863971a1c7e1089a1;p=ldk-java Update auto-generated bindings to LDK v0.0.99 --- diff --git a/src/main/java/org/ldk/enums/Level.java b/src/main/java/org/ldk/enums/Level.java index d4aae35f..e066ac32 100644 --- a/src/main/java/org/ldk/enums/Level.java +++ b/src/main/java/org/ldk/enums/Level.java @@ -4,12 +4,11 @@ package org.ldk.enums; * An enum representing the available verbosity levels of the logger. */ public enum Level { - LDKLevel_Off, - LDKLevel_Error, - LDKLevel_Warn, - LDKLevel_Info, - LDKLevel_Debug, LDKLevel_Trace, + LDKLevel_Debug, + LDKLevel_Info, + LDKLevel_Warn, + LDKLevel_Error, ; static native void init(); static { init(); } } \ No newline at end of file diff --git a/src/main/java/org/ldk/impl/bindings.java b/src/main/java/org/ldk/impl/bindings.java index cb8ac6cb..69a392fb 100644 --- a/src/main/java/org/ldk/impl/bindings.java +++ b/src/main/java/org/ldk/impl/bindings.java @@ -48,7 +48,7 @@ public class bindings { static native String get_lib_version_string(); public static String get_ldk_java_bindings_version() { - return "v0.0.98.5"; + return "v0.0.99.0"; } public static native String get_ldk_c_bindings_version(); public static native String get_ldk_version(); @@ -224,6 +224,10 @@ public class bindings { public final static class IgnoreError extends LDKErrorAction { IgnoreError() { } } + public final static class IgnoreAndLog extends LDKErrorAction { + public Level ignore_and_log; + IgnoreAndLog(Level ignore_and_log) { this.ignore_and_log = ignore_and_log; } + } public final static class SendErrorMessage extends LDKErrorAction { public long msg; SendErrorMessage(long msg) { this.msg = msg; } @@ -322,6 +326,11 @@ public class bindings { public long msg; BroadcastChannelUpdate(long msg) { this.msg = msg; } } + public final static class SendChannelUpdate extends LDKMessageSendEvent { + public byte[] node_id; + public long msg; + SendChannelUpdate(byte[] node_id, long msg) { this.node_id = node_id; this.msg = msg; } + } public final static class HandleError extends LDKMessageSendEvent { public byte[] node_id; public long action; @@ -448,6 +457,19 @@ public class bindings { public static native boolean LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(long arg); public static native long[] LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(long arg); public static native IOError LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(long arg); + public static class LDKCOption_u16Z { + private LDKCOption_u16Z() {} + public final static class Some extends LDKCOption_u16Z { + public short some; + Some(short some) { this.some = some; } + } + public final static class None extends LDKCOption_u16Z { + None() { } + } + static native void init(); + } + static { LDKCOption_u16Z.init(); } + public static native LDKCOption_u16Z LDKCOption_u16Z_ref_from_ptr(long ptr); public static class LDKAPIError { private LDKAPIError() {} public final static class APIMisuseError extends LDKAPIError { @@ -1415,6 +1437,14 @@ public class bindings { public static native long CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(IOError e); // void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(struct LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res); public static native void CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(long _res); + // struct LDKCOption_u16Z COption_u16Z_some(uint16_t o); + public static native long COption_u16Z_some(short o); + // struct LDKCOption_u16Z COption_u16Z_none(void); + public static native long COption_u16Z_none(); + // void COption_u16Z_free(struct LDKCOption_u16Z _res); + public static native void COption_u16Z_free(long _res); + // struct LDKCOption_u16Z COption_u16Z_clone(const struct LDKCOption_u16Z *NONNULL_PTR orig); + public static native long COption_u16Z_clone(long orig); // struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); public static native long CResult_NoneAPIErrorZ_ok(); // struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_err(struct LDKAPIError e); @@ -2055,7 +2085,7 @@ public class bindings { public static native void APIError_free(long this_ptr); // struct LDKAPIError APIError_clone(const struct LDKAPIError *NONNULL_PTR orig); public static native long APIError_clone(long orig); - // struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, struct LDKSecretKey sk); + // struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); public static native long sign(byte[] msg, byte[] sk); // struct LDKCResult_PublicKeyErrorZ recover_pk(struct LDKu8slice msg, struct LDKStr sig); public static native long recover_pk(byte[] msg, String sig); @@ -2133,10 +2163,14 @@ public class bindings { public static native long ChannelHandshakeLimits_default(); // void ChannelConfig_free(struct LDKChannelConfig this_obj); public static native void ChannelConfig_free(long this_obj); - // uint32_t ChannelConfig_get_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); - public static native int ChannelConfig_get_fee_proportional_millionths(long this_ptr); - // void ChannelConfig_set_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); - public static native void ChannelConfig_set_fee_proportional_millionths(long this_ptr, int val); + // uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); + public static native int ChannelConfig_get_forwarding_fee_proportional_millionths(long this_ptr); + // void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); + public static native void ChannelConfig_set_forwarding_fee_proportional_millionths(long this_ptr, int val); + // uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); + public static native int ChannelConfig_get_forwarding_fee_base_msat(long this_ptr); + // void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); + public static native void ChannelConfig_set_forwarding_fee_base_msat(long this_ptr, int val); // uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); public static native short ChannelConfig_get_cltv_expiry_delta(long this_ptr); // void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); @@ -2149,8 +2183,8 @@ public class bindings { public static native boolean ChannelConfig_get_commit_upfront_shutdown_pubkey(long this_ptr); // void ChannelConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannelConfig *NONNULL_PTR this_ptr, bool val); public static native void ChannelConfig_set_commit_upfront_shutdown_pubkey(long this_ptr, boolean val); - // MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); - public static native long ChannelConfig_new(int fee_proportional_millionths_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg); + // MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_proportional_millionths_arg, uint32_t forwarding_fee_base_msat_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); + public static native long ChannelConfig_new(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg); // struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); public static native long ChannelConfig_clone(long orig); // MUST_USE_RES struct LDKChannelConfig ChannelConfig_default(void); @@ -2173,12 +2207,28 @@ public class bindings { public static native long UserConfig_get_channel_options(long this_ptr); // void UserConfig_set_channel_options(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); public static native void UserConfig_set_channel_options(long this_ptr, long val); - // MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg); - public static native long UserConfig_new(long own_channel_config_arg, long peer_channel_config_limits_arg, long channel_options_arg); + // bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); + public static native boolean UserConfig_get_accept_forwards_to_priv_channels(long this_ptr); + // void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); + public static native void UserConfig_set_accept_forwards_to_priv_channels(long this_ptr, boolean val); + // MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg, bool accept_forwards_to_priv_channels_arg); + public static native long UserConfig_new(long own_channel_config_arg, long peer_channel_config_limits_arg, long channel_options_arg, boolean accept_forwards_to_priv_channels_arg); // struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); public static native long UserConfig_clone(long orig); // MUST_USE_RES struct LDKUserConfig UserConfig_default(void); public static native long UserConfig_default(); + // void BestBlock_free(struct LDKBestBlock this_obj); + public static native void BestBlock_free(long this_obj); + // struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); + public static native long BestBlock_clone(long orig); + // MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); + public static native long BestBlock_from_genesis(Network network); + // MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); + public static native long BestBlock_new(byte[] block_hash, int height); + // MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); + public static native byte[] BestBlock_block_hash(long this_arg); + // MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); + public static native int BestBlock_height(long this_arg); // enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig); public static native AccessError AccessError_clone(long orig); // void Access_free(struct LDKAccess this_ptr); @@ -2293,6 +2343,8 @@ public class bindings { public static native long[] ChannelMonitor_best_block_updated(long this_arg, byte[] header, int height, long broadcaster, long fee_estimator, long logger); // MUST_USE_RES struct LDKCVec_TxidZ ChannelMonitor_get_relevant_txids(const struct LDKChannelMonitor *NONNULL_PTR this_arg); public static native byte[][] ChannelMonitor_get_relevant_txids(long this_arg); + // MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + public static native long ChannelMonitor_current_best_block(long this_arg); // void Persist_free(struct LDKPersist this_ptr); public static native void Persist_free(long this_ptr); // struct LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ C2Tuple_BlockHashChannelMonitorZ_read(struct LDKu8slice ser, const struct LDKKeysInterface *NONNULL_PTR arg); @@ -2477,24 +2529,32 @@ public class bindings { public static native long ChainParameters_new(Network network_arg, long best_block_arg); // struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); public static native long ChainParameters_clone(long orig); - // void BestBlock_free(struct LDKBestBlock this_obj); - public static native void BestBlock_free(long this_obj); - // struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); - public static native long BestBlock_clone(long orig); - // MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); - public static native long BestBlock_from_genesis(Network network); - // MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); - public static native long BestBlock_new(byte[] block_hash, int height); - // MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); - public static native byte[] BestBlock_block_hash(long this_arg); - // MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); - public static native int BestBlock_height(long this_arg); + // void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); + public static native void ChannelCounterparty_free(long this_obj); + // struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + public static native byte[] ChannelCounterparty_get_node_id(long this_ptr); + // void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); + public static native void ChannelCounterparty_set_node_id(long this_ptr, byte[] val); + // struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + public static native long ChannelCounterparty_get_features(long this_ptr); + // void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); + public static native void ChannelCounterparty_set_features(long this_ptr, long val); + // uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + public static native long ChannelCounterparty_get_unspendable_punishment_reserve(long this_ptr); + // void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); + public static native void ChannelCounterparty_set_unspendable_punishment_reserve(long this_ptr, long val); + // struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); + public static native long ChannelCounterparty_clone(long orig); // void ChannelDetails_free(struct LDKChannelDetails this_obj); public static native void ChannelDetails_free(long this_obj); // const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; public static native byte[] ChannelDetails_get_channel_id(long this_ptr); // void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); public static native void ChannelDetails_set_channel_id(long this_ptr, byte[] val); + // struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + public static native long ChannelDetails_get_counterparty(long this_ptr); + // void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); + public static native void ChannelDetails_set_counterparty(long this_ptr, long val); // struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); public static native long ChannelDetails_get_funding_txo(long this_ptr); // void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); @@ -2503,18 +2563,14 @@ public class bindings { public static native long ChannelDetails_get_short_channel_id(long this_ptr); // void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); public static native void ChannelDetails_set_short_channel_id(long this_ptr, long val); - // struct LDKPublicKey ChannelDetails_get_remote_network_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - public static native byte[] ChannelDetails_get_remote_network_id(long this_ptr); - // void ChannelDetails_set_remote_network_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val); - public static native void ChannelDetails_set_remote_network_id(long this_ptr, byte[] val); - // struct LDKInitFeatures ChannelDetails_get_counterparty_features(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - public static native long ChannelDetails_get_counterparty_features(long this_ptr); - // void ChannelDetails_set_counterparty_features(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val); - public static native void ChannelDetails_set_counterparty_features(long this_ptr, long val); // uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); public static native long ChannelDetails_get_channel_value_satoshis(long this_ptr); // void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); public static native void ChannelDetails_set_channel_value_satoshis(long this_ptr, long val); + // struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + public static native long ChannelDetails_get_unspendable_punishment_reserve(long this_ptr); + // void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + public static native void ChannelDetails_set_unspendable_punishment_reserve(long this_ptr, long val); // uint64_t ChannelDetails_get_user_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); public static native long ChannelDetails_get_user_id(long this_ptr); // void ChannelDetails_set_user_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); @@ -2527,6 +2583,14 @@ public class bindings { public static native long ChannelDetails_get_inbound_capacity_msat(long this_ptr); // void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); public static native void ChannelDetails_set_inbound_capacity_msat(long this_ptr, long val); + // struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + public static native long ChannelDetails_get_confirmations_required(long this_ptr); + // void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + public static native void ChannelDetails_set_confirmations_required(long this_ptr, long val); + // struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + public static native long ChannelDetails_get_force_close_spend_delay(long this_ptr); + // void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); + public static native void ChannelDetails_set_force_close_spend_delay(long this_ptr, long val); // bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); public static native boolean ChannelDetails_get_is_outbound(long this_ptr); // void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); @@ -2543,6 +2607,8 @@ public class bindings { public static native boolean ChannelDetails_get_is_public(long this_ptr); // void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); public static native void ChannelDetails_set_is_public(long this_ptr, boolean val); + // MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKCOption_u64Z short_channel_id_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_id_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg); + public static native long ChannelDetails_new(byte[] channel_id_arg, long counterparty_arg, long funding_txo_arg, long short_channel_id_arg, long channel_value_satoshis_arg, long unspendable_punishment_reserve_arg, long user_id_arg, long outbound_capacity_msat_arg, long inbound_capacity_msat_arg, long confirmations_required_arg, long force_close_spend_delay_arg, boolean is_outbound_arg, boolean is_funding_locked_arg, boolean is_usable_arg, boolean is_public_arg); // struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); public static native long ChannelDetails_clone(long orig); // void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); @@ -2599,6 +2665,8 @@ public class bindings { public static native boolean ChannelManager_await_persistable_update_timeout(long this_arg, long max_wait); // void ChannelManager_await_persistable_update(const struct LDKChannelManager *NONNULL_PTR this_arg); public static native void ChannelManager_await_persistable_update(long this_arg); + // MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); + public static native long ChannelManager_current_best_block(long this_arg); // struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); public static native long ChannelManager_as_ChannelMessageHandler(long this_arg); // struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); diff --git a/src/main/java/org/ldk/structs/BestBlock.java b/src/main/java/org/ldk/structs/BestBlock.java index f4d69c1e..cda09d30 100644 --- a/src/main/java/org/ldk/structs/BestBlock.java +++ b/src/main/java/org/ldk/structs/BestBlock.java @@ -29,7 +29,8 @@ public class BestBlock extends CommonBase { } /** - * Returns the best block from the genesis of the given network. + * Constructs a `BestBlock` that represents the genesis block at height 0 of the given + * network. */ public static BestBlock from_genesis(Network network) { long ret = bindings.BestBlock_from_genesis(network); @@ -39,7 +40,7 @@ public class BestBlock extends CommonBase { } /** - * Returns the best block as identified by the given block hash and height. + * Returns a `BestBlock` as identified by the given block hash and height. */ public static BestBlock of(byte[] block_hash, int height) { long ret = bindings.BestBlock_new(block_hash, height); diff --git a/src/main/java/org/ldk/structs/ChannelConfig.java b/src/main/java/org/ldk/structs/ChannelConfig.java index 2056615c..eaef6ab8 100644 --- a/src/main/java/org/ldk/structs/ChannelConfig.java +++ b/src/main/java/org/ldk/structs/ChannelConfig.java @@ -20,26 +20,65 @@ public class ChannelConfig extends CommonBase { } /** - * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. + * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + * over the channel. * This may be allowed to change at runtime in a later update, however doing so must result in * update messages sent to notify all nodes of our updated relay fee. * * Default value: 0. */ - public int get_fee_proportional_millionths() { - int ret = bindings.ChannelConfig_get_fee_proportional_millionths(this.ptr); + public int get_forwarding_fee_proportional_millionths() { + int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr); return ret; } /** - * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi. + * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound + * over the channel. * This may be allowed to change at runtime in a later update, however doing so must result in * update messages sent to notify all nodes of our updated relay fee. * * Default value: 0. */ - public void set_fee_proportional_millionths(int val) { - bindings.ChannelConfig_set_fee_proportional_millionths(this.ptr, val); + public void set_forwarding_fee_proportional_millionths(int val) { + bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, val); + } + + /** + * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in + * excess of [`forwarding_fee_proportional_millionths`]. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * The default value of a single satoshi roughly matches the market rate on many routing nodes + * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through + * this node. + * + * Default value: 1000. + * + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + */ + public int get_forwarding_fee_base_msat() { + int ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr); + return ret; + } + + /** + * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in + * excess of [`forwarding_fee_proportional_millionths`]. + * This may be allowed to change at runtime in a later update, however doing so must result in + * update messages sent to notify all nodes of our updated relay fee. + * + * The default value of a single satoshi roughly matches the market rate on many routing nodes + * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through + * this node. + * + * Default value: 1000. + * + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + */ + public void set_forwarding_fee_base_msat(int val) { + bindings.ChannelConfig_set_forwarding_fee_base_msat(this.ptr, val); } /** @@ -100,7 +139,7 @@ public class ChannelConfig extends CommonBase { * This should only be set to true for nodes which expect to be online reliably. * * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set. + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. * * This cannot be changed after the initial channel handshake. * @@ -118,7 +157,7 @@ public class ChannelConfig extends CommonBase { * This should only be set to true for nodes which expect to be online reliably. * * As the node which funds a channel picks this value this will only apply for new outbound - * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set. + * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. * * This cannot be changed after the initial channel handshake. * @@ -166,8 +205,8 @@ public class ChannelConfig extends CommonBase { /** * Constructs a new ChannelConfig given each field */ - public static ChannelConfig of(int fee_proportional_millionths_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) { - long ret = bindings.ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); + public static ChannelConfig of(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) { + long ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); ChannelConfig ret_hu_conv = new ChannelConfig(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; diff --git a/src/main/java/org/ldk/structs/ChannelCounterparty.java b/src/main/java/org/ldk/structs/ChannelCounterparty.java new file mode 100644 index 00000000..c0bf5dd2 --- /dev/null +++ b/src/main/java/org/ldk/structs/ChannelCounterparty.java @@ -0,0 +1,96 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + + +/** + * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] + * to better separate parameters. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class ChannelCounterparty extends CommonBase { + ChannelCounterparty(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.ChannelCounterparty_free(ptr); } + } + + /** + * The node_id of our counterparty + */ + public byte[] get_node_id() { + byte[] ret = bindings.ChannelCounterparty_get_node_id(this.ptr); + return ret; + } + + /** + * The node_id of our counterparty + */ + public void set_node_id(byte[] val) { + bindings.ChannelCounterparty_set_node_id(this.ptr, val); + } + + /** + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. + */ + public InitFeatures get_features() { + long ret = bindings.ChannelCounterparty_get_features(this.ptr); + InitFeatures ret_hu_conv = new InitFeatures(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. + */ + public void set_features(InitFeatures val) { + bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr & ~1); + this.ptrs_to.add(val); + } + + /** + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + */ + public long get_unspendable_punishment_reserve() { + long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr); + return ret; + } + + /** + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + */ + public void set_unspendable_punishment_reserve(long val) { + bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val); + } + + /** + * Creates a copy of the ChannelCounterparty + */ + public ChannelCounterparty clone() { + long ret = bindings.ChannelCounterparty_clone(this.ptr); + ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/ChannelDetails.java b/src/main/java/org/ldk/structs/ChannelDetails.java index ca79d4b2..92f526b6 100644 --- a/src/main/java/org/ldk/structs/ChannelDetails.java +++ b/src/main/java/org/ldk/structs/ChannelDetails.java @@ -39,6 +39,24 @@ public class ChannelDetails extends CommonBase { bindings.ChannelDetails_set_channel_id(this.ptr, val); } + /** + * Parameters which apply to our counterparty. See individual fields for more information. + */ + public ChannelCounterparty get_counterparty() { + long ret = bindings.ChannelDetails_get_counterparty(this.ptr); + ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Parameters which apply to our counterparty. See individual fields for more information. + */ + public void set_counterparty(ChannelCounterparty val) { + bindings.ChannelDetails_set_counterparty(this.ptr, val == null ? 0 : val.ptr & ~1); + this.ptrs_to.add(val); + } + /** * The Channel's funding transaction output, if we've negotiated the funding transaction with * our counterparty already. @@ -85,55 +103,51 @@ public class ChannelDetails extends CommonBase { } /** - * The node_id of our counterparty + * The value, in satoshis, of this channel as appears in the funding output */ - public byte[] get_remote_network_id() { - byte[] ret = bindings.ChannelDetails_get_remote_network_id(this.ptr); + public long get_channel_value_satoshis() { + long ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr); return ret; } /** - * The node_id of our counterparty + * The value, in satoshis, of this channel as appears in the funding output */ - public void set_remote_network_id(byte[] val) { - bindings.ChannelDetails_set_remote_network_id(this.ptr, val); + public void set_channel_value_satoshis(long val) { + bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val); } /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat */ - public InitFeatures get_counterparty_features() { - long ret = bindings.ChannelDetails_get_counterparty_features(this.ptr); - InitFeatures ret_hu_conv = new InitFeatures(null, ret); + public Option_u64Z get_unspendable_punishment_reserve() { + long ret = bindings.ChannelDetails_get_unspendable_punishment_reserve(this.ptr); + Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. - */ - public void set_counterparty_features(InitFeatures val) { - bindings.ChannelDetails_set_counterparty_features(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); - } - - /** - * The value, in satoshis, of this channel as appears in the funding output - */ - public long get_channel_value_satoshis() { - long ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr); - return ret; - } - - /** - * The value, in satoshis, of this channel as appears in the funding output + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat */ - public void set_channel_value_satoshis(long val) { - bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val); + public void set_unspendable_punishment_reserve(Option_u64Z val) { + bindings.ChannelDetails_set_unspendable_punishment_reserve(this.ptr, val.ptr); } /** @@ -156,6 +170,10 @@ public class ChannelDetails extends CommonBase { * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not * available for inclusion in new outbound HTLCs). This further does not include any pending * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. */ public long get_outbound_capacity_msat() { long ret = bindings.ChannelDetails_get_outbound_capacity_msat(this.ptr); @@ -167,6 +185,10 @@ public class ChannelDetails extends CommonBase { * any pending HTLCs which are not yet fully resolved (and, thus, who's balance is not * available for inclusion in new outbound HTLCs). This further does not include any pending * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. */ public void set_outbound_capacity_msat(long val) { bindings.ChannelDetails_set_outbound_capacity_msat(this.ptr, val); @@ -178,6 +200,10 @@ public class ChannelDetails extends CommonBase { * available for inclusion in new inbound HTLCs). * Note that there are some corner cases not fully handled here, so the actual available * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. */ public long get_inbound_capacity_msat() { long ret = bindings.ChannelDetails_get_inbound_capacity_msat(this.ptr); @@ -190,11 +216,81 @@ public class ChannelDetails extends CommonBase { * available for inclusion in new inbound HTLCs). * Note that there are some corner cases not fully handled here, so the actual available * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. */ public void set_inbound_capacity_msat(long val) { bindings.ChannelDetails_set_inbound_capacity_msat(this.ptr, val); } + /** + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + */ + public Option_u32Z get_confirmations_required() { + long ret = bindings.ChannelDetails_get_confirmations_required(this.ptr); + Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + */ + public void set_confirmations_required(Option_u32Z val) { + bindings.ChannelDetails_set_confirmations_required(this.ptr, val.ptr); + } + + /** + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + */ + public Option_u16Z get_force_close_spend_delay() { + long ret = bindings.ChannelDetails_get_force_close_spend_delay(this.ptr); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + */ + public void set_force_close_spend_delay(Option_u16Z val) { + bindings.ChannelDetails_set_force_close_spend_delay(this.ptr, val.ptr); + } + /** * True if the channel was initiated (and thus funded) by us. */ @@ -214,7 +310,10 @@ public class ChannelDetails extends CommonBase { * True if the channel is confirmed, funding_locked messages have been exchanged, and the * channel is not currently being shut down. `funding_locked` message exchange implies the * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required */ public boolean get_is_funding_locked() { boolean ret = bindings.ChannelDetails_get_is_funding_locked(this.ptr); @@ -225,7 +324,10 @@ public class ChannelDetails extends CommonBase { * True if the channel is confirmed, funding_locked messages have been exchanged, and the * channel is not currently being shut down. `funding_locked` message exchange implies the * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required */ public void set_is_funding_locked(boolean val) { bindings.ChannelDetails_set_is_funding_locked(this.ptr, val); @@ -233,8 +335,7 @@ public class ChannelDetails extends CommonBase { /** * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) - * the peer is connected, (c) no monitor update failure is pending resolution, and (d) the - * channel is not currently negotiating a shutdown. + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. * * This is a strict superset of `is_funding_locked`. */ @@ -245,8 +346,7 @@ public class ChannelDetails extends CommonBase { /** * True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b) - * the peer is connected, (c) no monitor update failure is pending resolution, and (d) the - * channel is not currently negotiating a shutdown. + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. * * This is a strict superset of `is_funding_locked`. */ @@ -269,6 +369,18 @@ public class ChannelDetails extends CommonBase { bindings.ChannelDetails_set_is_public(this.ptr, val); } + /** + * Constructs a new ChannelDetails given each field + */ + public static ChannelDetails of(byte[] channel_id_arg, ChannelCounterparty counterparty_arg, OutPoint funding_txo_arg, Option_u64Z short_channel_id_arg, long channel_value_satoshis_arg, Option_u64Z unspendable_punishment_reserve_arg, long user_id_arg, long outbound_capacity_msat_arg, long inbound_capacity_msat_arg, Option_u32Z confirmations_required_arg, Option_u16Z force_close_spend_delay_arg, boolean is_outbound_arg, boolean is_funding_locked_arg, boolean is_usable_arg, boolean is_public_arg) { + long ret = bindings.ChannelDetails_new(channel_id_arg, counterparty_arg == null ? 0 : counterparty_arg.ptr & ~1, funding_txo_arg == null ? 0 : funding_txo_arg.ptr & ~1, short_channel_id_arg.ptr, channel_value_satoshis_arg, unspendable_punishment_reserve_arg.ptr, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg.ptr, force_close_spend_delay_arg.ptr, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); + ChannelDetails ret_hu_conv = new ChannelDetails(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(counterparty_arg); + ret_hu_conv.ptrs_to.add(funding_txo_arg); + return ret_hu_conv; + } + /** * Creates a copy of the ChannelDetails */ diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java index 39f6fd4e..c94c6ef3 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java @@ -161,11 +161,14 @@ public class ChannelHandshakeLimits extends CommonBase { } /** - * Set to force the incoming channel to match our announced channel preference in - * ChannelConfig. + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelConfig::announced_channel`]. * - * Default value: true, to make the default that no announced channels are possible (which is - * appropriate for any nodes which are not online very reliably). + * For a node which is not online reliably, this should be set to true and + * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. + * + * Default value: true. */ public boolean get_force_announced_channel_preference() { boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr); @@ -173,11 +176,14 @@ public class ChannelHandshakeLimits extends CommonBase { } /** - * Set to force the incoming channel to match our announced channel preference in - * ChannelConfig. + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelConfig::announced_channel`]. + * + * For a node which is not online reliably, this should be set to true and + * [`ChannelConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. * - * Default value: true, to make the default that no announced channels are possible (which is - * appropriate for any nodes which are not online very reliably). + * Default value: true. */ public void set_force_announced_channel_preference(boolean val) { bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val); diff --git a/src/main/java/org/ldk/structs/ChannelManager.java b/src/main/java/org/ldk/structs/ChannelManager.java index 734cca5a..60176ba1 100644 --- a/src/main/java/org/ldk/structs/ChannelManager.java +++ b/src/main/java/org/ldk/structs/ChannelManager.java @@ -105,6 +105,10 @@ public class ChannelManager extends CommonBase { * * Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is * greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000. + * + * Note that we do not check if you are currently connected to the given peer. If no + * connection is available, the outbound `open_channel` message may fail to send, resulting in + * the channel eventually being silently forgotten. */ public Result_NoneAPIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_id, UserConfig override_config) { long ret = bindings.ChannelManager_create_channel(this.ptr, their_network_key, channel_value_satoshis, push_msat, user_id, override_config == null ? 0 : override_config.ptr & ~1); @@ -517,6 +521,17 @@ public class ChannelManager extends CommonBase { bindings.ChannelManager_await_persistable_update(this.ptr); } + /** + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. + */ + public BestBlock current_best_block() { + long ret = bindings.ChannelManager_current_best_block(this.ptr); + BestBlock ret_hu_conv = new BestBlock(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + /** * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is diff --git a/src/main/java/org/ldk/structs/ChannelMonitor.java b/src/main/java/org/ldk/structs/ChannelMonitor.java index aef52a1d..68b04ace 100644 --- a/src/main/java/org/ldk/structs/ChannelMonitor.java +++ b/src/main/java/org/ldk/structs/ChannelMonitor.java @@ -337,4 +337,15 @@ public class ChannelMonitor extends CommonBase { return ret; } + /** + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. + */ + public BestBlock current_best_block() { + long ret = bindings.ChannelMonitor_current_best_block(this.ptr); + BestBlock ret_hu_conv = new BestBlock(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + } diff --git a/src/main/java/org/ldk/structs/ErrorAction.java b/src/main/java/org/ldk/structs/ErrorAction.java index e553c269..3eb5e9c3 100644 --- a/src/main/java/org/ldk/structs/ErrorAction.java +++ b/src/main/java/org/ldk/structs/ErrorAction.java @@ -25,6 +25,9 @@ public class ErrorAction extends CommonBase { if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreError.class) { return new IgnoreError(ptr, (bindings.LDKErrorAction.IgnoreError)raw_val); } + if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreAndLog.class) { + return new IgnoreAndLog(ptr, (bindings.LDKErrorAction.IgnoreAndLog)raw_val); + } if (raw_val.getClass() == bindings.LDKErrorAction.SendErrorMessage.class) { return new SendErrorMessage(ptr, (bindings.LDKErrorAction.SendErrorMessage)raw_val); } @@ -46,6 +49,13 @@ public class ErrorAction extends CommonBase { super(null, ptr); } } + public final static class IgnoreAndLog extends ErrorAction { + public final Level ignore_and_log; + private IgnoreAndLog(long ptr, bindings.LDKErrorAction.IgnoreAndLog obj) { + super(null, ptr); + this.ignore_and_log = obj.ignore_and_log; + } + } public final static class SendErrorMessage extends ErrorAction { public final ErrorMessage msg; private SendErrorMessage(long ptr, bindings.LDKErrorAction.SendErrorMessage obj) { diff --git a/src/main/java/org/ldk/structs/MessageHandler.java b/src/main/java/org/ldk/structs/MessageHandler.java index 46e66840..7077b4a2 100644 --- a/src/main/java/org/ldk/structs/MessageHandler.java +++ b/src/main/java/org/ldk/structs/MessageHandler.java @@ -20,7 +20,9 @@ public class MessageHandler extends CommonBase { /** * A message handler which handles messages specific to channels. Usually this is just a - * ChannelManager object or a ErroringMessageHandler. + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ public ChannelMessageHandler get_chan_handler() { long ret = bindings.MessageHandler_get_chan_handler(this.ptr); @@ -31,7 +33,9 @@ public class MessageHandler extends CommonBase { /** * A message handler which handles messages specific to channels. Usually this is just a - * ChannelManager object or a ErroringMessageHandler. + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ public void set_chan_handler(ChannelMessageHandler val) { bindings.MessageHandler_set_chan_handler(this.ptr, val == null ? 0 : val.ptr); @@ -40,7 +44,10 @@ public class MessageHandler extends CommonBase { /** * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler. + * graph. Usually this is just a [`NetGraphMsgHandler`] object or an + * [`IgnoringMessageHandler`]. + * + * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler */ public RoutingMessageHandler get_route_handler() { long ret = bindings.MessageHandler_get_route_handler(this.ptr); @@ -51,7 +58,10 @@ public class MessageHandler extends CommonBase { /** * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler. + * graph. Usually this is just a [`NetGraphMsgHandler`] object or an + * [`IgnoringMessageHandler`]. + * + * [`NetGraphMsgHandler`]: crate::routing::network_graph::NetGraphMsgHandler */ public void set_route_handler(RoutingMessageHandler val) { bindings.MessageHandler_set_route_handler(this.ptr, val == null ? 0 : val.ptr); diff --git a/src/main/java/org/ldk/structs/MessageSendEvent.java b/src/main/java/org/ldk/structs/MessageSendEvent.java index e1a703df..2885e0ca 100644 --- a/src/main/java/org/ldk/structs/MessageSendEvent.java +++ b/src/main/java/org/ldk/structs/MessageSendEvent.java @@ -63,6 +63,9 @@ public class MessageSendEvent extends CommonBase { if (raw_val.getClass() == bindings.LDKMessageSendEvent.BroadcastChannelUpdate.class) { return new BroadcastChannelUpdate(ptr, (bindings.LDKMessageSendEvent.BroadcastChannelUpdate)raw_val); } + if (raw_val.getClass() == bindings.LDKMessageSendEvent.SendChannelUpdate.class) { + return new SendChannelUpdate(ptr, (bindings.LDKMessageSendEvent.SendChannelUpdate)raw_val); + } if (raw_val.getClass() == bindings.LDKMessageSendEvent.HandleError.class) { return new HandleError(ptr, (bindings.LDKMessageSendEvent.HandleError)raw_val); } @@ -248,6 +251,18 @@ public class MessageSendEvent extends CommonBase { this.msg = msg_hu_conv; } } + public final static class SendChannelUpdate extends MessageSendEvent { + public final byte[] node_id; + public final ChannelUpdate msg; + private SendChannelUpdate(long ptr, bindings.LDKMessageSendEvent.SendChannelUpdate obj) { + super(null, ptr); + this.node_id = obj.node_id; + long msg = obj.msg; + ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg); + msg_hu_conv.ptrs_to.add(this); + this.msg = msg_hu_conv; + } + } public final static class HandleError extends MessageSendEvent { public final byte[] node_id; public final ErrorAction action; diff --git a/src/main/java/org/ldk/structs/Option_u16Z.java b/src/main/java/org/ldk/structs/Option_u16Z.java new file mode 100644 index 00000000..57a4c742 --- /dev/null +++ b/src/main/java/org/ldk/structs/Option_u16Z.java @@ -0,0 +1,74 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + + +/** + * An enum which can either contain a u16 or not + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class Option_u16Z extends CommonBase { + private Option_u16Z(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.COption_u16Z_free(ptr); } + } + static Option_u16Z constr_from_ptr(long ptr) { + bindings.LDKCOption_u16Z raw_val = bindings.LDKCOption_u16Z_ref_from_ptr(ptr); + if (raw_val.getClass() == bindings.LDKCOption_u16Z.Some.class) { + return new Some(ptr, (bindings.LDKCOption_u16Z.Some)raw_val); + } + if (raw_val.getClass() == bindings.LDKCOption_u16Z.None.class) { + return new None(ptr, (bindings.LDKCOption_u16Z.None)raw_val); + } + assert false; return null; // Unreachable without extending the (internal) bindings interface + } + + public final static class Some extends Option_u16Z { + public final short some; + private Some(long ptr, bindings.LDKCOption_u16Z.Some obj) { + super(null, ptr); + this.some = obj.some; + } + } + public final static class None extends Option_u16Z { + private None(long ptr, bindings.LDKCOption_u16Z.None obj) { + super(null, ptr); + } + } + /** + * Constructs a new COption_u16Z containing a u16 + */ + public static Option_u16Z some(short o) { + long ret = bindings.COption_u16Z_some(o); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Constructs a new COption_u16Z containing nothing + */ + public static Option_u16Z none() { + long ret = bindings.COption_u16Z_none(); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Creates a new COption_u16Z which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ + public Option_u16Z clone() { + long ret = bindings.COption_u16Z_clone(this.ptr); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/src/main/java/org/ldk/structs/PeerManager.java b/src/main/java/org/ldk/structs/PeerManager.java index d5138aad..3903b56b 100644 --- a/src/main/java/org/ldk/structs/PeerManager.java +++ b/src/main/java/org/ldk/structs/PeerManager.java @@ -7,14 +7,25 @@ import java.util.Arrays; /** - * A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket - * events into messages which it passes on to its MessageHandlers. + * A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls + * socket events into messages which it passes on to its [`MessageHandler`]. + * + * Locks are taken internally, so you must never assume that reentrancy from a + * [`SocketDescriptor`] call back into [`PeerManager`] methods will not deadlock. + * + * Calls to [`read_event`] will decode relevant messages and pass them to the + * [`ChannelMessageHandler`], likely doing message processing in-line. Thus, the primary form of + * parallelism in Rust-Lightning is in calls to [`read_event`]. Note, however, that calls to any + * [`PeerManager`] functions related to the same connection must occur only in serial, making new + * calls only after previous ones have returned. * * Rather than using a plain PeerManager, it is preferable to use either a SimpleArcPeerManager * a SimpleRefPeerManager, for conciseness. See their documentation for more details, but * essentially you should default to using a SimpleRefPeerManager, and use a * SimpleArcPeerManager when you require a PeerManager with a static lifetime, such as when * you're using lightning-net-tokio. + * + * [`read_event`]: PeerManager::read_event */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class PeerManager extends CommonBase { @@ -59,8 +70,10 @@ public class PeerManager extends CommonBase { * * Returns a small number of bytes to send to the remote node (currently always 50). * - * Panics if descriptor is duplicative with some other descriptor which has not yet had a - * socket_disconnected(). + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected()`]. + * + * [`socket_disconnected()`]: PeerManager::socket_disconnected */ public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, SocketDescriptor descriptor) { long ret = bindings.PeerManager_new_outbound_connection(this.ptr, their_node_id, descriptor == null ? 0 : descriptor.ptr); @@ -77,8 +90,10 @@ public class PeerManager extends CommonBase { * call socket_disconnected for the new descriptor but must disconnect the connection * immediately. * - * Panics if descriptor is duplicative with some other descriptor which has not yet had - * socket_disconnected called. + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected()`]. + * + * [`socket_disconnected()`]: PeerManager::socket_disconnected */ public Result_NonePeerHandleErrorZ new_inbound_connection(SocketDescriptor descriptor) { long ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor == null ? 0 : descriptor.ptr); @@ -92,12 +107,14 @@ public class PeerManager extends CommonBase { * * May return an Err to indicate that the connection should be closed. * - * Will most likely call send_data on the descriptor passed in (or the descriptor handed into - * new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The - * invariants around calling write_buffer_space_avail in case a write did not fully complete - * must still hold - be ready to call write_buffer_space_avail again if a write call generated - * here isn't sufficient! Panics if the descriptor was not previously registered in a - * new_\\*_connection event. + * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before + * returning. Thus, be very careful with reentrancy issues! The invariants around calling + * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be + * ready to call `[write_buffer_space_avail`] again if a write call generated here isn't + * sufficient! + * + * [`send_data`]: SocketDescriptor::send_data + * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail */ public Result_NonePeerHandleErrorZ write_buffer_space_avail(SocketDescriptor descriptor) { long ret = bindings.PeerManager_write_buffer_space_avail(this.ptr, descriptor == null ? 0 : descriptor.ptr); @@ -111,14 +128,16 @@ public class PeerManager extends CommonBase { * * May return an Err to indicate that the connection should be closed. * - * Will *not* call back into send_data on any descriptors to avoid reentrancy complexity. - * Thus, however, you almost certainly want to call process_events() after any read_event to - * generate send_data calls to handle responses. + * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. + * Thus, however, you should call [`process_events`] after any `read_event` to generate + * [`send_data`] calls to handle responses. * - * If Ok(true) is returned, further read_events should not be triggered until a send_data call - * on this file descriptor has resume_read set (preventing DoS issues in the send buffer). + * If `Ok(true)` is returned, further read_events should not be triggered until a + * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the + * send buffer). * - * Panics if the descriptor was not previously registered in a new_*_connection event. + * [`send_data`]: SocketDescriptor::send_data + * [`process_events`]: PeerManager::process_events */ public Result_boolPeerHandleErrorZ read_event(SocketDescriptor peer_descriptor, byte[] data) { long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor == null ? 0 : peer_descriptor.ptr, data); @@ -130,7 +149,14 @@ public class PeerManager extends CommonBase { /** * Checks for any events generated by our handlers and processes them. Includes sending most * response messages as well as messages generated by calls to handler functions directly (eg - * functions like ChannelManager::process_pending_htlc_forward or send_payment). + * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). + * + * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + * [`send_data`]: SocketDescriptor::send_data */ public void process_events() { bindings.PeerManager_process_events(this.ptr); @@ -138,13 +164,6 @@ public class PeerManager extends CommonBase { /** * Indicates that the given socket descriptor's connection is now closed. - * - * This must only be called if the socket has been disconnected by the peer or your own - * decision to disconnect it and must NOT be called in any case where other parts of this - * library (eg PeerHandleError, explicit disconnect_socket calls) instruct you to disconnect - * the peer. - * - * Panics if the descriptor was not previously registered in a successful new_*_connection event. */ public void socket_disconnected(SocketDescriptor descriptor) { bindings.PeerManager_socket_disconnected(this.ptr, descriptor == null ? 0 : descriptor.ptr); @@ -154,11 +173,13 @@ public class PeerManager extends CommonBase { /** * Disconnect a peer given its node id. * - * Set no_connection_possible to true to prevent any further connection with this peer, + * Set `no_connection_possible` to true to prevent any further connection with this peer, * force-closing any channels we have with it. * - * If a peer is connected, this will call `disconnect_socket` on the descriptor for the peer, - * so be careful about reentrancy issues. + * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the + * peer. Thus, be very careful about reentrancy issues. + * + * [`disconnect_socket`]: SocketDescriptor::disconnect_socket */ public void disconnect_by_node_id(byte[] node_id, boolean no_connection_possible) { bindings.PeerManager_disconnect_by_node_id(this.ptr, node_id, no_connection_possible); @@ -166,8 +187,13 @@ public class PeerManager extends CommonBase { /** * This function should be called roughly once every 30 seconds. - * 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! + * It will send pings to each peer and disconnect those which did not respond to the last + * round of pings. + * + * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * [`send_data`]: SocketDescriptor::send_data */ public void timer_tick_occurred() { bindings.PeerManager_timer_tick_occurred(this.ptr); diff --git a/src/main/java/org/ldk/structs/SocketDescriptor.java b/src/main/java/org/ldk/structs/SocketDescriptor.java index 7c993305..86fbfdec 100644 --- a/src/main/java/org/ldk/structs/SocketDescriptor.java +++ b/src/main/java/org/ldk/structs/SocketDescriptor.java @@ -12,11 +12,12 @@ import java.util.Arrays; * * For efficiency, Clone should be relatively cheap for this type. * - * You probably want to just extend an int and put a file descriptor in a struct and implement - * send_data. Note that if you are using a higher-level net library that may call close() itself, - * be careful to ensure you don't have races whereby you might register a new connection with an - * fd which is the same as a previous one which has yet to be removed via - * PeerManager::socket_disconnected(). + * Two descriptors may compare equal (by [`cmp::Eq`] and [`hash::Hash`]) as long as the original + * has been disconnected, the [`PeerManager`] has been informed of the disconnection (either by it + * having triggered the disconnection or a call to [`PeerManager::socket_disconnected`]), and no + * further calls to the [`PeerManager`] related to the original socket occur. This allows you to + * use a file descriptor for your SocketDescriptor directly, however for simplicity you may wish + * to simply use another value which is guaranteed to be globally unique instead. */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class SocketDescriptor extends CommonBase { @@ -37,25 +38,27 @@ public class SocketDescriptor extends CommonBase { * Attempts to send some data from the given slice to the peer. * * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. - * Note that in the disconnected case, socket_disconnected must still fire and further write - * attempts may occur until that time. + * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be + * called and further write attempts may occur until that time. * - * If the returned size is smaller than data.len(), a write_available event must - * trigger the next time more data can be written. Additionally, until the a send_data event - * completes fully, no further read_events should trigger on the same peer! + * If the returned size is smaller than `data.len()`, a + * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be + * written. Additionally, until a `send_data` event completes fully, no further + * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to + * prevent denial-of-service issues, you should not read or buffer any data from the socket + * until then. * - * If a read_event on this descriptor had previously returned true (indicating that read - * events should be paused to prevent DoS in the send buffer), resume_read may be set - * indicating that read events on this descriptor should resume. A resume_read of false does - * not* imply that further read events should be paused. + * If a [`PeerManager::read_event`] call on this descriptor had previously returned true + * (indicating that read events should be paused to prevent DoS in the send buffer), + * `resume_read` may be set indicating that read events on this descriptor should resume. A + * `resume_read` of false carries no meaning, and should not cause any action. */ long send_data(byte[] data, boolean resume_read); /** - * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no - * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with - * this descriptor. No socket_disconnected call should be generated as a result of this call, - * though races may occur whereby disconnect_socket is called after a call to - * socket_disconnected but prior to socket_disconnected returning. + * Disconnect the socket pointed to by this SocketDescriptor. + * + * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this + * call (doing so is a noop). */ void disconnect_socket(); /** @@ -96,17 +99,20 @@ public class SocketDescriptor extends CommonBase { * Attempts to send some data from the given slice to the peer. * * Returns the amount of data which was sent, possibly 0 if the socket has since disconnected. - * Note that in the disconnected case, socket_disconnected must still fire and further write - * attempts may occur until that time. + * Note that in the disconnected case, [`PeerManager::socket_disconnected`] must still be + * called and further write attempts may occur until that time. * - * If the returned size is smaller than data.len(), a write_available event must - * trigger the next time more data can be written. Additionally, until the a send_data event - * completes fully, no further read_events should trigger on the same peer! + * If the returned size is smaller than `data.len()`, a + * [`PeerManager::write_buffer_space_avail`] call must be made the next time more data can be + * written. Additionally, until a `send_data` event completes fully, no further + * [`PeerManager::read_event`] calls should be made for the same peer! Because this is to + * prevent denial-of-service issues, you should not read or buffer any data from the socket + * until then. * - * If a read_event on this descriptor had previously returned true (indicating that read - * events should be paused to prevent DoS in the send buffer), resume_read may be set - * indicating that read events on this descriptor should resume. A resume_read of false does - * not* imply that further read events should be paused. + * If a [`PeerManager::read_event`] call on this descriptor had previously returned true + * (indicating that read events should be paused to prevent DoS in the send buffer), + * `resume_read` may be set indicating that read events on this descriptor should resume. A + * `resume_read` of false carries no meaning, and should not cause any action. */ public long send_data(byte[] data, boolean resume_read) { long ret = bindings.SocketDescriptor_send_data(this.ptr, data, resume_read); @@ -114,11 +120,10 @@ public class SocketDescriptor extends CommonBase { } /** - * Disconnect the socket pointed to by this SocketDescriptor. Once this function returns, no - * more calls to write_buffer_space_avail, read_event or socket_disconnected may be made with - * this descriptor. No socket_disconnected call should be generated as a result of this call, - * though races may occur whereby disconnect_socket is called after a call to - * socket_disconnected but prior to socket_disconnected returning. + * Disconnect the socket pointed to by this SocketDescriptor. + * + * You do *not* need to call [`PeerManager::socket_disconnected`] with this socket after this + * call (doing so is a noop). */ public void disconnect_socket() { bindings.SocketDescriptor_disconnect_socket(this.ptr); diff --git a/src/main/java/org/ldk/structs/UserConfig.java b/src/main/java/org/ldk/structs/UserConfig.java index 3f5c2ba0..60234317 100644 --- a/src/main/java/org/ldk/structs/UserConfig.java +++ b/src/main/java/org/ldk/structs/UserConfig.java @@ -75,11 +75,56 @@ public class UserConfig extends CommonBase { this.ptrs_to.add(val); } + /** + * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a + * node which is not online reliably. + * + * For nodes which are not online reliably, you should set all channels to *not* be announced + * (using [`ChannelConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * ensure you are not exposed to any forwarding risk. + * + * Note that because you cannot change a channel's announced state after creation, there is no + * way to disable forwarding on public channels retroactively. Thus, in order to change a node + * from a publicly-announced forwarding node to a private non-forwarding node you must close + * all your channels and open new ones. For privacy, you should also change your node_id + * (swapping all private and public key material for new ones) at that time. + * + * Default value: false. + */ + public boolean get_accept_forwards_to_priv_channels() { + boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr); + return ret; + } + + /** + * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a + * node which is not online reliably. + * + * For nodes which are not online reliably, you should set all channels to *not* be announced + * (using [`ChannelConfig::announced_channel`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * ensure you are not exposed to any forwarding risk. + * + * Note that because you cannot change a channel's announced state after creation, there is no + * way to disable forwarding on public channels retroactively. Thus, in order to change a node + * from a publicly-announced forwarding node to a private non-forwarding node you must close + * all your channels and open new ones. For privacy, you should also change your node_id + * (swapping all private and public key material for new ones) at that time. + * + * Default value: false. + */ + public void set_accept_forwards_to_priv_channels(boolean val) { + bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val); + } + /** * Constructs a new UserConfig given each field */ - public static UserConfig of(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg) { - long ret = bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1); + public static UserConfig of(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg, boolean accept_forwards_to_priv_channels_arg) { + long ret = bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1, accept_forwards_to_priv_channels_arg); UserConfig ret_hu_conv = new UserConfig(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(own_channel_config_arg); diff --git a/src/main/jni/bindings.c b/src/main/jni/bindings.c index 77945305..88713602 100644 --- a/src/main/jni/bindings.c +++ b/src/main/jni/bindings.c @@ -133,7 +133,7 @@ static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) { } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) { - return str_ref_to_java(env, "v0.0.98.5", strlen("v0.0.98.5")); + return str_ref_to_java(env, "v0.0.99.0", strlen("v0.0.99.0")); } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) { return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version())); @@ -454,52 +454,46 @@ static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) { static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) { switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) { - case 0: return LDKLevel_Off; - case 1: return LDKLevel_Error; - case 2: return LDKLevel_Warn; - case 3: return LDKLevel_Info; - case 4: return LDKLevel_Debug; - case 5: return LDKLevel_Trace; + case 0: return LDKLevel_Trace; + case 1: return LDKLevel_Debug; + case 2: return LDKLevel_Info; + case 3: return LDKLevel_Warn; + case 4: return LDKLevel_Error; } abort(); } static jclass Level_class = NULL; -static jfieldID Level_LDKLevel_Off = NULL; -static jfieldID Level_LDKLevel_Error = NULL; -static jfieldID Level_LDKLevel_Warn = NULL; -static jfieldID Level_LDKLevel_Info = NULL; -static jfieldID Level_LDKLevel_Debug = NULL; static jfieldID Level_LDKLevel_Trace = NULL; +static jfieldID Level_LDKLevel_Debug = NULL; +static jfieldID Level_LDKLevel_Info = NULL; +static jfieldID Level_LDKLevel_Warn = NULL; +static jfieldID Level_LDKLevel_Error = NULL; JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) { Level_class = (*env)->NewGlobalRef(env, clz); CHECK(Level_class != NULL); - Level_LDKLevel_Off = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Off", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Off != NULL); - Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Error != NULL); - Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Warn != NULL); - Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Info != NULL); - Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Debug != NULL); Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;"); CHECK(Level_LDKLevel_Trace != NULL); + Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Debug != NULL); + Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Info != NULL); + Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Warn != NULL); + Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Error != NULL); } static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) { switch (val) { - case LDKLevel_Off: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Off); - case LDKLevel_Error: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error); - case LDKLevel_Warn: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn); - case LDKLevel_Info: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info); - case LDKLevel_Debug: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug); case LDKLevel_Trace: return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace); + case LDKLevel_Debug: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug); + case LDKLevel_Info: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info); + case LDKLevel_Warn: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn); + case LDKLevel_Error: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error); default: abort(); } } @@ -1468,6 +1462,8 @@ static jclass LDKErrorAction_DisconnectPeer_class = NULL; static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL; static jclass LDKErrorAction_IgnoreError_class = NULL; static jmethodID LDKErrorAction_IgnoreError_meth = NULL; +static jclass LDKErrorAction_IgnoreAndLog_class = NULL; +static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL; static jclass LDKErrorAction_SendErrorMessage_class = NULL; static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL; JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) { @@ -1481,6 +1477,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIE CHECK(LDKErrorAction_IgnoreError_class != NULL); LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "", "()V"); CHECK(LDKErrorAction_IgnoreError_meth != NULL); + LDKErrorAction_IgnoreAndLog_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;")); + CHECK(LDKErrorAction_IgnoreAndLog_class != NULL); + LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "", "(Lorg/ldk/enums/Level;)V"); + CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL); LDKErrorAction_SendErrorMessage_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;")); CHECK(LDKErrorAction_SendErrorMessage_class != NULL); @@ -1500,6 +1501,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1 case LDKErrorAction_IgnoreError: { return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth); } + case LDKErrorAction_IgnoreAndLog: { + jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log); + return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv); + } case LDKErrorAction_SendErrorMessage: { LDKErrorMessage msg_var = obj->send_error_message.msg; CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -1582,6 +1587,8 @@ static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL; static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL; static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL; static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL; +static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL; +static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL; static jclass LDKMessageSendEvent_HandleError_class = NULL; static jmethodID LDKMessageSendEvent_HandleError_meth = NULL; static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL; @@ -1663,6 +1670,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL); LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "", "(J)V"); CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL); + LDKMessageSendEvent_SendChannelUpdate_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;")); + CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL); + LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "", "([BJ)V"); + CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL); LDKMessageSendEvent_HandleError_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;")); CHECK(LDKMessageSendEvent_HandleError_class != NULL); @@ -1816,6 +1828,15 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref); } + case LDKMessageSendEvent_SendChannelUpdate: { + int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form); + LDKChannelUpdate msg_var = obj->send_channel_update.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref); + } case LDKMessageSendEvent_HandleError: { int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form); @@ -2941,6 +2962,34 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1B jclass err_conv = LDKIOError_to_java(env, (*val->contents.err)); return err_conv; } +static jclass LDKCOption_u16Z_Some_class = NULL; +static jmethodID LDKCOption_u16Z_Some_meth = NULL; +static jclass LDKCOption_u16Z_None_class = NULL; +static jmethodID LDKCOption_u16Z_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) { + LDKCOption_u16Z_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;")); + CHECK(LDKCOption_u16Z_Some_class != NULL); + LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "", "(S)V"); + CHECK(LDKCOption_u16Z_Some_meth != NULL); + LDKCOption_u16Z_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;")); + CHECK(LDKCOption_u16Z_None_class != NULL); + LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "", "()V"); + CHECK(LDKCOption_u16Z_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_u16Z_Some: { + return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some); + } + case LDKCOption_u16Z_None: { + return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth); + } + default: abort(); + } +} static jclass LDKAPIError_APIMisuseError_class = NULL; static jmethodID LDKAPIError_APIMisuseError_meth = NULL; static jclass LDKAPIError_FeeRateTooHigh_class = NULL; @@ -10421,6 +10470,35 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockH CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_some(o); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_u16Z_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) { LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_ok(); @@ -13254,9 +13332,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass cl LDKu8slice msg_ref; msg_ref.datalen = (*env)->GetArrayLength(env, msg); msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL); - LDKSecretKey sk_ref; + unsigned char sk_arr[32]; CHECK((*env)->GetArrayLength(env, sk) == 32); - (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_ref.bytes); + (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr); + unsigned char (*sk_ref)[32] = &sk_arr; LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ"); *ret_conv = sign(msg_ref, sk_ref); (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0); @@ -13576,19 +13655,34 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *en ChannelConfig_free(this_obj_conv); } -JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) { +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv); + int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv); return ret_val; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val); + ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val); +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val); } JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -13636,8 +13730,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1up ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) { - LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, 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); 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; @@ -13775,7 +13869,22 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1opti UserConfig_set_channel_options(&this_ptr_conv, val_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg) { +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) { LDKChannelHandshakeConfig own_channel_config_arg_conv; own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1)); own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0); @@ -13788,7 +13897,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1)); channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0); channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv); - LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv); + LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_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; @@ -13823,6 +13932,70 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv return ret_ref; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKBestBlock this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + BestBlock_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKBestBlock orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKBestBlock ret_var = BestBlock_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; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) { + LDKNetwork network_conv = LDKNetwork_from_java(env, network); + LDKBestBlock ret_var = BestBlock_from_genesis(network_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; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) { + LDKThirtyTwoBytes block_hash_ref; + CHECK((*env)->GetArrayLength(env, block_hash) == 32); + (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data); + LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); + 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; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int8_tArray ret_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data); + return ret_arr; +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int32_t ret_val = BestBlock_height(&this_arg_conv); + return ret_val; +} + JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1); jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv)); @@ -14574,6 +14747,20 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1r return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -15568,30 +15755,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIE return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKBestBlock this_obj_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKChannelCounterparty this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - BestBlock_free(this_obj_conv); + ChannelCounterparty_free(this_obj_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKBestBlock orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKBestBlock ret_var = BestBlock_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; +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int8_tArray ret_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form); + return ret_arr; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) { - LDKNetwork network_conv = LDKNetwork_from_java(env, network); - LDKBestBlock ret_var = BestBlock_from_genesis(network_conv); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKPublicKey val_ref; + CHECK((*env)->GetArrayLength(env, val) == 33); + (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form); + ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures ret_var = ChannelCounterparty_get_features(&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; @@ -15601,11 +15795,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JN return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) { - LDKThirtyTwoBytes block_hash_ref; - CHECK((*env)->GetArrayLength(env, block_hash) == 32); - (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data); - LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = InitFeatures_clone(&val_conv); + ChannelCounterparty_set_features(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKChannelCounterparty orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelCounterparty_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; @@ -15615,23 +15835,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, return ret_ref; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int8_tArray ret_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data); - return ret_arr; -} - -JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int32_t ret_val = BestBlock_height(&this_arg_conv); - return ret_val; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelDetails this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -15658,6 +15861,31 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1 ChannelDetails_set_channel_id(&this_ptr_conv, val_ref); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&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; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = ChannelCounterparty_clone(&val_conv); + ChannelDetails_set_counterparty(&this_ptr_conv, val_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -15701,63 +15929,37 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1ch ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int8_tArray ret_arr = (*env)->NewByteArray(env, 33); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form); - return ret_arr; + int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); + return ret_val; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKPublicKey val_ref; - CHECK((*env)->GetArrayLength(env, val) == 33); - (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form); - ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref); + ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&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; - } + LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z"); + *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures val_conv; - val_conv.inner = (void*)(val & (~1)); - val_conv.is_owned = (val & 1) || (val == 0); - val_conv = InitFeatures_clone(&val_conv); - ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); - return ret_val; -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); + LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -15805,6 +16007,42 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1 ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z"); + *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -15865,6 +16103,32 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1publi ChannelDetails_set_is_public(&this_ptr_conv, val); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) { + LDKThirtyTwoBytes channel_id_arg_ref; + CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32); + (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data); + LDKChannelCounterparty counterparty_arg_conv; + counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1)); + counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0); + counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv); + LDKOutPoint funding_txo_arg_conv; + funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1)); + funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); + funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); + LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); + LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_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; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKChannelDetails orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -16237,6 +16501,20 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persist ChannelManager_await_persistable_update(&this_arg_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelManager_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); diff --git a/src/main/jni/bindings.c.body b/src/main/jni/bindings.c.body index 6441e2bd..62287f97 100644 --- a/src/main/jni/bindings.c.body +++ b/src/main/jni/bindings.c.body @@ -131,7 +131,7 @@ static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) { } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1lib_1version_1string(JNIEnv *env, jclass _c) { - return str_ref_to_java(env, "v0.0.98.5", strlen("v0.0.98.5")); + return str_ref_to_java(env, "v0.0.99.0", strlen("v0.0.99.0")); } JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) { return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version())); @@ -452,52 +452,46 @@ static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) { static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) { switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) { - case 0: return LDKLevel_Off; - case 1: return LDKLevel_Error; - case 2: return LDKLevel_Warn; - case 3: return LDKLevel_Info; - case 4: return LDKLevel_Debug; - case 5: return LDKLevel_Trace; + case 0: return LDKLevel_Trace; + case 1: return LDKLevel_Debug; + case 2: return LDKLevel_Info; + case 3: return LDKLevel_Warn; + case 4: return LDKLevel_Error; } abort(); } static jclass Level_class = NULL; -static jfieldID Level_LDKLevel_Off = NULL; -static jfieldID Level_LDKLevel_Error = NULL; -static jfieldID Level_LDKLevel_Warn = NULL; -static jfieldID Level_LDKLevel_Info = NULL; -static jfieldID Level_LDKLevel_Debug = NULL; static jfieldID Level_LDKLevel_Trace = NULL; +static jfieldID Level_LDKLevel_Debug = NULL; +static jfieldID Level_LDKLevel_Info = NULL; +static jfieldID Level_LDKLevel_Warn = NULL; +static jfieldID Level_LDKLevel_Error = NULL; JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) { Level_class = (*env)->NewGlobalRef(env, clz); CHECK(Level_class != NULL); - Level_LDKLevel_Off = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Off", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Off != NULL); - Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Error != NULL); - Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Warn != NULL); - Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Info != NULL); - Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;"); - CHECK(Level_LDKLevel_Debug != NULL); Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;"); CHECK(Level_LDKLevel_Trace != NULL); + Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Debug != NULL); + Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Info != NULL); + Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Warn != NULL); + Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;"); + CHECK(Level_LDKLevel_Error != NULL); } static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) { switch (val) { - case LDKLevel_Off: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Off); - case LDKLevel_Error: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error); - case LDKLevel_Warn: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn); - case LDKLevel_Info: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info); - case LDKLevel_Debug: - return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug); case LDKLevel_Trace: return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace); + case LDKLevel_Debug: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug); + case LDKLevel_Info: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info); + case LDKLevel_Warn: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn); + case LDKLevel_Error: + return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error); default: abort(); } } @@ -1466,6 +1460,8 @@ static jclass LDKErrorAction_DisconnectPeer_class = NULL; static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL; static jclass LDKErrorAction_IgnoreError_class = NULL; static jmethodID LDKErrorAction_IgnoreError_meth = NULL; +static jclass LDKErrorAction_IgnoreAndLog_class = NULL; +static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL; static jclass LDKErrorAction_SendErrorMessage_class = NULL; static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL; JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) { @@ -1479,6 +1475,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIE CHECK(LDKErrorAction_IgnoreError_class != NULL); LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "", "()V"); CHECK(LDKErrorAction_IgnoreError_meth != NULL); + LDKErrorAction_IgnoreAndLog_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;")); + CHECK(LDKErrorAction_IgnoreAndLog_class != NULL); + LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "", "(Lorg/ldk/enums/Level;)V"); + CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL); LDKErrorAction_SendErrorMessage_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;")); CHECK(LDKErrorAction_SendErrorMessage_class != NULL); @@ -1498,6 +1499,10 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1 case LDKErrorAction_IgnoreError: { return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth); } + case LDKErrorAction_IgnoreAndLog: { + jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log); + return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv); + } case LDKErrorAction_SendErrorMessage: { LDKErrorMessage msg_var = obj->send_error_message.msg; CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -1580,6 +1585,8 @@ static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL; static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL; static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL; static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL; +static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL; +static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL; static jclass LDKMessageSendEvent_HandleError_class = NULL; static jmethodID LDKMessageSendEvent_HandleError_meth = NULL; static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL; @@ -1661,6 +1668,11 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL); LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "", "(J)V"); CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL); + LDKMessageSendEvent_SendChannelUpdate_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;")); + CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL); + LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "", "([BJ)V"); + CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL); LDKMessageSendEvent_HandleError_class = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;")); CHECK(LDKMessageSendEvent_HandleError_class != NULL); @@ -1814,6 +1826,15 @@ JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1f uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref); } + case LDKMessageSendEvent_SendChannelUpdate: { + int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form); + LDKChannelUpdate msg_var = obj->send_channel_update.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref); + } case LDKMessageSendEvent_HandleError: { int8_tArray node_id_arr = (*env)->NewByteArray(env, 33); (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form); @@ -2939,6 +2960,34 @@ JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1B jclass err_conv = LDKIOError_to_java(env, (*val->contents.err)); return err_conv; } +static jclass LDKCOption_u16Z_Some_class = NULL; +static jmethodID LDKCOption_u16Z_Some_meth = NULL; +static jclass LDKCOption_u16Z_None_class = NULL; +static jmethodID LDKCOption_u16Z_None_meth = NULL; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) { + LDKCOption_u16Z_Some_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;")); + CHECK(LDKCOption_u16Z_Some_class != NULL); + LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "", "(S)V"); + CHECK(LDKCOption_u16Z_Some_meth != NULL); + LDKCOption_u16Z_None_class = + (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;")); + CHECK(LDKCOption_u16Z_None_class != NULL); + LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "", "()V"); + CHECK(LDKCOption_u16Z_None_meth != NULL); +} +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) { + LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_u16Z_Some: { + return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some); + } + case LDKCOption_u16Z_None: { + return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth); + } + default: abort(); + } +} static jclass LDKAPIError_APIMisuseError_class = NULL; static jmethodID LDKAPIError_APIMisuseError_meth = NULL; static jclass LDKAPIError_FeeRateTooHigh_class = NULL; @@ -10419,6 +10468,35 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockH CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_some(o); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_u16Z_free(_res_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) { LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_ok(); @@ -13252,9 +13330,10 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass cl LDKu8slice msg_ref; msg_ref.datalen = (*env)->GetArrayLength(env, msg); msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL); - LDKSecretKey sk_ref; + unsigned char sk_arr[32]; CHECK((*env)->GetArrayLength(env, sk) == 32); - (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_ref.bytes); + (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr); + unsigned char (*sk_ref)[32] = &sk_arr; LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ"); *ret_conv = sign(msg_ref, sk_ref); (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0); @@ -13574,19 +13653,34 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *en ChannelConfig_free(this_obj_conv); } -JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) { +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv); + int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv); return ret_val; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val); + ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val); +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val); } JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -13634,8 +13728,8 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1up ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) { - LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, 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); 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; @@ -13773,7 +13867,22 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1opti UserConfig_set_channel_options(&this_ptr_conv, val_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg) { +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) { LDKChannelHandshakeConfig own_channel_config_arg_conv; own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1)); own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0); @@ -13786,7 +13895,7 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1)); channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0); channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv); - LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv); + LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_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; @@ -13821,6 +13930,70 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv return ret_ref; } +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKBestBlock this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + BestBlock_free(this_obj_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKBestBlock orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKBestBlock ret_var = BestBlock_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; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) { + LDKNetwork network_conv = LDKNetwork_from_java(env, network); + LDKBestBlock ret_var = BestBlock_from_genesis(network_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; +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) { + LDKThirtyTwoBytes block_hash_ref; + CHECK((*env)->GetArrayLength(env, block_hash) == 32); + (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data); + LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); + 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; +} + +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int8_tArray ret_arr = (*env)->NewByteArray(env, 32); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data); + return ret_arr; +} + +JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int32_t ret_val = BestBlock_height(&this_arg_conv); + return ret_val; +} + JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1); jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv)); @@ -14572,6 +14745,20 @@ JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1r return ret_arr; } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -15566,30 +15753,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIE return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) { - LDKBestBlock this_obj_conv; +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) { + LDKChannelCounterparty this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - BestBlock_free(this_obj_conv); + ChannelCounterparty_free(this_obj_conv); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) { - LDKBestBlock orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKBestBlock ret_var = BestBlock_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; +JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int8_tArray ret_arr = (*env)->NewByteArray(env, 33); + (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form); + return ret_arr; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) { - LDKNetwork network_conv = LDKNetwork_from_java(env, network); - LDKBestBlock ret_var = BestBlock_from_genesis(network_conv); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKPublicKey val_ref; + CHECK((*env)->GetArrayLength(env, val) == 33); + (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form); + ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures ret_var = ChannelCounterparty_get_features(&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; @@ -15599,11 +15793,37 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JN return ret_ref; } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) { - LDKThirtyTwoBytes block_hash_ref; - CHECK((*env)->GetArrayLength(env, block_hash) == 32); - (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data); - LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = InitFeatures_clone(&val_conv); + ChannelCounterparty_set_features(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv); + return ret_val; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) { + LDKChannelCounterparty orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelCounterparty_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; @@ -15613,23 +15833,6 @@ JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, return ret_ref; } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int8_tArray ret_arr = (*env)->NewByteArray(env, 32); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data); - return ret_arr; -} - -JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int32_t ret_val = BestBlock_height(&this_arg_conv); - return ret_val; -} - JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) { LDKChannelDetails this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -15656,6 +15859,31 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1 ChannelDetails_set_channel_id(&this_ptr_conv, val_ref); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&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; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = ChannelCounterparty_clone(&val_conv); + ChannelDetails_set_counterparty(&this_ptr_conv, val_conv); +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -15699,63 +15927,37 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1ch ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } -JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int8_tArray ret_arr = (*env)->NewByteArray(env, 33); - (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form); - return ret_arr; + int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); + return ret_val; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKPublicKey val_ref; - CHECK((*env)->GetArrayLength(env, val) == 33); - (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form); - ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref); + ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); } -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr) { +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&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; - } + LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z"); + *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures val_conv; - val_conv.inner = (void*)(val & (~1)); - val_conv.is_owned = (val & 1) || (val == 0); - val_conv = InitFeatures_clone(&val_conv); - ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv); -} - -JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); - return ret_val; -} - -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); + LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) { @@ -15803,6 +16005,42 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1 ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z"); + *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); +} + +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); +} + JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -15863,6 +16101,32 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1publi ChannelDetails_set_is_public(&this_ptr_conv, val); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) { + LDKThirtyTwoBytes channel_id_arg_ref; + CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32); + (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data); + LDKChannelCounterparty counterparty_arg_conv; + counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1)); + counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0); + counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv); + LDKOutPoint funding_txo_arg_conv; + funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1)); + funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); + funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); + LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); + LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_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; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) { LDKChannelDetails orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -16235,6 +16499,20 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persist ChannelManager_await_persistable_update(&this_arg_conv); } +JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelManager_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); diff --git a/src/main/jni/org_ldk_impl_bindings.h b/src/main/jni/org_ldk_impl_bindings.h index ec6b98da..75930552 100644 --- a/src/main/jni/org_ldk_impl_bindings.h +++ b/src/main/jni/org_ldk_impl_bindings.h @@ -1287,6 +1287,14 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tupl JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: LDKCOption_u16Z_ref_from_ptr + * Signature: (J)Lorg/ldk/impl/bindings/LDKCOption_u16Z; + */ +JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: LDKAPIError_ref_from_ptr @@ -5287,6 +5295,38 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1Block JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: COption_u16Z_some + * Signature: (S)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some + (JNIEnv *, jclass, jshort); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_u16Z_none + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none + (JNIEnv *, jclass); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_u16Z_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: COption_u16Z_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: CResult_NoneAPIErrorZ_ok @@ -8161,18 +8201,34 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free /* * Class: org_ldk_impl_bindings - * Method: ChannelConfig_get_fee_proportional_millionths + * Method: ChannelConfig_get_forwarding_fee_proportional_millionths + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelConfig_set_forwarding_fee_proportional_millionths + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1proportional_1millionths + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelConfig_get_forwarding_fee_base_msat * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1fee_1proportional_1millionths +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelConfig_set_fee_proportional_millionths + * Method: ChannelConfig_set_forwarding_fee_base_msat * Signature: (JI)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1fee_1proportional_1millionths +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1forwarding_1fee_1base_1msat (JNIEnv *, jclass, jlong, jint); /* @@ -8226,10 +8282,10 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1up /* * Class: org_ldk_impl_bindings * Method: ChannelConfig_new - * Signature: (ISZZ)J + * Signature: (IISZZ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new - (JNIEnv *, jclass, jint, jshort, jboolean, jboolean); + (JNIEnv *, jclass, jint, jint, jshort, jboolean, jboolean); /* * Class: org_ldk_impl_bindings @@ -8319,13 +8375,29 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1opt JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: UserConfig_get_accept_forwards_to_priv_channels + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: UserConfig_set_accept_forwards_to_priv_channels + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1forwards_1to_1priv_1channels + (JNIEnv *, jclass, jlong, jboolean); + /* * Class: org_ldk_impl_bindings * Method: UserConfig_new - * Signature: (JJJ)J + * Signature: (JJJZ)J */ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1new - (JNIEnv *, jclass, jlong, jlong, jlong); + (JNIEnv *, jclass, jlong, jlong, jlong, jboolean); /* * Class: org_ldk_impl_bindings @@ -8343,6 +8415,54 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_UserConfig_1default (JNIEnv *, jclass); +/* + * Class: org_ldk_impl_bindings + * Method: BestBlock_free + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: BestBlock_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: BestBlock_from_genesis + * Signature: (Lorg/ldk/enums/Network;)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis + (JNIEnv *, jclass, jobject); + +/* + * Class: org_ldk_impl_bindings + * Method: BestBlock_new + * Signature: ([BI)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BestBlock_1new + (JNIEnv *, jclass, jbyteArray, jint); + +/* + * Class: org_ldk_impl_bindings + * Method: BestBlock_block_hash + * Signature: (J)[B + */ +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: BestBlock_height + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_BestBlock_1height + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: AccessError_clone @@ -8799,6 +8919,14 @@ JNIEXPORT jlongArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1best_1bl JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: ChannelMonitor_current_best_block + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: Persist_free @@ -9537,50 +9665,66 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone /* * Class: org_ldk_impl_bindings - * Method: BestBlock_free + * Method: ChannelCounterparty_free * Signature: (J)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: BestBlock_clone - * Signature: (J)J + * Method: ChannelCounterparty_get_node_id + * Signature: (J)[B */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone +JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: BestBlock_from_genesis - * Signature: (Lorg/ldk/enums/Network;)J + * Method: ChannelCounterparty_set_node_id + * Signature: (J[B)V */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis - (JNIEnv *, jclass, jobject); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id + (JNIEnv *, jclass, jlong, jbyteArray); /* * Class: org_ldk_impl_bindings - * Method: BestBlock_new - * Signature: ([BI)J + * Method: ChannelCounterparty_get_features + * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_BestBlock_1new - (JNIEnv *, jclass, jbyteArray, jint); +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features + (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: BestBlock_block_hash - * Signature: (J)[B + * Method: ChannelCounterparty_set_features + * Signature: (JJ)V */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelCounterparty_get_unspendable_punishment_reserve + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: BestBlock_height - * Signature: (J)I + * Method: ChannelCounterparty_set_unspendable_punishment_reserve + * Signature: (JJ)V */ -JNIEXPORT jint JNICALL Java_org_ldk_impl_bindings_BestBlock_1height +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelCounterparty_clone + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone (JNIEnv *, jclass, jlong); /* @@ -9609,82 +9753,82 @@ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1 /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_funding_txo + * Method: ChannelDetails_get_counterparty * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_set_funding_txo + * Method: ChannelDetails_set_counterparty * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_short_channel_id + * Method: ChannelDetails_get_funding_txo * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_set_short_channel_id + * Method: ChannelDetails_set_funding_txo * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_remote_network_id - * Signature: (J)[B + * Method: ChannelDetails_get_short_channel_id + * Signature: (J)J */ -JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1remote_1network_1id +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_set_remote_network_id - * Signature: (J[B)V + * Method: ChannelDetails_set_short_channel_id + * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1remote_1network_1id - (JNIEnv *, jclass, jlong, jbyteArray); +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id + (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_counterparty_features + * Method: ChannelDetails_get_channel_value_satoshis * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty_1features +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_set_counterparty_features + * Method: ChannelDetails_set_channel_value_satoshis * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty_1features +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis (JNIEnv *, jclass, jlong, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_get_channel_value_satoshis + * Method: ChannelDetails_get_unspendable_punishment_reserve * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve (JNIEnv *, jclass, jlong); /* * Class: org_ldk_impl_bindings - * Method: ChannelDetails_set_channel_value_satoshis + * Method: ChannelDetails_set_unspendable_punishment_reserve * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve (JNIEnv *, jclass, jlong, jlong); /* @@ -9735,6 +9879,38 @@ JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_ JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat (JNIEnv *, jclass, jlong, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_get_confirmations_required + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_set_confirmations_required + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required + (JNIEnv *, jclass, jlong, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_get_force_close_spend_delay + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay + (JNIEnv *, jclass, jlong); + +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_set_force_close_spend_delay + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1force_1close_1spend_1delay + (JNIEnv *, jclass, jlong, jlong); + /* * Class: org_ldk_impl_bindings * Method: ChannelDetails_get_is_outbound @@ -9799,6 +9975,14 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1p JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public (JNIEnv *, jclass, jlong, jboolean); +/* + * Class: org_ldk_impl_bindings + * Method: ChannelDetails_new + * Signature: ([BJJJJJJJJJJZZZZ)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new + (JNIEnv *, jclass, jbyteArray, jlong, jlong, jlong, jlong, jlong, jlong, jlong, jlong, jlong, jlong, jboolean, jboolean, jboolean, jboolean); + /* * Class: org_ldk_impl_bindings * Method: ChannelDetails_clone @@ -10023,6 +10207,14 @@ JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1per JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update (JNIEnv *, jclass, jlong); +/* + * Class: org_ldk_impl_bindings + * Method: ChannelManager_current_best_block + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block + (JNIEnv *, jclass, jlong); + /* * Class: org_ldk_impl_bindings * Method: ChannelManager_as_ChannelMessageHandler diff --git a/src/main/jni/org_ldk_impl_bindings_LDKCOption_u16Z.h b/src/main/jni/org_ldk_impl_bindings_LDKCOption_u16Z.h new file mode 100644 index 00000000..b3d25935 --- /dev/null +++ b/src/main/jni/org_ldk_impl_bindings_LDKCOption_u16Z.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_ldk_impl_bindings_LDKCOption_u16Z */ + +#ifndef _Included_org_ldk_impl_bindings_LDKCOption_u16Z +#define _Included_org_ldk_impl_bindings_LDKCOption_u16Z +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_ldk_impl_bindings_LDKCOption_u16Z + * Method: init + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ts/bindings.c b/ts/bindings.c index e539908e..665c4f05 100644 --- a/ts/bindings.c +++ b/ts/bindings.c @@ -199,23 +199,21 @@ static inline int32_t LDKIOError_to_js(LDKIOError val) { } static inline LDKLevel LDKLevel_from_js(int32_t ord) { switch (ord) { - case 0: return LDKLevel_Off; - case 1: return LDKLevel_Error; - case 2: return LDKLevel_Warn; - case 3: return LDKLevel_Info; - case 4: return LDKLevel_Debug; - case 5: return LDKLevel_Trace; + case 0: return LDKLevel_Trace; + case 1: return LDKLevel_Debug; + case 2: return LDKLevel_Info; + case 3: return LDKLevel_Warn; + case 4: return LDKLevel_Error; } abort(); } static inline int32_t LDKLevel_to_js(LDKLevel val) { switch (val) { - case LDKLevel_Off: return 0; - case LDKLevel_Error: return 1; - case LDKLevel_Warn: return 2; - case LDKLevel_Info: return 3; - case LDKLevel_Debug: return 4; - case LDKLevel_Trace: return 5; + case LDKLevel_Trace: return 0; + case LDKLevel_Debug: return 1; + case LDKLevel_Info: return 2; + case LDKLevel_Warn: return 3; + case LDKLevel_Error: return 4; default: abort(); } } @@ -974,6 +972,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u case LDKErrorAction_IgnoreError: { return 0 /* LDKErrorAction - IgnoreError */; } + case LDKErrorAction_IgnoreAndLog: { + uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log); + return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv; + } case LDKErrorAction_SendErrorMessage: { LDKErrorMessage msg_var = obj->send_error_message.msg; CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -1132,6 +1134,15 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref; } + case LDKMessageSendEvent_SendChannelUpdate: { + int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33); + LDKChannelUpdate msg_var = obj->send_channel_update.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref; + } case LDKMessageSendEvent_HandleError: { int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33); @@ -2018,6 +2029,18 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_Bloc uint32_t err_conv = LDKIOError_to_js((*val->contents.err)); return err_conv; } +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) { + LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_u16Z_Some: { + return 0 /* LDKCOption_u16Z - Some */; (void) obj->some; + } + case LDKCOption_u16Z_None: { + return 0 /* LDKCOption_u16Z - None */; + } + default: abort(); + } +} uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) { LDKAPIError *obj = (LDKAPIError*)(ptr & ~1); switch(obj->tag) { @@ -7921,6 +7944,35 @@ void __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashCh CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv); } +uint32_t __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_some(o); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_u16Z_none() { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_u16Z_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) { + LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() { LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_ok(); @@ -10737,9 +10789,10 @@ uint32_t __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_t LDKu8slice msg_ref; msg_ref.datalen = *((uint32_t*)msg); msg_ref.data = (int8_t*)(msg + 4); - LDKSecretKey sk_ref; + unsigned char sk_arr[32]; CHECK(*((uint32_t*)sk) == 32); - memcpy(sk_ref.bytes, (uint8_t*)(sk + 4), 32); + memcpy(sk_arr, (uint8_t*)(sk + 4), 32); + unsigned char (*sk_ref)[32] = &sk_arr; LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ"); *ret_conv = sign(msg_ref, sk_ref); return (uint64_t)ret_conv; @@ -11056,19 +11109,34 @@ void __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this ChannelConfig_free(this_obj_conv); } -int32_t __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) { +int32_t __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val); +} + +int32_t __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv); + int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv); return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) { +void __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val); + ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val); } int16_t __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) { @@ -11116,8 +11184,8 @@ void __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val); } -uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) { - LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_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) { + 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); 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; @@ -11254,7 +11322,22 @@ void __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(u UserConfig_set_channel_options(&this_ptr_conv, val_conv); } -uint32_t __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg) { +jboolean __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val); +} + +uint32_t __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) { LDKChannelHandshakeConfig own_channel_config_arg_conv; own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1)); own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0); @@ -11267,7 +11350,7 @@ uint32_t __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_ channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1)); channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0); channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv); - LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv); + LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_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; @@ -11302,6 +11385,70 @@ uint32_t __attribute__((visibility("default"))) TS_UserConfig_default() { return ret_ref; } +void __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) { + LDKBestBlock this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + BestBlock_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) { + LDKBestBlock orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKBestBlock ret_var = BestBlock_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; +} + +uint32_t __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) { + LDKNetwork network_conv = LDKNetwork_from_js(network); + LDKBestBlock ret_var = BestBlock_from_genesis(network_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; +} + +uint32_t __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) { + LDKThirtyTwoBytes block_hash_ref; + CHECK(*((uint32_t*)block_hash) == 32); + memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32); + LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); + 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_BestBlock_block_hash(uint32_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32); + return ret_arr; +} + +int32_t __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int32_t ret_val = BestBlock_height(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) { LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1); uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv)); @@ -11963,6 +12110,20 @@ ptrArray __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_ return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + void __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -12949,30 +13110,37 @@ uint32_t __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32 return ret_ref; } -void __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) { - LDKBestBlock this_obj_conv; +void __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) { + LDKChannelCounterparty this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - BestBlock_free(this_obj_conv); + ChannelCounterparty_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) { - LDKBestBlock orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKBestBlock ret_var = BestBlock_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; +int8_tArray __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33); + return ret_arr; } -uint32_t __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) { - LDKNetwork network_conv = LDKNetwork_from_js(network); - LDKBestBlock ret_var = BestBlock_from_genesis(network_conv); +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKPublicKey val_ref; + CHECK(*((uint32_t*)val) == 33); + memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); + ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures ret_var = ChannelCounterparty_get_features(&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; @@ -12982,11 +13150,37 @@ uint32_t __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint3 return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) { - LDKThirtyTwoBytes block_hash_ref; - CHECK(*((uint32_t*)block_hash) == 32); - memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32); - LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = InitFeatures_clone(&val_conv); + ChannelCounterparty_set_features(&this_ptr_conv, val_conv); +} + +int64_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) { + LDKChannelCounterparty orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelCounterparty_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; @@ -12996,23 +13190,6 @@ uint32_t __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray bl return ret_ref; } -int8_tArray __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32); - return ret_arr; -} - -int32_t __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int32_t ret_val = BestBlock_height(&this_arg_conv); - return ret_val; -} - void __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) { LDKChannelDetails this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -13039,6 +13216,31 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(ui ChannelDetails_set_channel_id(&this_ptr_conv, val_ref); } +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&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_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = ChannelCounterparty_clone(&val_conv); + ChannelDetails_set_counterparty(&this_ptr_conv, val_conv); +} + uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -13082,63 +13284,37 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } -int8_tArray __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) { +int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33); - return ret_arr; + int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); + return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) { +void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKPublicKey val_ref; - CHECK(*((uint32_t*)val) == 33); - memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); - ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref); + ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); } -uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) { +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&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; - } + LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z"); + *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -void __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - LDKInitFeatures val_conv; - val_conv.inner = (void*)(val & (~1)); - val_conv.is_owned = (val & 1) || (val == 0); - val_conv = InitFeatures_clone(&val_conv); - ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv); -} - -int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); - return ret_val; -} - -void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) { +void __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); + LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) { @@ -13186,6 +13362,42 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capac ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val); } +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z"); + *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); +} + jboolean __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -13246,6 +13458,32 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uin ChannelDetails_set_is_public(&this_ptr_conv, val); } +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_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); + LDKChannelCounterparty counterparty_arg_conv; + counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1)); + counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0); + counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv); + LDKOutPoint funding_txo_arg_conv; + funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1)); + funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); + funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); + LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); + LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_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_ChannelDetails_clone(uint32_t orig) { LDKChannelDetails orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -13595,6 +13833,20 @@ void __attribute__((visibility("default"))) TS_ChannelManager_await_persistable ChannelManager_await_persistable_update(&this_arg_conv); } +uint32_t __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelManager_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); diff --git a/ts/bindings.c.body b/ts/bindings.c.body index dd99fe3c..739af011 100644 --- a/ts/bindings.c.body +++ b/ts/bindings.c.body @@ -197,23 +197,21 @@ static inline int32_t LDKIOError_to_js(LDKIOError val) { } static inline LDKLevel LDKLevel_from_js(int32_t ord) { switch (ord) { - case 0: return LDKLevel_Off; - case 1: return LDKLevel_Error; - case 2: return LDKLevel_Warn; - case 3: return LDKLevel_Info; - case 4: return LDKLevel_Debug; - case 5: return LDKLevel_Trace; + case 0: return LDKLevel_Trace; + case 1: return LDKLevel_Debug; + case 2: return LDKLevel_Info; + case 3: return LDKLevel_Warn; + case 4: return LDKLevel_Error; } abort(); } static inline int32_t LDKLevel_to_js(LDKLevel val) { switch (val) { - case LDKLevel_Off: return 0; - case LDKLevel_Error: return 1; - case LDKLevel_Warn: return 2; - case LDKLevel_Info: return 3; - case LDKLevel_Debug: return 4; - case LDKLevel_Trace: return 5; + case LDKLevel_Trace: return 0; + case LDKLevel_Debug: return 1; + case LDKLevel_Info: return 2; + case LDKLevel_Warn: return 3; + case LDKLevel_Error: return 4; default: abort(); } } @@ -972,6 +970,10 @@ uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(u case LDKErrorAction_IgnoreError: { return 0 /* LDKErrorAction - IgnoreError */; } + case LDKErrorAction_IgnoreAndLog: { + uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log); + return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv; + } case LDKErrorAction_SendErrorMessage: { LDKErrorMessage msg_var = obj->send_error_message.msg; CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. @@ -1130,6 +1132,15 @@ uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref; } + case LDKMessageSendEvent_SendChannelUpdate: { + int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33); + LDKChannelUpdate msg_var = obj->send_channel_update.msg; + CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this. + CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this. + uint64_t msg_ref = (uint64_t)msg_var.inner & ~1; + return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref; + } case LDKMessageSendEvent_HandleError: { int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33); @@ -2016,6 +2027,18 @@ uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_Bloc uint32_t err_conv = LDKIOError_to_js((*val->contents.err)); return err_conv; } +uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) { + LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1); + switch(obj->tag) { + case LDKCOption_u16Z_Some: { + return 0 /* LDKCOption_u16Z - Some */; (void) obj->some; + } + case LDKCOption_u16Z_None: { + return 0 /* LDKCOption_u16Z - None */; + } + default: abort(); + } +} uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) { LDKAPIError *obj = (LDKAPIError*)(ptr & ~1); switch(obj->tag) { @@ -7919,6 +7942,35 @@ void __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashCh CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv); } +uint32_t __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_some(o); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +uint32_t __attribute__((visibility("default"))) TS_COption_u16Z_none() { + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_none(); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) { + if ((_res & 1) != 0) return; + LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1); + FREE((void*)_res); + COption_u16Z_free(_res_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) { + LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = COption_u16Z_clone(orig_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() { LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ"); *ret_conv = CResult_NoneAPIErrorZ_ok(); @@ -10735,9 +10787,10 @@ uint32_t __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_t LDKu8slice msg_ref; msg_ref.datalen = *((uint32_t*)msg); msg_ref.data = (int8_t*)(msg + 4); - LDKSecretKey sk_ref; + unsigned char sk_arr[32]; CHECK(*((uint32_t*)sk) == 32); - memcpy(sk_ref.bytes, (uint8_t*)(sk + 4), 32); + memcpy(sk_arr, (uint8_t*)(sk + 4), 32); + unsigned char (*sk_ref)[32] = &sk_arr; LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ"); *ret_conv = sign(msg_ref, sk_ref); return (uint64_t)ret_conv; @@ -11054,19 +11107,34 @@ void __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this ChannelConfig_free(this_obj_conv); } -int32_t __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) { +int32_t __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) { + LDKChannelConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val); +} + +int32_t __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv); + int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv); return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) { +void __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) { LDKChannelConfig this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val); + ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val); } int16_t __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) { @@ -11114,8 +11182,8 @@ void __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val); } -uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) { - LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_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) { + 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); 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; @@ -11252,7 +11320,22 @@ void __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(u UserConfig_set_channel_options(&this_ptr_conv, val_conv); } -uint32_t __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg) { +jboolean __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) { + LDKUserConfig this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val); +} + +uint32_t __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) { LDKChannelHandshakeConfig own_channel_config_arg_conv; own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1)); own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0); @@ -11265,7 +11348,7 @@ uint32_t __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_ channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1)); channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0); channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv); - LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv); + LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_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; @@ -11300,6 +11383,70 @@ uint32_t __attribute__((visibility("default"))) TS_UserConfig_default() { return ret_ref; } +void __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) { + LDKBestBlock this_obj_conv; + this_obj_conv.inner = (void*)(this_obj & (~1)); + this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); + BestBlock_free(this_obj_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) { + LDKBestBlock orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKBestBlock ret_var = BestBlock_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; +} + +uint32_t __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) { + LDKNetwork network_conv = LDKNetwork_from_js(network); + LDKBestBlock ret_var = BestBlock_from_genesis(network_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; +} + +uint32_t __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) { + LDKThirtyTwoBytes block_hash_ref; + CHECK(*((uint32_t*)block_hash) == 32); + memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32); + LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); + 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_BestBlock_block_hash(uint32_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32); + return ret_arr; +} + +int32_t __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) { + LDKBestBlock this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + int32_t ret_val = BestBlock_height(&this_arg_conv); + return ret_val; +} + uint32_t __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) { LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1); uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv)); @@ -11961,6 +12108,20 @@ ptrArray __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_ return ret_arr; } +uint32_t __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) { + LDKChannelMonitor this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + void __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) { if ((this_ptr & 1) != 0) return; LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1); @@ -12947,30 +13108,37 @@ uint32_t __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32 return ret_ref; } -void __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) { - LDKBestBlock this_obj_conv; +void __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) { + LDKChannelCounterparty this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0); - BestBlock_free(this_obj_conv); + ChannelCounterparty_free(this_obj_conv); } -uint32_t __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) { - LDKBestBlock orig_conv; - orig_conv.inner = (void*)(orig & (~1)); - orig_conv.is_owned = false; - LDKBestBlock ret_var = BestBlock_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; +int8_tArray __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); + memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33); + return ret_arr; } -uint32_t __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) { - LDKNetwork network_conv = LDKNetwork_from_js(network); - LDKBestBlock ret_var = BestBlock_from_genesis(network_conv); +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKPublicKey val_ref; + CHECK(*((uint32_t*)val) == 33); + memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); + ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures ret_var = ChannelCounterparty_get_features(&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; @@ -12980,11 +13148,37 @@ uint32_t __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint3 return ret_ref; } -uint32_t __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) { - LDKThirtyTwoBytes block_hash_ref; - CHECK(*((uint32_t*)block_hash) == 32); - memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32); - LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height); +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKInitFeatures val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = InitFeatures_clone(&val_conv); + ChannelCounterparty_set_features(&this_ptr_conv, val_conv); +} + +int64_t __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv); + return ret_val; +} + +void __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) { + LDKChannelCounterparty this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) { + LDKChannelCounterparty orig_conv; + orig_conv.inner = (void*)(orig & (~1)); + orig_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelCounterparty_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; @@ -12994,23 +13188,6 @@ uint32_t __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray bl return ret_ref; } -int8_tArray __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32); - return ret_arr; -} - -int32_t __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) { - LDKBestBlock this_arg_conv; - this_arg_conv.inner = (void*)(this_arg & (~1)); - this_arg_conv.is_owned = false; - int32_t ret_val = BestBlock_height(&this_arg_conv); - return ret_val; -} - void __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) { LDKChannelDetails this_obj_conv; this_obj_conv.inner = (void*)(this_obj & (~1)); @@ -13037,6 +13214,31 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(ui ChannelDetails_set_channel_id(&this_ptr_conv, val_ref); } +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&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_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKChannelCounterparty val_conv; + val_conv.inner = (void*)(val & (~1)); + val_conv.is_owned = (val & 1) || (val == 0); + val_conv = ChannelCounterparty_clone(&val_conv); + ChannelDetails_set_counterparty(&this_ptr_conv, val_conv); +} + uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -13080,63 +13282,37 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv); } -int8_tArray __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) { +int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes"); - memcpy((uint8_t*)(ret_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33); - return ret_arr; + int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); + return ret_val; } -void __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) { +void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKPublicKey val_ref; - CHECK(*((uint32_t*)val) == 33); - memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33); - ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref); + ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); } -uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) { +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&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; - } + LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z"); + *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; return ret_ref; } -void __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - LDKInitFeatures val_conv; - val_conv.inner = (void*)(val & (~1)); - val_conv.is_owned = (val & 1) || (val == 0); - val_conv = InitFeatures_clone(&val_conv); - ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv); -} - -int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) { - LDKChannelDetails this_ptr_conv; - this_ptr_conv.inner = (void*)(this_ptr & (~1)); - this_ptr_conv.is_owned = false; - int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv); - return ret_val; -} - -void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) { +void __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); this_ptr_conv.is_owned = false; - ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val); + LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv); } int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) { @@ -13184,6 +13360,42 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capac ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val); } +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z"); + *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv); +} + +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z"); + *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv); + uint64_t ret_ref = (uint64_t)ret_copy; + return ret_ref; +} + +void __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) { + LDKChannelDetails this_ptr_conv; + this_ptr_conv.inner = (void*)(this_ptr & (~1)); + this_ptr_conv.is_owned = false; + LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1); + ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv); +} + jboolean __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) { LDKChannelDetails this_ptr_conv; this_ptr_conv.inner = (void*)(this_ptr & (~1)); @@ -13244,6 +13456,32 @@ void __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uin ChannelDetails_set_is_public(&this_ptr_conv, val); } +uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_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); + LDKChannelCounterparty counterparty_arg_conv; + counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1)); + counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0); + counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv); + LDKOutPoint funding_txo_arg_conv; + funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1)); + funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0); + funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv); + LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1); + LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1); + LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1); + LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1); + LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_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_ChannelDetails_clone(uint32_t orig) { LDKChannelDetails orig_conv; orig_conv.inner = (void*)(orig & (~1)); @@ -13593,6 +13831,20 @@ void __attribute__((visibility("default"))) TS_ChannelManager_await_persistable ChannelManager_await_persistable_update(&this_arg_conv); } +uint32_t __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) { + LDKChannelManager this_arg_conv; + this_arg_conv.inner = (void*)(this_arg & (~1)); + this_arg_conv.is_owned = false; + LDKBestBlock ret_var = ChannelManager_current_best_block(&this_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; + if (ret_var.is_owned) { + ret_ref |= 1; + } + return ret_ref; +} + uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) { LDKChannelManager this_arg_conv; this_arg_conv.inner = (void*)(this_arg & (~1)); diff --git a/ts/bindings.ts b/ts/bindings.ts index 54dae4ed..055daec0 100644 --- a/ts/bindings.ts +++ b/ts/bindings.ts @@ -299,6 +299,10 @@ public static native long new_empty_slice_vec(); export class IgnoreError extends LDKErrorAction { IgnoreError() { } } + export class IgnoreAndLog extends LDKErrorAction { + public Level ignore_and_log; + IgnoreAndLog(Level ignore_and_log) { this.ignore_and_log = ignore_and_log; } + } export class SendErrorMessage extends LDKErrorAction { public number msg; SendErrorMessage(number msg) { this.msg = msg; } @@ -397,6 +401,11 @@ public static native long new_empty_slice_vec(); public number msg; BroadcastChannelUpdate(number msg) { this.msg = msg; } } + export class SendChannelUpdate extends LDKMessageSendEvent { + public Uint8Array node_id; + public number msg; + SendChannelUpdate(Uint8Array node_id, number msg) { this.node_id = node_id; this.msg = msg; } + } export class HandleError extends LDKMessageSendEvent { public Uint8Array node_id; public number action; @@ -625,6 +634,19 @@ public static native long new_empty_slice_vec(); public static native boolean LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(long arg); public static native number[] LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(long arg); public static native IOError LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(long arg); + public static class LDKCOption_u16Z { + private LDKCOption_u16Z() {} + export class Some extends LDKCOption_u16Z { + public number some; + Some(number some) { this.some = some; } + } + export class None extends LDKCOption_u16Z { + None() { } + } + static native void init(); + } + static { LDKCOption_u16Z.init(); } + public static native LDKCOption_u16Z LDKCOption_u16Z_ref_from_ptr(long ptr); public static class LDKAPIError { private LDKAPIError() {} export class APIMisuseError extends LDKAPIError { @@ -3176,6 +3198,38 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res); // debug statements here } + // struct LDKCOption_u16Z COption_u16Z_some(uint16_t o); + export function COption_u16Z_some(o: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_u16Z_some(o); + return nativeResponseValue; + } + // struct LDKCOption_u16Z COption_u16Z_none(void); + export function COption_u16Z_none(): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_u16Z_none(); + return nativeResponseValue; + } + // void COption_u16Z_free(struct LDKCOption_u16Z _res); + export function COption_u16Z_free(_res: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_u16Z_free(_res); + // debug statements here + } + // struct LDKCOption_u16Z COption_u16Z_clone(const struct LDKCOption_u16Z *NONNULL_PTR orig); + export function COption_u16Z_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.COption_u16Z_clone(orig); + return nativeResponseValue; + } // struct LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_ok(void); export function CResult_NoneAPIErrorZ_ok(): number { if(!isWasmInitialized) { @@ -5736,7 +5790,7 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.APIError_clone(orig); return nativeResponseValue; } - // struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, struct LDKSecretKey sk); + // struct LDKCResult_StringErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); export function sign(msg: Uint8Array, sk: Uint8Array): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); @@ -6048,20 +6102,36 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelConfig_free(this_obj); // debug statements here } - // uint32_t ChannelConfig_get_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); - export function ChannelConfig_get_fee_proportional_millionths(this_ptr: number): number { + // uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); + export function ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelConfig_get_fee_proportional_millionths(this_ptr); + const nativeResponseValue = wasm.ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr); return nativeResponseValue; } - // void ChannelConfig_set_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); - export function ChannelConfig_set_fee_proportional_millionths(this_ptr: number, val: number): void { + // void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); + export function ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: number, val: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelConfig_set_fee_proportional_millionths(this_ptr, val); + const nativeResponseValue = wasm.ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr, val); + // debug statements here + } + // uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfig *NONNULL_PTR this_ptr); + export function ChannelConfig_get_forwarding_fee_base_msat(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelConfig_get_forwarding_fee_base_msat(this_ptr); + return nativeResponseValue; + } + // void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); + export function ChannelConfig_set_forwarding_fee_base_msat(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelConfig_set_forwarding_fee_base_msat(this_ptr, val); // debug statements here } // uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONNULL_PTR this_ptr); @@ -6112,12 +6182,12 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelConfig_set_commit_upfront_shutdown_pubkey(this_ptr, val); // debug statements here } - // MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); - export function ChannelConfig_new(fee_proportional_millionths_arg: number, cltv_expiry_delta_arg: number, announced_channel_arg: boolean, commit_upfront_shutdown_pubkey_arg: boolean): number { + // MUST_USE_RES struct LDKChannelConfig ChannelConfig_new(uint32_t forwarding_fee_proportional_millionths_arg, uint32_t forwarding_fee_base_msat_arg, uint16_t cltv_expiry_delta_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg); + export function ChannelConfig_new(forwarding_fee_proportional_millionths_arg: number, forwarding_fee_base_msat_arg: number, cltv_expiry_delta_arg: number, announced_channel_arg: boolean, commit_upfront_shutdown_pubkey_arg: boolean): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); + const nativeResponseValue = wasm.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); return nativeResponseValue; } // struct LDKChannelConfig ChannelConfig_clone(const struct LDKChannelConfig *NONNULL_PTR orig); @@ -6208,12 +6278,28 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.UserConfig_set_channel_options(this_ptr, val); // debug statements here } - // MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg); - export function UserConfig_new(own_channel_config_arg: number, peer_channel_config_limits_arg: number, channel_options_arg: number): number { + // bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); + export function UserConfig_get_accept_forwards_to_priv_channels(this_ptr: number): boolean { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.UserConfig_new(own_channel_config_arg, peer_channel_config_limits_arg, channel_options_arg); + const nativeResponseValue = wasm.UserConfig_get_accept_forwards_to_priv_channels(this_ptr); + return nativeResponseValue; + } + // void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); + export function UserConfig_set_accept_forwards_to_priv_channels(this_ptr: number, val: boolean): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.UserConfig_set_accept_forwards_to_priv_channels(this_ptr, val); + // debug statements here + } + // MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig own_channel_config_arg, struct LDKChannelHandshakeLimits peer_channel_config_limits_arg, struct LDKChannelConfig channel_options_arg, bool accept_forwards_to_priv_channels_arg); + export function UserConfig_new(own_channel_config_arg: number, peer_channel_config_limits_arg: number, channel_options_arg: number, accept_forwards_to_priv_channels_arg: boolean): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.UserConfig_new(own_channel_config_arg, peer_channel_config_limits_arg, channel_options_arg, accept_forwards_to_priv_channels_arg); return nativeResponseValue; } // struct LDKUserConfig UserConfig_clone(const struct LDKUserConfig *NONNULL_PTR orig); @@ -6232,6 +6318,54 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.UserConfig_default(); return nativeResponseValue; } + // void BestBlock_free(struct LDKBestBlock this_obj); + export function BestBlock_free(this_obj: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BestBlock_free(this_obj); + // debug statements here + } + // struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); + export function BestBlock_clone(orig: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BestBlock_clone(orig); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); + export function BestBlock_from_genesis(network: Network): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BestBlock_from_genesis(network); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); + export function BestBlock_new(block_hash: Uint8Array, height: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BestBlock_new(encodeArray(block_hash), height); + return nativeResponseValue; + } + // MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); + export function BestBlock_block_hash(this_arg: number): Uint8Array { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BestBlock_block_hash(this_arg); + return decodeArray(nativeResponseValue); + } + // MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); + export function BestBlock_height(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.BestBlock_height(this_arg); + return nativeResponseValue; + } // enum LDKAccessError AccessError_clone(const enum LDKAccessError *NONNULL_PTR orig); export function AccessError_clone(orig: number): AccessError { if(!isWasmInitialized) { @@ -6688,6 +6822,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelMonitor_get_relevant_txids(this_arg); return nativeResponseValue; } + // MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + export function ChannelMonitor_current_best_block(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelMonitor_current_best_block(this_arg); + return nativeResponseValue; + } // void Persist_free(struct LDKPersist this_ptr); export function Persist_free(this_ptr: number): void { if(!isWasmInitialized) { @@ -7424,52 +7566,68 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChainParameters_clone(orig); return nativeResponseValue; } - // void BestBlock_free(struct LDKBestBlock this_obj); - export function BestBlock_free(this_obj: number): void { + // void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); + export function ChannelCounterparty_free(this_obj: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BestBlock_free(this_obj); + const nativeResponseValue = wasm.ChannelCounterparty_free(this_obj); // debug statements here } - // struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); - export function BestBlock_clone(orig: number): number { + // struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + export function ChannelCounterparty_get_node_id(this_ptr: number): Uint8Array { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BestBlock_clone(orig); - return nativeResponseValue; + const nativeResponseValue = wasm.ChannelCounterparty_get_node_id(this_ptr); + return decodeArray(nativeResponseValue); } - // MUST_USE_RES struct LDKBestBlock BestBlock_from_genesis(enum LDKNetwork network); - export function BestBlock_from_genesis(network: Network): number { + // void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); + export function ChannelCounterparty_set_node_id(this_ptr: number, val: Uint8Array): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BestBlock_from_genesis(network); + const nativeResponseValue = wasm.ChannelCounterparty_set_node_id(this_ptr, encodeArray(val)); + // debug statements here + } + // struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + export function ChannelCounterparty_get_features(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelCounterparty_get_features(this_ptr); return nativeResponseValue; } - // MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); - export function BestBlock_new(block_hash: Uint8Array, height: number): number { + // void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); + export function ChannelCounterparty_set_features(this_ptr: number, val: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BestBlock_new(encodeArray(block_hash), height); + const nativeResponseValue = wasm.ChannelCounterparty_set_features(this_ptr, val); + // debug statements here + } + // uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + export function ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr); return nativeResponseValue; } - // MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); - export function BestBlock_block_hash(this_arg: number): Uint8Array { + // void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); + export function ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: number, val: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BestBlock_block_hash(this_arg); - return decodeArray(nativeResponseValue); + const nativeResponseValue = wasm.ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr, val); + // debug statements here } - // MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); - export function BestBlock_height(this_arg: number): number { + // struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); + export function ChannelCounterparty_clone(orig: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.BestBlock_height(this_arg); + const nativeResponseValue = wasm.ChannelCounterparty_clone(orig); return nativeResponseValue; } // void ChannelDetails_free(struct LDKChannelDetails this_obj); @@ -7496,6 +7654,22 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelDetails_set_channel_id(this_ptr, encodeArray(val)); // debug statements here } + // struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + export function ChannelDetails_get_counterparty(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelDetails_get_counterparty(this_ptr); + return nativeResponseValue; + } + // void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); + export function ChannelDetails_set_counterparty(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelDetails_set_counterparty(this_ptr, val); + // debug statements here + } // struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); export function ChannelDetails_get_funding_txo(this_ptr: number): number { if(!isWasmInitialized) { @@ -7528,52 +7702,36 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelDetails_set_short_channel_id(this_ptr, val); // debug statements here } - // struct LDKPublicKey ChannelDetails_get_remote_network_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - export function ChannelDetails_get_remote_network_id(this_ptr: number): Uint8Array { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.ChannelDetails_get_remote_network_id(this_ptr); - return decodeArray(nativeResponseValue); - } - // void ChannelDetails_set_remote_network_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val); - export function ChannelDetails_set_remote_network_id(this_ptr: number, val: Uint8Array): void { - if(!isWasmInitialized) { - throw new Error("initializeWasm() must be awaited first!"); - } - const nativeResponseValue = wasm.ChannelDetails_set_remote_network_id(this_ptr, encodeArray(val)); - // debug statements here - } - // struct LDKInitFeatures ChannelDetails_get_counterparty_features(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - export function ChannelDetails_get_counterparty_features(this_ptr: number): number { + // uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + export function ChannelDetails_get_channel_value_satoshis(this_ptr: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelDetails_get_counterparty_features(this_ptr); + const nativeResponseValue = wasm.ChannelDetails_get_channel_value_satoshis(this_ptr); return nativeResponseValue; } - // void ChannelDetails_set_counterparty_features(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val); - export function ChannelDetails_set_counterparty_features(this_ptr: number, val: number): void { + // void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + export function ChannelDetails_set_channel_value_satoshis(this_ptr: number, val: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelDetails_set_counterparty_features(this_ptr, val); + const nativeResponseValue = wasm.ChannelDetails_set_channel_value_satoshis(this_ptr, val); // debug statements here } - // uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - export function ChannelDetails_get_channel_value_satoshis(this_ptr: number): number { + // struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + export function ChannelDetails_get_unspendable_punishment_reserve(this_ptr: number): number { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelDetails_get_channel_value_satoshis(this_ptr); + const nativeResponseValue = wasm.ChannelDetails_get_unspendable_punishment_reserve(this_ptr); return nativeResponseValue; } - // void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); - export function ChannelDetails_set_channel_value_satoshis(this_ptr: number, val: number): void { + // void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + export function ChannelDetails_set_unspendable_punishment_reserve(this_ptr: number, val: number): void { if(!isWasmInitialized) { throw new Error("initializeWasm() must be awaited first!"); } - const nativeResponseValue = wasm.ChannelDetails_set_channel_value_satoshis(this_ptr, val); + const nativeResponseValue = wasm.ChannelDetails_set_unspendable_punishment_reserve(this_ptr, val); // debug statements here } // uint64_t ChannelDetails_get_user_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); @@ -7624,6 +7782,38 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelDetails_set_inbound_capacity_msat(this_ptr, val); // debug statements here } + // struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + export function ChannelDetails_get_confirmations_required(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelDetails_get_confirmations_required(this_ptr); + return nativeResponseValue; + } + // void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + export function ChannelDetails_set_confirmations_required(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelDetails_set_confirmations_required(this_ptr, val); + // debug statements here + } + // struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + export function ChannelDetails_get_force_close_spend_delay(this_ptr: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelDetails_get_force_close_spend_delay(this_ptr); + return nativeResponseValue; + } + // void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); + export function ChannelDetails_set_force_close_spend_delay(this_ptr: number, val: number): void { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelDetails_set_force_close_spend_delay(this_ptr, val); + // debug statements here + } // bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); export function ChannelDetails_get_is_outbound(this_ptr: number): boolean { if(!isWasmInitialized) { @@ -7688,6 +7878,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelDetails_set_is_public(this_ptr, val); // debug statements here } + // MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKCOption_u64Z short_channel_id_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, uint64_t user_id_arg, uint64_t outbound_capacity_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_funding_locked_arg, bool is_usable_arg, bool is_public_arg); + export function ChannelDetails_new(channel_id_arg: Uint8Array, counterparty_arg: number, funding_txo_arg: number, short_channel_id_arg: number, channel_value_satoshis_arg: number, unspendable_punishment_reserve_arg: number, user_id_arg: number, outbound_capacity_msat_arg: number, inbound_capacity_msat_arg: number, confirmations_required_arg: number, force_close_spend_delay_arg: number, is_outbound_arg: boolean, is_funding_locked_arg: boolean, is_usable_arg: boolean, is_public_arg: boolean): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelDetails_new(encodeArray(channel_id_arg), counterparty_arg, funding_txo_arg, short_channel_id_arg, channel_value_satoshis_arg, unspendable_punishment_reserve_arg, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg, force_close_spend_delay_arg, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); + return nativeResponseValue; + } // struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); export function ChannelDetails_clone(orig: number): number { if(!isWasmInitialized) { @@ -7912,6 +8110,14 @@ public static native long new_empty_slice_vec(); const nativeResponseValue = wasm.ChannelManager_await_persistable_update(this_arg); // debug statements here } + // MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); + export function ChannelManager_current_best_block(this_arg: number): number { + if(!isWasmInitialized) { + throw new Error("initializeWasm() must be awaited first!"); + } + const nativeResponseValue = wasm.ChannelManager_current_best_block(this_arg); + return nativeResponseValue; + } // struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); export function ChannelManager_as_ChannelMessageHandler(this_arg: number): number { if(!isWasmInitialized) { diff --git a/ts/enums/Level.ts b/ts/enums/Level.ts index 1c3eb114..ba44f740 100644 --- a/ts/enums/Level.ts +++ b/ts/enums/Level.ts @@ -1,10 +1,9 @@ export enum Level { - LDKLevel_Off, - LDKLevel_Error, - LDKLevel_Warn, - LDKLevel_Info, + LDKLevel_Trace, LDKLevel_Debug, - LDKLevel_Trace, + LDKLevel_Info, + LDKLevel_Warn, + LDKLevel_Error, } diff --git a/ts/structs/ChannelConfig.ts b/ts/structs/ChannelConfig.ts index afb53fb0..f1c352e8 100644 --- a/ts/structs/ChannelConfig.ts +++ b/ts/structs/ChannelConfig.ts @@ -18,13 +18,22 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelConfig_free(this.ptr); } } - public number get_fee_proportional_millionths() { - number ret = bindings.ChannelConfig_get_fee_proportional_millionths(this.ptr); + public number get_forwarding_fee_proportional_millionths() { + number ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr); return ret; } - public void set_fee_proportional_millionths(number val) { - bindings.ChannelConfig_set_fee_proportional_millionths(this.ptr, val); + public void set_forwarding_fee_proportional_millionths(number val) { + bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, val); + } + + public number get_forwarding_fee_base_msat() { + number ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr); + return ret; + } + + public void set_forwarding_fee_base_msat(number val) { + bindings.ChannelConfig_set_forwarding_fee_base_msat(this.ptr, val); } public number get_cltv_expiry_delta() { @@ -54,8 +63,8 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val); } - public static ChannelConfig constructor_new(number fee_proportional_millionths_arg, number cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) { - number ret = bindings.ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); + public static ChannelConfig constructor_new(number forwarding_fee_proportional_millionths_arg, number forwarding_fee_base_msat_arg, number cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) { + number ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg); const ret_hu_conv: ChannelConfig = new ChannelConfig(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; diff --git a/ts/structs/ChannelCounterparty.ts b/ts/structs/ChannelCounterparty.ts new file mode 100644 index 00000000..12911ef8 --- /dev/null +++ b/ts/structs/ChannelCounterparty.ts @@ -0,0 +1,58 @@ + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export default class ChannelCounterparty extends CommonBase { + constructor(_dummy: object, ptr: number) { + super(ptr); + } + + + protected finalize() { + super.finalize(); + + if (this.ptr != 0) { + bindings.ChannelCounterparty_free(this.ptr); + } + } + public Uint8Array get_node_id() { + Uint8Array ret = bindings.ChannelCounterparty_get_node_id(this.ptr); + return ret; + } + + public void set_node_id(Uint8Array val) { + bindings.ChannelCounterparty_set_node_id(this.ptr, val); + } + + public InitFeatures get_features() { + number ret = bindings.ChannelCounterparty_get_features(this.ptr); + const ret_hu_conv: InitFeatures = new InitFeatures(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public void set_features(InitFeatures val) { + bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr & ~1); + this.ptrs_to.add(val); + } + + public number get_unspendable_punishment_reserve() { + number ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr); + return ret; + } + + public void set_unspendable_punishment_reserve(number val) { + bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val); + } + + public ChannelCounterparty clone() { + number ret = bindings.ChannelCounterparty_clone(this.ptr); + const ret_hu_conv: ChannelCounterparty = new ChannelCounterparty(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/ts/structs/ChannelDetails.ts b/ts/structs/ChannelDetails.ts index e85efd45..9e55d0ca 100644 --- a/ts/structs/ChannelDetails.ts +++ b/ts/structs/ChannelDetails.ts @@ -27,6 +27,18 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelDetails_set_channel_id(this.ptr, val); } + public ChannelCounterparty get_counterparty() { + number ret = bindings.ChannelDetails_get_counterparty(this.ptr); + const ret_hu_conv: ChannelCounterparty = new ChannelCounterparty(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public void set_counterparty(ChannelCounterparty val) { + bindings.ChannelDetails_set_counterparty(this.ptr, val == null ? 0 : val.ptr & ~1); + this.ptrs_to.add(val); + } + public OutPoint get_funding_txo() { number ret = bindings.ChannelDetails_get_funding_txo(this.ptr); const ret_hu_conv: OutPoint = new OutPoint(null, ret); @@ -50,34 +62,24 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelDetails_set_short_channel_id(this.ptr, val.ptr); } - public Uint8Array get_remote_network_id() { - Uint8Array ret = bindings.ChannelDetails_get_remote_network_id(this.ptr); + public number get_channel_value_satoshis() { + number ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr); return ret; } - public void set_remote_network_id(Uint8Array val) { - bindings.ChannelDetails_set_remote_network_id(this.ptr, val); + public void set_channel_value_satoshis(number val) { + bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val); } - public InitFeatures get_counterparty_features() { - number ret = bindings.ChannelDetails_get_counterparty_features(this.ptr); - const ret_hu_conv: InitFeatures = new InitFeatures(null, ret); + public Option_u64Z get_unspendable_punishment_reserve() { + number ret = bindings.ChannelDetails_get_unspendable_punishment_reserve(this.ptr); + Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } - public void set_counterparty_features(InitFeatures val) { - bindings.ChannelDetails_set_counterparty_features(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); - } - - public number get_channel_value_satoshis() { - number ret = bindings.ChannelDetails_get_channel_value_satoshis(this.ptr); - return ret; - } - - public void set_channel_value_satoshis(number val) { - bindings.ChannelDetails_set_channel_value_satoshis(this.ptr, val); + public void set_unspendable_punishment_reserve(Option_u64Z val) { + bindings.ChannelDetails_set_unspendable_punishment_reserve(this.ptr, val.ptr); } public number get_user_id() { @@ -107,6 +109,28 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelDetails_set_inbound_capacity_msat(this.ptr, val); } + public Option_u32Z get_confirmations_required() { + number ret = bindings.ChannelDetails_get_confirmations_required(this.ptr); + Option_u32Z ret_hu_conv = Option_u32Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public void set_confirmations_required(Option_u32Z val) { + bindings.ChannelDetails_set_confirmations_required(this.ptr, val.ptr); + } + + public Option_u16Z get_force_close_spend_delay() { + number ret = bindings.ChannelDetails_get_force_close_spend_delay(this.ptr); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + public void set_force_close_spend_delay(Option_u16Z val) { + bindings.ChannelDetails_set_force_close_spend_delay(this.ptr, val.ptr); + } + public boolean get_is_outbound() { boolean ret = bindings.ChannelDetails_get_is_outbound(this.ptr); return ret; @@ -143,6 +167,15 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelDetails_set_is_public(this.ptr, val); } + public static ChannelDetails constructor_new(Uint8Array channel_id_arg, ChannelCounterparty counterparty_arg, OutPoint funding_txo_arg, Option_u64Z short_channel_id_arg, number channel_value_satoshis_arg, Option_u64Z unspendable_punishment_reserve_arg, number user_id_arg, number outbound_capacity_msat_arg, number inbound_capacity_msat_arg, Option_u32Z confirmations_required_arg, Option_u16Z force_close_spend_delay_arg, boolean is_outbound_arg, boolean is_funding_locked_arg, boolean is_usable_arg, boolean is_public_arg) { + number ret = bindings.ChannelDetails_new(channel_id_arg, counterparty_arg == null ? 0 : counterparty_arg.ptr & ~1, funding_txo_arg == null ? 0 : funding_txo_arg.ptr & ~1, short_channel_id_arg.ptr, channel_value_satoshis_arg, unspendable_punishment_reserve_arg.ptr, user_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg.ptr, force_close_spend_delay_arg.ptr, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg); + const ret_hu_conv: ChannelDetails = new ChannelDetails(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(counterparty_arg); + ret_hu_conv.ptrs_to.add(funding_txo_arg); + return ret_hu_conv; + } + public ChannelDetails clone() { number ret = bindings.ChannelDetails_clone(this.ptr); const ret_hu_conv: ChannelDetails = new ChannelDetails(null, ret); diff --git a/ts/structs/ChannelManager.ts b/ts/structs/ChannelManager.ts index 1e6443d4..86590bfc 100644 --- a/ts/structs/ChannelManager.ts +++ b/ts/structs/ChannelManager.ts @@ -185,6 +185,13 @@ import * as bindings from '../bindings' // TODO: figure out location bindings.ChannelManager_await_persistable_update(this.ptr); } + public BestBlock current_best_block() { + number ret = bindings.ChannelManager_current_best_block(this.ptr); + const ret_hu_conv: BestBlock = new BestBlock(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + public ChannelMessageHandler as_ChannelMessageHandler() { number ret = bindings.ChannelManager_as_ChannelMessageHandler(this.ptr); ChannelMessageHandler ret_hu_conv = new ChannelMessageHandler(null, ret); diff --git a/ts/structs/ChannelMonitor.ts b/ts/structs/ChannelMonitor.ts index af5d1cf9..a937362b 100644 --- a/ts/structs/ChannelMonitor.ts +++ b/ts/structs/ChannelMonitor.ts @@ -225,4 +225,11 @@ import * as bindings from '../bindings' // TODO: figure out location return ret; } + public BestBlock current_best_block() { + number ret = bindings.ChannelMonitor_current_best_block(this.ptr); + const ret_hu_conv: BestBlock = new BestBlock(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + } diff --git a/ts/structs/ErrorAction.ts b/ts/structs/ErrorAction.ts index 25bf0917..09faa349 100644 --- a/ts/structs/ErrorAction.ts +++ b/ts/structs/ErrorAction.ts @@ -16,6 +16,9 @@ export default class ErrorAction extends CommonBase { if (raw_val instanceof bindings.LDKErrorAction.IgnoreError) { return new IgnoreError(this.ptr, raw_val); } + if (raw_val instanceof bindings.LDKErrorAction.IgnoreAndLog) { + return new IgnoreAndLog(this.ptr, raw_val); + } if (raw_val instanceof bindings.LDKErrorAction.SendErrorMessage) { return new SendErrorMessage(this.ptr, raw_val); } @@ -38,6 +41,13 @@ export class IgnoreError extends ErrorAction { super(null, ptr); } } +export class IgnoreAndLog extends ErrorAction { + public ignore_and_log: Level; + private constructor(ptr: number, obj: bindings.LDKErrorAction.IgnoreAndLog) { + super(null, ptr); + this.ignore_and_log = obj.ignore_and_log; + } +} export class SendErrorMessage extends ErrorAction { public msg: ErrorMessage; private constructor(ptr: number, obj: bindings.LDKErrorAction.SendErrorMessage) { diff --git a/ts/structs/MessageSendEvent.ts b/ts/structs/MessageSendEvent.ts index a2f96107..b5b708c1 100644 --- a/ts/structs/MessageSendEvent.ts +++ b/ts/structs/MessageSendEvent.ts @@ -52,6 +52,9 @@ export default class MessageSendEvent extends CommonBase { if (raw_val instanceof bindings.LDKMessageSendEvent.BroadcastChannelUpdate) { return new BroadcastChannelUpdate(this.ptr, raw_val); } + if (raw_val instanceof bindings.LDKMessageSendEvent.SendChannelUpdate) { + return new SendChannelUpdate(this.ptr, raw_val); + } if (raw_val instanceof bindings.LDKMessageSendEvent.HandleError) { return new HandleError(this.ptr, raw_val); } @@ -238,6 +241,18 @@ export class BroadcastChannelUpdate extends MessageSendEvent { this.msg = msg_hu_conv; } } +export class SendChannelUpdate extends MessageSendEvent { + public node_id: Uint8Array; + public msg: ChannelUpdate; + private constructor(ptr: number, obj: bindings.LDKMessageSendEvent.SendChannelUpdate) { + super(null, ptr); + this.node_id = obj.node_id; + const msg: number = obj.msg; + const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg); + msg_hu_conv.ptrs_to.add(this); + this.msg = msg_hu_conv; + } +} export class HandleError extends MessageSendEvent { public node_id: Uint8Array; public action: ErrorAction; diff --git a/ts/structs/Option_u16Z.ts b/ts/structs/Option_u16Z.ts new file mode 100644 index 00000000..5d3b56e6 --- /dev/null +++ b/ts/structs/Option_u16Z.ts @@ -0,0 +1,56 @@ + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + +export default class COption_u16Z extends CommonBase { + protected constructor(_dummy: object, ptr: number) { super(ptr); } + protected finalize() { + super.finalize(); + if (this.ptr != 0) { bindings.COption_u16Z_free(this.ptr); } + } + static constr_from_ptr(ptr: number): COption_u16Z { + const raw_val: bindings.LDKCOption_u16Z = bindings.LDKCOption_u16Z_ref_from_ptr(ptr); + if (raw_val instanceof bindings.LDKCOption_u16Z.Some) { + return new Some(this.ptr, raw_val); + } + if (raw_val instanceof bindings.LDKCOption_u16Z.None) { + return new None(this.ptr, raw_val); + } + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface + } + +} +export class Some extends COption_u16Z { + public some: number; + private constructor(ptr: number, obj: bindings.LDKCOption_u16Z.Some) { + super(null, ptr); + this.some = obj.some; + } +} +export class None extends COption_u16Z { + private constructor(ptr: number, obj: bindings.LDKCOption_u16Z.None) { + super(null, ptr); + } +} + public static Option_u16Z constructor__some(number o) { + number ret = bindings.COption_u16Z_some(o); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public static Option_u16Z constructor__none() { + number ret = bindings.COption_u16Z_none(); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + public Option_u16Z _clone() { + number ret = bindings.COption_u16Z_clone(this.ptr); + Option_u16Z ret_hu_conv = Option_u16Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + +} diff --git a/ts/structs/UserConfig.ts b/ts/structs/UserConfig.ts index 31f28d33..0e59b8fb 100644 --- a/ts/structs/UserConfig.ts +++ b/ts/structs/UserConfig.ts @@ -54,8 +54,17 @@ import * as bindings from '../bindings' // TODO: figure out location this.ptrs_to.add(val); } - public static UserConfig constructor_new(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg) { - number ret = bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1); + public boolean get_accept_forwards_to_priv_channels() { + boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr); + return ret; + } + + public void set_accept_forwards_to_priv_channels(boolean val) { + bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val); + } + + public static UserConfig constructor_new(ChannelHandshakeConfig own_channel_config_arg, ChannelHandshakeLimits peer_channel_config_limits_arg, ChannelConfig channel_options_arg, boolean accept_forwards_to_priv_channels_arg) { + number ret = bindings.UserConfig_new(own_channel_config_arg == null ? 0 : own_channel_config_arg.ptr & ~1, peer_channel_config_limits_arg == null ? 0 : peer_channel_config_limits_arg.ptr & ~1, channel_options_arg == null ? 0 : channel_options_arg.ptr & ~1, accept_forwards_to_priv_channels_arg); const ret_hu_conv: UserConfig = new UserConfig(null, ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); ret_hu_conv.ptrs_to.add(own_channel_config_arg);