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 * Options which apply on a per-channel basis and may change at runtime or based on negotiation
12 * with our counterparty.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelConfig extends CommonBase {
16 ChannelConfig(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelConfig_free(ptr); }
24 * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
26 * This may be allowed to change at runtime in a later update, however doing so must result in
27 * update messages sent to notify all nodes of our updated relay fee.
31 public int get_forwarding_fee_proportional_millionths() {
32 int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr);
37 * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
39 * This may be allowed to change at runtime in a later update, however doing so must result in
40 * update messages sent to notify all nodes of our updated relay fee.
44 public void set_forwarding_fee_proportional_millionths(int val) {
45 bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, val);
49 * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
50 * excess of [`forwarding_fee_proportional_millionths`].
51 * This may be allowed to change at runtime in a later update, however doing so must result in
52 * update messages sent to notify all nodes of our updated relay fee.
54 * The default value of a single satoshi roughly matches the market rate on many routing nodes
55 * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
58 * Default value: 1000.
60 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
62 public int get_forwarding_fee_base_msat() {
63 int ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr);
68 * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
69 * excess of [`forwarding_fee_proportional_millionths`].
70 * This may be allowed to change at runtime in a later update, however doing so must result in
71 * update messages sent to notify all nodes of our updated relay fee.
73 * The default value of a single satoshi roughly matches the market rate on many routing nodes
74 * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
77 * Default value: 1000.
79 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
81 public void set_forwarding_fee_base_msat(int val) {
82 bindings.ChannelConfig_set_forwarding_fee_base_msat(this.ptr, val);
86 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
87 * the channel this config applies to.
89 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
90 * HTLC balance when a channel appears on-chain whereas
91 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
92 * (non-HTLC-encumbered) balance.
94 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
95 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
96 * commitment transaction at least once per this many blocks (minus some margin to allow us
97 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
98 * the spending transaction).
100 * Default value: 72 (12 hours at an average of 6 blocks/hour).
101 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
102 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
104 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
106 public short get_cltv_expiry_delta() {
107 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
112 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
113 * the channel this config applies to.
115 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
116 * HTLC balance when a channel appears on-chain whereas
117 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
118 * (non-HTLC-encumbered) balance.
120 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
121 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
122 * commitment transaction at least once per this many blocks (minus some margin to allow us
123 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
124 * the spending transaction).
126 * Default value: 72 (12 hours at an average of 6 blocks/hour).
127 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
128 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
130 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
132 public void set_cltv_expiry_delta(short val) {
133 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
137 * Set to announce the channel publicly and notify all nodes that they can route via this
140 * This should only be set to true for nodes which expect to be online reliably.
142 * As the node which funds a channel picks this value this will only apply for new outbound
143 * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
145 * This cannot be changed after the initial channel handshake.
147 * Default value: false.
149 public boolean get_announced_channel() {
150 boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr);
155 * Set to announce the channel publicly and notify all nodes that they can route via this
158 * This should only be set to true for nodes which expect to be online reliably.
160 * As the node which funds a channel picks this value this will only apply for new outbound
161 * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
163 * This cannot be changed after the initial channel handshake.
165 * Default value: false.
167 public void set_announced_channel(boolean val) {
168 bindings.ChannelConfig_set_announced_channel(this.ptr, val);
172 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
173 * supports it, they will then enforce the mutual-close output to us matches what we provided
174 * at intialization, preventing us from closing to an alternate pubkey.
176 * This is set to true by default to provide a slight increase in security, though ultimately
177 * any attacker who is able to take control of a channel can just as easily send the funds via
178 * lightning payments, so we never require that our counterparties support this option.
180 * This cannot be changed after a channel has been initialized.
182 * Default value: true.
184 public boolean get_commit_upfront_shutdown_pubkey() {
185 boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
190 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
191 * supports it, they will then enforce the mutual-close output to us matches what we provided
192 * at intialization, preventing us from closing to an alternate pubkey.
194 * This is set to true by default to provide a slight increase in security, though ultimately
195 * any attacker who is able to take control of a channel can just as easily send the funds via
196 * lightning payments, so we never require that our counterparties support this option.
198 * This cannot be changed after a channel has been initialized.
200 * Default value: true.
202 public void set_commit_upfront_shutdown_pubkey(boolean val) {
203 bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
207 * Constructs a new ChannelConfig given each field
209 public static ChannelConfig of(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) {
210 long ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
211 if (ret < 1024) { return null; }
212 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
213 ret_hu_conv.ptrs_to.add(ret_hu_conv);
218 * Creates a copy of the ChannelConfig
220 public ChannelConfig clone() {
221 long ret = bindings.ChannelConfig_clone(this.ptr);
222 if (ret < 1024) { return null; }
223 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
224 ret_hu_conv.ptrs_to.add(this);
229 * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
231 public static ChannelConfig with_default() {
232 long ret = bindings.ChannelConfig_default();
233 if (ret < 1024) { return null; }
234 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
235 ret_hu_conv.ptrs_to.add(ret_hu_conv);
240 * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
242 public byte[] write() {
243 byte[] ret = bindings.ChannelConfig_write(this.ptr);
248 * Read a ChannelConfig from a byte array, created by ChannelConfig_write
250 public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
251 long ret = bindings.ChannelConfig_read(ser);
252 if (ret < 1024) { return null; }
253 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);