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(org.ldk.structs.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(org.ldk.structs.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(org.ldk.structs.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::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::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 * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
204 * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
205 * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
207 * Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
209 * Default value: false.
211 * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
212 * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
214 public boolean get_accept_intercept_htlcs() {
215 boolean ret = bindings.UserConfig_get_accept_intercept_htlcs(this.ptr);
216 Reference.reachabilityFence(this);
221 * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over
222 * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC
223 * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user.
225 * Setting this to true may break backwards compatibility with LDK versions < 0.0.113.
227 * Default value: false.
229 * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
230 * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
232 public void set_accept_intercept_htlcs(boolean val) {
233 bindings.UserConfig_set_accept_intercept_htlcs(this.ptr, val);
234 Reference.reachabilityFence(this);
235 Reference.reachabilityFence(val);
239 * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple
240 * parts. If this is set to true, we'll accept the payment.
242 * Setting this to true will break backwards compatibility upon downgrading to an LDK
243 * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP
244 * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`].
246 * Default value: false.
248 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
250 public boolean get_accept_mpp_keysend() {
251 boolean ret = bindings.UserConfig_get_accept_mpp_keysend(this.ptr);
252 Reference.reachabilityFence(this);
257 * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple
258 * parts. If this is set to true, we'll accept the payment.
260 * Setting this to true will break backwards compatibility upon downgrading to an LDK
261 * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP
262 * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`].
264 * Default value: false.
266 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
268 public void set_accept_mpp_keysend(boolean val) {
269 bindings.UserConfig_set_accept_mpp_keysend(this.ptr, val);
270 Reference.reachabilityFence(this);
271 Reference.reachabilityFence(val);
275 * Constructs a new UserConfig given each field
277 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) {
278 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, accept_intercept_htlcs_arg, accept_mpp_keysend_arg);
279 Reference.reachabilityFence(channel_handshake_config_arg);
280 Reference.reachabilityFence(channel_handshake_limits_arg);
281 Reference.reachabilityFence(channel_config_arg);
282 Reference.reachabilityFence(accept_forwards_to_priv_channels_arg);
283 Reference.reachabilityFence(accept_inbound_channels_arg);
284 Reference.reachabilityFence(manually_accept_inbound_channels_arg);
285 Reference.reachabilityFence(accept_intercept_htlcs_arg);
286 Reference.reachabilityFence(accept_mpp_keysend_arg);
287 if (ret >= 0 && ret <= 4096) { return null; }
288 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
289 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
290 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_handshake_config_arg); };
291 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_handshake_limits_arg); };
292 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_config_arg); };
297 long ret = bindings.UserConfig_clone_ptr(this.ptr);
298 Reference.reachabilityFence(this);
303 * Creates a copy of the UserConfig
305 public UserConfig clone() {
306 long ret = bindings.UserConfig_clone(this.ptr);
307 Reference.reachabilityFence(this);
308 if (ret >= 0 && ret <= 4096) { return null; }
309 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
310 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
315 * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
317 public static UserConfig with_default() {
318 long ret = bindings.UserConfig_default();
319 if (ret >= 0 && ret <= 4096) { return null; }
320 org.ldk.structs.UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UserConfig(null, ret); }
321 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };