1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
14 * Default::default() provides sane defaults for most configurations
15 * (but currently with 0 relay fees!)
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class UserConfig extends CommonBase {
19 UserConfig(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.UserConfig_free(ptr); }
27 * Channel config that we propose to our counterparty.
29 public ChannelHandshakeConfig get_own_channel_config() {
30 long ret = bindings.UserConfig_get_own_channel_config(this.ptr);
31 Reference.reachabilityFence(this);
32 if (ret >= 0 && ret <= 4096) { return null; }
33 ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
34 ret_hu_conv.ptrs_to.add(this);
39 * Channel config that we propose to our counterparty.
41 public void set_own_channel_config(ChannelHandshakeConfig val) {
42 bindings.UserConfig_set_own_channel_config(this.ptr, val == null ? 0 : val.ptr & ~1);
43 Reference.reachabilityFence(this);
44 Reference.reachabilityFence(val);
48 * Limits applied to our counterparty's proposed channel config settings.
50 public ChannelHandshakeLimits get_peer_channel_config_limits() {
51 long ret = bindings.UserConfig_get_peer_channel_config_limits(this.ptr);
52 Reference.reachabilityFence(this);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeLimits(null, ret); }
55 ret_hu_conv.ptrs_to.add(this);
60 * Limits applied to our counterparty's proposed channel config settings.
62 public void set_peer_channel_config_limits(ChannelHandshakeLimits val) {
63 bindings.UserConfig_set_peer_channel_config_limits(this.ptr, val == null ? 0 : val.ptr & ~1);
64 Reference.reachabilityFence(this);
65 Reference.reachabilityFence(val);
69 * Channel config which affects behavior during channel lifetime.
71 public ChannelConfig get_channel_options() {
72 long ret = bindings.UserConfig_get_channel_options(this.ptr);
73 Reference.reachabilityFence(this);
74 if (ret >= 0 && ret <= 4096) { return null; }
75 ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
76 ret_hu_conv.ptrs_to.add(this);
81 * Channel config which affects behavior during channel lifetime.
83 public void set_channel_options(ChannelConfig val) {
84 bindings.UserConfig_set_channel_options(this.ptr, val == null ? 0 : val.ptr & ~1);
85 Reference.reachabilityFence(this);
86 Reference.reachabilityFence(val);
90 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
91 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
92 * node which is not online reliably.
94 * For nodes which are not online reliably, you should set all channels to *not* be announced
95 * (using [`ChannelConfig::announced_channel`] and
96 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
97 * ensure you are not exposed to any forwarding risk.
99 * Note that because you cannot change a channel's announced state after creation, there is no
100 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
101 * from a publicly-announced forwarding node to a private non-forwarding node you must close
102 * all your channels and open new ones. For privacy, you should also change your node_id
103 * (swapping all private and public key material for new ones) at that time.
105 * Default value: false.
107 public boolean get_accept_forwards_to_priv_channels() {
108 boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr);
109 Reference.reachabilityFence(this);
114 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
115 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
116 * node which is not online reliably.
118 * For nodes which are not online reliably, you should set all channels to *not* be announced
119 * (using [`ChannelConfig::announced_channel`] and
120 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
121 * ensure you are not exposed to any forwarding risk.
123 * Note that because you cannot change a channel's announced state after creation, there is no
124 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
125 * from a publicly-announced forwarding node to a private non-forwarding node you must close
126 * all your channels and open new ones. For privacy, you should also change your node_id
127 * (swapping all private and public key material for new ones) at that time.
129 * Default value: false.
131 public void set_accept_forwards_to_priv_channels(boolean val) {
132 bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val);
133 Reference.reachabilityFence(this);
134 Reference.reachabilityFence(val);
138 * If this is set to false, we do not accept inbound requests to open a new channel.
139 * Default value: true.
141 public boolean get_accept_inbound_channels() {
142 boolean ret = bindings.UserConfig_get_accept_inbound_channels(this.ptr);
143 Reference.reachabilityFence(this);
148 * If this is set to false, we do not accept inbound requests to open a new channel.
149 * Default value: true.
151 public void set_accept_inbound_channels(boolean val) {
152 bindings.UserConfig_set_accept_inbound_channels(this.ptr, val);
153 Reference.reachabilityFence(this);
154 Reference.reachabilityFence(val);
158 * Constructs a new UserConfig given each field
160 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, boolean accept_inbound_channels_arg) {
161 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, accept_inbound_channels_arg);
162 Reference.reachabilityFence(own_channel_config_arg);
163 Reference.reachabilityFence(peer_channel_config_limits_arg);
164 Reference.reachabilityFence(channel_options_arg);
165 Reference.reachabilityFence(accept_forwards_to_priv_channels_arg);
166 Reference.reachabilityFence(accept_inbound_channels_arg);
167 if (ret >= 0 && ret <= 4096) { return null; }
168 UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
169 ret_hu_conv.ptrs_to.add(ret_hu_conv);
174 long ret = bindings.UserConfig_clone_ptr(this.ptr);
175 Reference.reachabilityFence(this);
180 * Creates a copy of the UserConfig
182 public UserConfig clone() {
183 long ret = bindings.UserConfig_clone(this.ptr);
184 Reference.reachabilityFence(this);
185 if (ret >= 0 && ret <= 4096) { return null; }
186 UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
187 ret_hu_conv.ptrs_to.add(this);
192 * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
194 public static UserConfig with_default() {
195 long ret = bindings.UserConfig_default();
196 if (ret >= 0 && ret <= 4096) { return null; }
197 UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
198 ret_hu_conv.ptrs_to.add(ret_hu_conv);