1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
12 * Default::default() provides sane defaults for most configurations
13 * (but currently with 0 relay fees!)
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 {
21 if (ptr != 0) { bindings.UserConfig_free(ptr); }
25 * Channel config that we propose to our counterparty.
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);
36 * Channel config that we propose to our counterparty.
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);
44 * Limits applied to our counterparty's proposed channel config settings.
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);
55 * Limits applied to our counterparty's proposed channel config settings.
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);
63 * Channel config which affects behavior during channel lifetime.
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);
74 * Channel config which affects behavior during channel lifetime.
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);
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.
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.
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.
97 * Default value: false.
99 public boolean get_accept_forwards_to_priv_channels() {
100 boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr);
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.
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.
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.
120 * Default value: false.
122 public void set_accept_forwards_to_priv_channels(boolean val) {
123 bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val);
127 * Constructs a new UserConfig given each field
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);
141 * Creates a copy of the UserConfig
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);
152 * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
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);