1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
13 * Default::default() provides sane defaults for most configurations
14 * (but currently with 0 relay fees!)
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class UserConfig extends CommonBase {
18 UserConfig(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.UserConfig_free(ptr); }
26 * Channel config that we propose to our counterparty.
28 public ChannelHandshakeConfig get_own_channel_config() {
29 long ret = bindings.UserConfig_get_own_channel_config(this.ptr);
30 if (ret >= 0 && ret < 1024) { return null; }
31 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
32 ret_hu_conv.ptrs_to.add(this);
37 * Channel config that we propose to our counterparty.
39 public void set_own_channel_config(ChannelHandshakeConfig val) {
40 bindings.UserConfig_set_own_channel_config(this.ptr, val == null ? 0 : val.ptr & ~1);
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 >= 0 && 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);
62 * Channel config which affects behavior during channel lifetime.
64 public ChannelConfig get_channel_options() {
65 long ret = bindings.UserConfig_get_channel_options(this.ptr);
66 if (ret >= 0 && ret < 1024) { return null; }
67 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
68 ret_hu_conv.ptrs_to.add(this);
73 * Channel config which affects behavior during channel lifetime.
75 public void set_channel_options(ChannelConfig val) {
76 bindings.UserConfig_set_channel_options(this.ptr, val == null ? 0 : val.ptr & ~1);
80 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
81 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
82 * node which is not online reliably.
84 * For nodes which are not online reliably, you should set all channels to *not* be announced
85 * (using [`ChannelConfig::announced_channel`] and
86 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
87 * ensure you are not exposed to any forwarding risk.
89 * Note that because you cannot change a channel's announced state after creation, there is no
90 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
91 * from a publicly-announced forwarding node to a private non-forwarding node you must close
92 * all your channels and open new ones. For privacy, you should also change your node_id
93 * (swapping all private and public key material for new ones) at that time.
95 * Default value: false.
97 public boolean get_accept_forwards_to_priv_channels() {
98 boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr);
103 * If this is set to false, we will reject any HTLCs which were to be forwarded over private
104 * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a
105 * node which is not online reliably.
107 * For nodes which are not online reliably, you should set all channels to *not* be announced
108 * (using [`ChannelConfig::announced_channel`] and
109 * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to
110 * ensure you are not exposed to any forwarding risk.
112 * Note that because you cannot change a channel's announced state after creation, there is no
113 * way to disable forwarding on public channels retroactively. Thus, in order to change a node
114 * from a publicly-announced forwarding node to a private non-forwarding node you must close
115 * all your channels and open new ones. For privacy, you should also change your node_id
116 * (swapping all private and public key material for new ones) at that time.
118 * Default value: false.
120 public void set_accept_forwards_to_priv_channels(boolean val) {
121 bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val);
125 * Constructs a new UserConfig given each field
127 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) {
128 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);
129 if (ret >= 0 && ret < 1024) { return null; }
130 UserConfig ret_hu_conv = new UserConfig(null, ret);
131 ret_hu_conv.ptrs_to.add(ret_hu_conv);
136 * Creates a copy of the UserConfig
138 public UserConfig clone() {
139 long ret = bindings.UserConfig_clone(this.ptr);
140 if (ret >= 0 && ret < 1024) { return null; }
141 UserConfig ret_hu_conv = new UserConfig(null, ret);
142 ret_hu_conv.ptrs_to.add(this);
147 * Creates a "default" UserConfig. See struct and individual field documentaiton for details on which values are used.
149 public static UserConfig with_default() {
150 long ret = bindings.UserConfig_default();
151 if (ret >= 0 && ret < 1024) { return null; }
152 UserConfig ret_hu_conv = new UserConfig(null, ret);
153 ret_hu_conv.ptrs_to.add(ret_hu_conv);