1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
13 * Default::default() provides sane defaults for most configurations
14 * (but currently with 0 relay fees!)
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UserConfig extends CommonBase {
18 UserConfig(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UserConfig_free(ptr); }
26 * Channel config that we propose to our counterparty.
28 public ChannelHandshakeConfig get_own_channel_config() {
29 long ret = bindings.UserConfig_get_own_channel_config(this.ptr);
30 if (ret < 1024) { return null; }
31 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
32 ret_hu_conv.ptrs_to.add(this);
37 * Channel config that we propose to our counterparty.
39 public void set_own_channel_config(ChannelHandshakeConfig val) {
40 bindings.UserConfig_set_own_channel_config(this.ptr, val == null ? 0 : val.ptr & ~1);
41 this.ptrs_to.add(val);
45 * Limits applied to our counterparty's proposed channel config settings.
47 public ChannelHandshakeLimits get_peer_channel_config_limits() {
48 long ret = bindings.UserConfig_get_peer_channel_config_limits(this.ptr);
49 if (ret < 1024) { return null; }
50 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
51 ret_hu_conv.ptrs_to.add(this);
56 * Limits applied to our counterparty's proposed channel config settings.
58 public void set_peer_channel_config_limits(ChannelHandshakeLimits val) {
59 bindings.UserConfig_set_peer_channel_config_limits(this.ptr, val == null ? 0 : val.ptr & ~1);
60 this.ptrs_to.add(val);
64 * Channel config which affects behavior during channel lifetime.
66 public ChannelConfig get_channel_options() {
67 long ret = bindings.UserConfig_get_channel_options(this.ptr);
68 if (ret < 1024) { return null; }
69 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
70 ret_hu_conv.ptrs_to.add(this);
75 * Channel config which affects behavior during channel lifetime.
77 public void set_channel_options(ChannelConfig val) {
78 bindings.UserConfig_set_channel_options(this.ptr, val == null ? 0 : val.ptr & ~1);
79 this.ptrs_to.add(val);
83 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
84 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
85 * node which is not online reliably.
87 * For nodes which are not online reliably, you should set all channels to *not* be announced
88 * (using [`ChannelConfig::announced_channel`] and
89 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
90 * ensure you are not exposed to any forwarding risk.
92 * Note that because you cannot change a channel's announced state after creation, there is no
93 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
94 * from a publicly-announced forwarding node to a private non-forwarding node you must close
95 * all your channels and open new ones. For privacy, you should also change your node_id
96 * (swapping all private and public key material for new ones) at that time.
98 * Default value: false.
100 public boolean get_accept_forwards_to_priv_channels() {
101 boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr);
106 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
107 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
108 * node which is not online reliably.
110 * For nodes which are not online reliably, you should set all channels to *not* be announced
111 * (using [`ChannelConfig::announced_channel`] and
112 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
113 * ensure you are not exposed to any forwarding risk.
115 * Note that because you cannot change a channel's announced state after creation, there is no
116 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
117 * from a publicly-announced forwarding node to a private non-forwarding node you must close
118 * all your channels and open new ones. For privacy, you should also change your node_id
119 * (swapping all private and public key material for new ones) at that time.
121 * Default value: false.
123 public void set_accept_forwards_to_priv_channels(boolean val) {
124 bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val);
128 * Constructs a new UserConfig given each field
130 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) {
131 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);
132 if (ret < 1024) { return null; }
133 UserConfig ret_hu_conv = new UserConfig(null, ret);
134 ret_hu_conv.ptrs_to.add(ret_hu_conv);
135 ret_hu_conv.ptrs_to.add(own_channel_config_arg);
136 ret_hu_conv.ptrs_to.add(peer_channel_config_limits_arg);
137 ret_hu_conv.ptrs_to.add(channel_options_arg);
142 * Creates a copy of the UserConfig
144 public UserConfig clone() {
145 long ret = bindings.UserConfig_clone(this.ptr);
146 if (ret < 1024) { return null; }
147 UserConfig ret_hu_conv = new UserConfig(null, ret);
148 ret_hu_conv.ptrs_to.add(this);
153 * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
155 public static UserConfig with_default() {
156 long ret = bindings.UserConfig_default();
157 if (ret < 1024) { return null; }
158 UserConfig ret_hu_conv = new UserConfig(null, ret);
159 ret_hu_conv.ptrs_to.add(ret_hu_conv);