[Java] Update auto-generated Java structs
[ldk-java] / src / main / java / org / ldk / structs / UserConfig.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
13  * 
14  * Default::default() provides sane defaults for most configurations
15  * (but currently with 0 relay fees!)
16  */
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 {
22                 super.finalize();
23                 if (ptr != 0) { bindings.UserConfig_free(ptr); }
24         }
25
26         /**
27          * Channel handshake config that we propose to our counterparty.
28          */
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); };
35                 return ret_hu_conv;
36         }
37
38         /**
39          * Channel handshake config that we propose to our counterparty.
40          */
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); };
46         }
47
48         /**
49          * Limits applied to our counterparty's proposed channel handshake config settings.
50          */
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); };
57                 return ret_hu_conv;
58         }
59
60         /**
61          * Limits applied to our counterparty's proposed channel handshake config settings.
62          */
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); };
68         }
69
70         /**
71          * Channel config which affects behavior during channel lifetime.
72          */
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); };
79                 return ret_hu_conv;
80         }
81
82         /**
83          * Channel config which affects behavior during channel lifetime.
84          */
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); };
90         }
91
92         /**
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.
96          * 
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.
101          * 
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.
107          * 
108          * Default value: false.
109          */
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);
113                 return ret;
114         }
115
116         /**
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.
120          * 
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.
125          * 
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.
131          * 
132          * Default value: false.
133          */
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);
138         }
139
140         /**
141          * If this is set to false, we do not accept inbound requests to open a new channel.
142          * Default value: true.
143          */
144         public boolean get_accept_inbound_channels() {
145                 boolean ret = bindings.UserConfig_get_accept_inbound_channels(this.ptr);
146                 Reference.reachabilityFence(this);
147                 return ret;
148         }
149
150         /**
151          * If this is set to false, we do not accept inbound requests to open a new channel.
152          * Default value: true.
153          */
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);
158         }
159
160         /**
161          * If this is set to true, the user needs to manually accept inbound requests to open a new
162          * channel.
163          * 
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.
168          * 
169          * Default value: false.
170          * 
171          * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
172          * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
173          * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
174          */
175         public boolean get_manually_accept_inbound_channels() {
176                 boolean ret = bindings.UserConfig_get_manually_accept_inbound_channels(this.ptr);
177                 Reference.reachabilityFence(this);
178                 return ret;
179         }
180
181         /**
182          * If this is set to true, the user needs to manually accept inbound requests to open a new
183          * channel.
184          * 
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.
189          * 
190          * Default value: false.
191          * 
192          * [`Event::OpenChannelRequest`]: crate::util::events::Event::OpenChannelRequest
193          * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel
194          * [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
195          */
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);
200         }
201
202         /**
203          * Constructs a new UserConfig given each field
204          */
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); };
219                 return ret_hu_conv;
220         }
221
222         long clone_ptr() {
223                 long ret = bindings.UserConfig_clone_ptr(this.ptr);
224                 Reference.reachabilityFence(this);
225                 return ret;
226         }
227
228         /**
229          * Creates a copy of the UserConfig
230          */
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); };
237                 return ret_hu_conv;
238         }
239
240         /**
241          * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
242          */
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); };
248                 return ret_hu_conv;
249         }
250
251 }