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 handshake config that we propose to our counterparty.
29 public ChannelHandshakeConfig get_channel_handshake_config() {
30 long ret = bindings.UserConfig_get_channel_handshake_config(this.ptr);
31 Reference.reachabilityFence(this);
32 if (ret >= 0 && ret <= 4096) { return null; }
33 org.ldk.structs.ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeConfig(null, ret); }
34 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
39 * Channel handshake config that we propose to our counterparty.
41 public void set_channel_handshake_config(ChannelHandshakeConfig val) {
42 bindings.UserConfig_set_channel_handshake_config(this.ptr, val == null ? 0 : val.ptr);
43 Reference.reachabilityFence(this);
44 Reference.reachabilityFence(val);
45 if (this != null) { this.ptrs_to.add(val); };
49 * Limits applied to our counterparty's proposed channel handshake config settings.
51 public ChannelHandshakeLimits get_channel_handshake_limits() {
52 long ret = bindings.UserConfig_get_channel_handshake_limits(this.ptr);
53 Reference.reachabilityFence(this);
54 if (ret >= 0 && ret <= 4096) { return null; }
55 org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); }
56 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
61 * Limits applied to our counterparty's proposed channel handshake config settings.
63 public void set_channel_handshake_limits(ChannelHandshakeLimits val) {
64 bindings.UserConfig_set_channel_handshake_limits(this.ptr, val == null ? 0 : val.ptr);
65 Reference.reachabilityFence(this);
66 Reference.reachabilityFence(val);
67 if (this != null) { this.ptrs_to.add(val); };
71 * Channel config which affects behavior during channel lifetime.
73 public ChannelConfig get_channel_config() {
74 long ret = bindings.UserConfig_get_channel_config(this.ptr);
75 Reference.reachabilityFence(this);
76 if (ret >= 0 && ret <= 4096) { return null; }
77 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
78 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
83 * Channel config which affects behavior during channel lifetime.
85 public void set_channel_config(ChannelConfig val) {
86 bindings.UserConfig_set_channel_config(this.ptr, val == null ? 0 : val.ptr);
87 Reference.reachabilityFence(this);
88 Reference.reachabilityFence(val);
89 if (this != null) { this.ptrs_to.add(val); };
93 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
94 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
95 * node which is not online reliably.
97 * For nodes which are not online reliably, you should set all channels to *not* be announced
98 * (using [`ChannelHandshakeConfig::announced_channel`] and
99 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
100 * ensure you are not exposed to any forwarding risk.
102 * Note that because you cannot change a channel's announced state after creation, there is no
103 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
104 * from a publicly-announced forwarding node to a private non-forwarding node you must close
105 * all your channels and open new ones. For privacy, you should also change your node_id
106 * (swapping all private and public key material for new ones) at that time.
108 * Default value: false.
110 public boolean get_accept_forwards_to_priv_channels() {
111 boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr);
112 Reference.reachabilityFence(this);
117 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
118 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
119 * node which is not online reliably.
121 * For nodes which are not online reliably, you should set all channels to *not* be announced
122 * (using [`ChannelHandshakeConfig::announced_channel`] and
123 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
124 * ensure you are not exposed to any forwarding risk.
126 * Note that because you cannot change a channel's announced state after creation, there is no
127 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
128 * from a publicly-announced forwarding node to a private non-forwarding node you must close
129 * all your channels and open new ones. For privacy, you should also change your node_id
130 * (swapping all private and public key material for new ones) at that time.
132 * Default value: false.
134 public void set_accept_forwards_to_priv_channels(boolean val) {
135 bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val);
136 Reference.reachabilityFence(this);
137 Reference.reachabilityFence(val);
141 * If this is set to false, we do not accept inbound requests to open a new channel.
142 * Default value: true.
144 public boolean get_accept_inbound_channels() {
145 boolean ret = bindings.UserConfig_get_accept_inbound_channels(this.ptr);
146 Reference.reachabilityFence(this);
151 * If this is set to false, we do not accept inbound requests to open a new channel.
152 * Default value: true.
154 public void set_accept_inbound_channels(boolean val) {
155 bindings.UserConfig_set_accept_inbound_channels(this.ptr, val);
156 Reference.reachabilityFence(this);
157 Reference.reachabilityFence(val);
161 * If this is set to true, the user needs to manually accept inbound requests to open a new
164 * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
165 * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
166 * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
167 * user explicitly chooses to accept the request.
169 * Default value: false.
171 * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
172 * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
173 * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
175 public boolean get_manually_accept_inbound_channels() {
176 boolean ret = bindings.UserConfig_get_manually_accept_inbound_channels(this.ptr);
177 Reference.reachabilityFence(this);
182 * If this is set to true, the user needs to manually accept inbound requests to open a new
185 * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
186 * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
187 * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
188 * user explicitly chooses to accept the request.
190 * Default value: false.
192 * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
193 * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
194 * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
196 public void set_manually_accept_inbound_channels(boolean val) {
197 bindings.UserConfig_set_manually_accept_inbound_channels(this.ptr, val);
198 Reference.reachabilityFence(this);
199 Reference.reachabilityFence(val);
203 * Constructs a new UserConfig given each field
205 public static UserConfig of(ChannelHandshakeConfig channel_handshake_config_arg, ChannelHandshakeLimits channel_handshake_limits_arg, ChannelConfig channel_config_arg, boolean accept_forwards_to_priv_channels_arg, boolean accept_inbound_channels_arg, boolean manually_accept_inbound_channels_arg) {
206 long ret = bindings.UserConfig_new(channel_handshake_config_arg == null ? 0 : channel_handshake_config_arg.ptr, channel_handshake_limits_arg == null ? 0 : channel_handshake_limits_arg.ptr, channel_config_arg == null ? 0 : channel_config_arg.ptr, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
207 Reference.reachabilityFence(channel_handshake_config_arg);
208 Reference.reachabilityFence(channel_handshake_limits_arg);
209 Reference.reachabilityFence(channel_config_arg);
210 Reference.reachabilityFence(accept_forwards_to_priv_channels_arg);
211 Reference.reachabilityFence(accept_inbound_channels_arg);
212 Reference.reachabilityFence(manually_accept_inbound_channels_arg);
213 if (ret >= 0 && ret <= 4096) { return null; }
214 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
215 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
216 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_handshake_config_arg); };
217 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_handshake_limits_arg); };
218 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_config_arg); };
223 long ret = bindings.UserConfig_clone_ptr(this.ptr);
224 Reference.reachabilityFence(this);
229 * Creates a copy of the UserConfig
231 public UserConfig clone() {
232 long ret = bindings.UserConfig_clone(this.ptr);
233 Reference.reachabilityFence(this);
234 if (ret >= 0 && ret <= 4096) { return null; }
235 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
236 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
241 * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
243 public static UserConfig with_default() {
244 long ret = bindings.UserConfig_default();
245 if (ret >= 0 && ret <= 4096) { return null; }
246 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
247 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };