X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FUserConfig.java;h=3b1f2a90d87bf17a9d0e01027d2ba9357a13c54a;hb=1d0c372339e4d0148449728072c95964088412c4;hp=3f5c2ba0dcbbb496a36906b5004ca81ab82550ae;hpb=b0c50b891cbca28d3bd1d86276c132ff5221d8e4;p=ldk-java diff --git a/src/main/java/org/ldk/structs/UserConfig.java b/src/main/java/org/ldk/structs/UserConfig.java index 3f5c2ba0..3b1f2a90 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 javax.annotation.Nullable; /** @@ -26,6 +27,7 @@ public class UserConfig extends CommonBase { */ 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); return ret_hu_conv; @@ -44,6 +46,7 @@ public class UserConfig extends CommonBase { */ 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); return ret_hu_conv; @@ -62,6 +65,7 @@ public class UserConfig extends CommonBase { */ 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); return ret_hu_conv; @@ -75,11 +79,57 @@ 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); + 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); @@ -93,6 +143,7 @@ public class UserConfig extends CommonBase { */ 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); return ret_hu_conv; @@ -103,6 +154,7 @@ 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); return ret_hu_conv;