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 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
30 ret_hu_conv.ptrs_to.add(this);
35 * Channel config that we propose to our counterparty.
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);
43 * Limits applied to our counterparty's proposed channel config settings.
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);
53 * Limits applied to our counterparty's proposed channel config settings.
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);
61 * Channel config which affects behavior during channel lifetime.
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);
71 * Channel config which affects behavior during channel lifetime.
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);
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.
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.
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.
94 * Default value: false.
96 public boolean get_accept_forwards_to_priv_channels() {
97 boolean ret = bindings.UserConfig_get_accept_forwards_to_priv_channels(this.ptr);
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.
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.
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.
117 * Default value: false.
119 public void set_accept_forwards_to_priv_channels(boolean val) {
120 bindings.UserConfig_set_accept_forwards_to_priv_channels(this.ptr, val);
124 * Constructs a new UserConfig given each field
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);
137 * Creates a copy of the UserConfig
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);
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 UserConfig ret_hu_conv = new UserConfig(null, ret);
152 ret_hu_conv.ptrs_to.add(ret_hu_conv);