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