Update auto-generated bindings
[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
8
9 /**
10  * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
11  * 
12  * Default::default() provides sane defaults for most configurations
13  * (but currently with 0 relay fees!)
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class UserConfig extends CommonBase {
17         UserConfig(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.UserConfig_free(ptr); }
22         }
23
24         /**
25          * Channel config that we propose to our counterparty.
26          */
27         public ChannelHandshakeConfig get_own_channel_config() {
28                 long ret = bindings.UserConfig_get_own_channel_config(this.ptr);
29                 if (ret < 1024) { return null; }
30                 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
31                 ret_hu_conv.ptrs_to.add(this);
32                 return ret_hu_conv;
33         }
34
35         /**
36          * Channel config that we propose to our counterparty.
37          */
38         public void set_own_channel_config(ChannelHandshakeConfig val) {
39                 bindings.UserConfig_set_own_channel_config(this.ptr, val == null ? 0 : val.ptr & ~1);
40                 this.ptrs_to.add(val);
41         }
42
43         /**
44          * Limits applied to our counterparty's proposed channel config settings.
45          */
46         public ChannelHandshakeLimits get_peer_channel_config_limits() {
47                 long ret = bindings.UserConfig_get_peer_channel_config_limits(this.ptr);
48                 if (ret < 1024) { return null; }
49                 ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret);
50                 ret_hu_conv.ptrs_to.add(this);
51                 return ret_hu_conv;
52         }
53
54         /**
55          * Limits applied to our counterparty's proposed channel config settings.
56          */
57         public void set_peer_channel_config_limits(ChannelHandshakeLimits val) {
58                 bindings.UserConfig_set_peer_channel_config_limits(this.ptr, val == null ? 0 : val.ptr & ~1);
59                 this.ptrs_to.add(val);
60         }
61
62         /**
63          * Channel config which affects behavior during channel lifetime.
64          */
65         public ChannelConfig get_channel_options() {
66                 long ret = bindings.UserConfig_get_channel_options(this.ptr);
67                 if (ret < 1024) { return null; }
68                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
69                 ret_hu_conv.ptrs_to.add(this);
70                 return ret_hu_conv;
71         }
72
73         /**
74          * Channel config which affects behavior during channel lifetime.
75          */
76         public void set_channel_options(ChannelConfig val) {
77                 bindings.UserConfig_set_channel_options(this.ptr, val == null ? 0 : val.ptr & ~1);
78                 this.ptrs_to.add(val);
79         }
80
81         /**
82          * If this is set to false, we will reject any HTLCs which were to be forwarded over private
83          * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
84          * node which is not online reliably.
85          * 
86          * For nodes which are not online reliably, you should set all channels to *not* be announced
87          * (using [`ChannelConfig::announced_channel`] and
88          * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
89          * ensure you are not exposed to any forwarding risk.
90          * 
91          * Note that because you cannot change a channel's announced state after creation, there is no
92          * way to disable forwarding on public channels retroactively. Thus, in order to change a node
93          * from a publicly-announced forwarding node to a private non-forwarding node you must close
94          * all your channels and open new ones. For privacy, you should also change your node_id
95          * (swapping all private and public key material for new ones) at that time.
96          * 
97          * Default value: false.
98          */
99         public boolean get_accept_forwards_to_priv_channels() {
100                 boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr);
101                 return ret;
102         }
103
104         /**
105          * If this is set to false, we will reject any HTLCs which were to be forwarded over private
106          * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
107          * node which is not online reliably.
108          * 
109          * For nodes which are not online reliably, you should set all channels to *not* be announced
110          * (using [`ChannelConfig::announced_channel`] and
111          * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
112          * ensure you are not exposed to any forwarding risk.
113          * 
114          * Note that because you cannot change a channel's announced state after creation, there is no
115          * way to disable forwarding on public channels retroactively. Thus, in order to change a node
116          * from a publicly-announced forwarding node to a private non-forwarding node you must close
117          * all your channels and open new ones. For privacy, you should also change your node_id
118          * (swapping all private and public key material for new ones) at that time.
119          * 
120          * Default value: false.
121          */
122         public void set_accept_forwards_to_priv_channels(boolean val) {
123                 bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val);
124         }
125
126         /**
127          * Constructs a new UserConfig given each field
128          */
129         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) {
130                 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);
131                 if (ret < 1024) { return null; }
132                 UserConfig ret_hu_conv = new UserConfig(null, ret);
133                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
134                 ret_hu_conv.ptrs_to.add(own_channel_config_arg);
135                 ret_hu_conv.ptrs_to.add(peer_channel_config_limits_arg);
136                 ret_hu_conv.ptrs_to.add(channel_options_arg);
137                 return ret_hu_conv;
138         }
139
140         /**
141          * Creates a copy of the UserConfig
142          */
143         public UserConfig clone() {
144                 long ret = bindings.UserConfig_clone(this.ptr);
145                 if (ret < 1024) { return null; }
146                 UserConfig ret_hu_conv = new UserConfig(null, ret);
147                 ret_hu_conv.ptrs_to.add(this);
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
153          */
154         public static UserConfig with_default() {
155                 long ret = bindings.UserConfig_default();
156                 if (ret < 1024) { return null; }
157                 UserConfig ret_hu_conv = new UserConfig(null, ret);
158                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
159                 return ret_hu_conv;
160         }
161
162 }