X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FUserConfig.java;h=c995f6e4daf74a50e3f576df35d0264bb8ac5161;hb=ffdd56c967087cba7548599934585b8a9a3102e2;hp=3b1f2a90d87bf17a9d0e01027d2ba9357a13c54a;hpb=ba1af51214a8ea2de62b84cd23b6145173c71752;p=ldk-java diff --git a/src/main/java/org/ldk/structs/UserConfig.java b/src/main/java/org/ldk/structs/UserConfig.java index 3b1f2a90..c995f6e4 100644 --- a/src/main/java/org/ldk/structs/UserConfig.java +++ b/src/main/java/org/ldk/structs/UserConfig.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import java.lang.ref.Reference; import javax.annotation.Nullable; @@ -23,60 +24,69 @@ public class UserConfig extends CommonBase { } /** - * Channel config that we propose to our counterparty. + * Channel handshake config that we propose to our counterparty. */ - public ChannelHandshakeConfig get_own_channel_config() { - long ret = bindings.UserConfig_get_own_channel_config(this.ptr); - if (ret < 1024) { return null; } - ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret); - ret_hu_conv.ptrs_to.add(this); + public ChannelHandshakeConfig get_channel_handshake_config() { + long ret = bindings.UserConfig_get_channel_handshake_config(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } /** - * Channel config that we propose to our counterparty. + * Channel handshake config that we propose to our counterparty. */ - public void set_own_channel_config(ChannelHandshakeConfig val) { - bindings.UserConfig_set_own_channel_config(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); + public void set_channel_handshake_config(org.ldk.structs.ChannelHandshakeConfig val) { + bindings.UserConfig_set_channel_handshake_config(this.ptr, val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** - * Limits applied to our counterparty's proposed channel config settings. + * Limits applied to our counterparty's proposed channel handshake config settings. */ - public ChannelHandshakeLimits get_peer_channel_config_limits() { - long ret = bindings.UserConfig_get_peer_channel_config_limits(this.ptr); - if (ret < 1024) { return null; } - ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); - ret_hu_conv.ptrs_to.add(this); + public ChannelHandshakeLimits get_channel_handshake_limits() { + long ret = bindings.UserConfig_get_channel_handshake_limits(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } /** - * Limits applied to our counterparty's proposed channel config settings. + * Limits applied to our counterparty's proposed channel handshake config settings. */ - public void set_peer_channel_config_limits(ChannelHandshakeLimits val) { - bindings.UserConfig_set_peer_channel_config_limits(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); + public void set_channel_handshake_limits(org.ldk.structs.ChannelHandshakeLimits val) { + bindings.UserConfig_set_channel_handshake_limits(this.ptr, val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** * Channel config which affects behavior during channel lifetime. */ - public ChannelConfig get_channel_options() { - long ret = bindings.UserConfig_get_channel_options(this.ptr); - if (ret < 1024) { return null; } - ChannelConfig ret_hu_conv = new ChannelConfig(null, ret); - ret_hu_conv.ptrs_to.add(this); + public ChannelConfig get_channel_config() { + long ret = bindings.UserConfig_get_channel_config(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } /** * Channel config which affects behavior during channel lifetime. */ - public void set_channel_options(ChannelConfig val) { - bindings.UserConfig_set_channel_options(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); + public void set_channel_config(org.ldk.structs.ChannelConfig val) { + bindings.UserConfig_set_channel_config(this.ptr, val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -85,7 +95,7 @@ public class UserConfig extends CommonBase { * 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 + * (using [`ChannelHandshakeConfig::announced_channel`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to * ensure you are not exposed to any forwarding risk. * @@ -99,6 +109,7 @@ public class UserConfig extends CommonBase { */ public boolean get_accept_forwards_to_priv_channels() { boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -108,7 +119,7 @@ public class UserConfig extends CommonBase { * 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 + * (using [`ChannelHandshakeConfig::announced_channel`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to * ensure you are not exposed to any forwarding risk. * @@ -122,30 +133,181 @@ public class UserConfig extends CommonBase { */ public void set_accept_forwards_to_priv_channels(boolean val) { bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. + */ + public boolean get_accept_inbound_channels() { + boolean ret = bindings.UserConfig_get_accept_inbound_channels(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * If this is set to false, we do not accept inbound requests to open a new channel. + * Default value: true. + */ + public void set_accept_inbound_channels(boolean val) { + bindings.UserConfig_set_accept_inbound_channels(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * If this is set to true, the user needs to manually accept inbound requests to open a new + * channel. + * + * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a + * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the + * user explicitly chooses to accept the request. + * + * Default value: false. + * + * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest + * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel + * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + */ + public boolean get_manually_accept_inbound_channels() { + boolean ret = bindings.UserConfig_get_manually_accept_inbound_channels(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * If this is set to true, the user needs to manually accept inbound requests to open a new + * channel. + * + * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a + * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the + * user explicitly chooses to accept the request. + * + * Default value: false. + * + * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest + * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel + * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel + */ + public void set_manually_accept_inbound_channels(boolean val) { + bindings.UserConfig_set_manually_accept_inbound_channels(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC + * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. + * + * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. + * + * Default value: false. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + */ + public boolean get_accept_intercept_htlcs() { + boolean ret = bindings.UserConfig_get_accept_intercept_htlcs(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC + * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. + * + * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. + * + * Default value: false. + * + * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid + * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted + */ + public void set_accept_intercept_htlcs(boolean val) { + bindings.UserConfig_set_accept_intercept_htlcs(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple + * parts. If this is set to true, we'll accept the payment. + * + * Setting this to true will break backwards compatibility upon downgrading to an LDK + * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP + * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. + * + * Default value: false. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + */ + public boolean get_accept_mpp_keysend() { + boolean ret = bindings.UserConfig_get_accept_mpp_keysend(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple + * parts. If this is set to true, we'll accept the payment. + * + * Setting this to true will break backwards compatibility upon downgrading to an LDK + * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP + * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. + * + * Default value: false. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + */ + public void set_accept_mpp_keysend(boolean val) { + bindings.UserConfig_set_accept_mpp_keysend(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(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, 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); - if (ret < 1024) { return null; } - 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); - ret_hu_conv.ptrs_to.add(peer_channel_config_limits_arg); - ret_hu_conv.ptrs_to.add(channel_options_arg); + public static UserConfig of(org.ldk.structs.ChannelHandshakeConfig channel_handshake_config_arg, org.ldk.structs.ChannelHandshakeLimits channel_handshake_limits_arg, org.ldk.structs.ChannelConfig channel_config_arg, boolean accept_forwards_to_priv_channels_arg, boolean accept_inbound_channels_arg, boolean manually_accept_inbound_channels_arg, boolean accept_intercept_htlcs_arg, boolean accept_mpp_keysend_arg) { + long ret = bindings.UserConfig_new(channel_handshake_config_arg.ptr, channel_handshake_limits_arg.ptr, channel_config_arg.ptr, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg, accept_intercept_htlcs_arg, accept_mpp_keysend_arg); + Reference.reachabilityFence(channel_handshake_config_arg); + Reference.reachabilityFence(channel_handshake_limits_arg); + Reference.reachabilityFence(channel_config_arg); + Reference.reachabilityFence(accept_forwards_to_priv_channels_arg); + Reference.reachabilityFence(accept_inbound_channels_arg); + Reference.reachabilityFence(manually_accept_inbound_channels_arg); + Reference.reachabilityFence(accept_intercept_htlcs_arg); + Reference.reachabilityFence(accept_mpp_keysend_arg); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_handshake_config_arg); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_handshake_limits_arg); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_config_arg); }; return ret_hu_conv; } + long clone_ptr() { + long ret = bindings.UserConfig_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + /** * Creates a copy of the UserConfig */ public UserConfig clone() { long ret = bindings.UserConfig_clone(this.ptr); - if (ret < 1024) { return null; } - UserConfig ret_hu_conv = new UserConfig(null, ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -154,9 +316,9 @@ public class UserConfig extends CommonBase { */ public static UserConfig with_default() { long ret = bindings.UserConfig_default(); - if (ret < 1024) { return null; } - UserConfig ret_hu_conv = new UserConfig(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; }