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 * If this is set to true, the user needs to manually accept inbound requests to open a new
161 * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
162 * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
163 * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
164 * user explicitly chooses to accept the request.
166 * Default value: false.
168 * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
169 * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
170 * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
172 public boolean get_manually_accept_inbound_channels() {
173 boolean ret = bindings.UserConfig_get_manually_accept_inbound_channels(this.ptr);
174 Reference.reachabilityFence(this);
179 * If this is set to true, the user needs to manually accept inbound requests to open a new
182 * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a
183 * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a
184 * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the
185 * user explicitly chooses to accept the request.
187 * Default value: false.
189 * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
190 * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
191 * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
193 public void set_manually_accept_inbound_channels(boolean val) {
194 bindings.UserConfig_set_manually_accept_inbound_channels(this.ptr, val);
195 Reference.reachabilityFence(this);
196 Reference.reachabilityFence(val);
200 * Constructs a new UserConfig given each field
202 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, boolean manually_accept_inbound_channels_arg) {
203 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, manually_accept_inbound_channels_arg);
204 Reference.reachabilityFence(own_channel_config_arg);
205 Reference.reachabilityFence(peer_channel_config_limits_arg);
206 Reference.reachabilityFence(channel_options_arg);
207 Reference.reachabilityFence(accept_forwards_to_priv_channels_arg);
208 Reference.reachabilityFence(accept_inbound_channels_arg);
209 Reference.reachabilityFence(manually_accept_inbound_channels_arg);
210 if (ret >= 0 && ret <= 4096) { return null; }
211 UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
212 ret_hu_conv.ptrs_to.add(ret_hu_conv);
217 long ret = bindings.UserConfig_clone_ptr(this.ptr);
218 Reference.reachabilityFence(this);
223 * Creates a copy of the UserConfig
225 public UserConfig clone() {
226 long ret = bindings.UserConfig_clone(this.ptr);
227 Reference.reachabilityFence(this);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
230 ret_hu_conv.ptrs_to.add(this);
235 * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
237 public static UserConfig with_default() {
238 long ret = bindings.UserConfig_default();
239 if (ret >= 0 && ret <= 4096) { return null; }
240 UserConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new UserConfig(null, ret); }
241 ret_hu_conv.ptrs_to.add(ret_hu_conv);