1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * Options which apply on a per-channel basis and may change at runtime or based on negotiation
11 * with our counterparty.
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ChannelConfig extends CommonBase {
15 ChannelConfig(Object _dummy, long ptr) { super(ptr); }
16 @Override @SuppressWarnings("deprecation")
17 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.ChannelConfig_free(ptr); }
23 * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
24 * This may be allowed to change at runtime in a later update, however doing so must result in
25 * update messages sent to notify all nodes of our updated relay fee.
29 public int get_fee_proportional_millionths() {
30 int ret = bindings.ChannelConfig_get_fee_proportional_millionths(this.ptr);
35 * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
36 * This may be allowed to change at runtime in a later update, however doing so must result in
37 * update messages sent to notify all nodes of our updated relay fee.
41 public void set_fee_proportional_millionths(int val) {
42 bindings.ChannelConfig_set_fee_proportional_millionths(this.ptr, val);
46 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
47 * the channel this config applies to.
49 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
50 * HTLC balance when a channel appears on-chain whereas
51 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
52 * (non-HTLC-encumbered) balance.
54 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
55 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
56 * commitment transaction at least once per this many blocks (minus some margin to allow us
57 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
58 * the spending transaction).
60 * Default value: 72 (12 hours at an average of 6 blocks/hour).
61 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
62 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
64 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
66 public short get_cltv_expiry_delta() {
67 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
72 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
73 * the channel this config applies to.
75 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
76 * HTLC balance when a channel appears on-chain whereas
77 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
78 * (non-HTLC-encumbered) balance.
80 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
81 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
82 * commitment transaction at least once per this many blocks (minus some margin to allow us
83 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
84 * the spending transaction).
86 * Default value: 72 (12 hours at an average of 6 blocks/hour).
87 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
88 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
90 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
92 public void set_cltv_expiry_delta(short val) {
93 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
97 * Set to announce the channel publicly and notify all nodes that they can route via this
100 * This should only be set to true for nodes which expect to be online reliably.
102 * As the node which funds a channel picks this value this will only apply for new outbound
103 * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
105 * This cannot be changed after the initial channel handshake.
107 * Default value: false.
109 public boolean get_announced_channel() {
110 boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr);
115 * Set to announce the channel publicly and notify all nodes that they can route via this
118 * This should only be set to true for nodes which expect to be online reliably.
120 * As the node which funds a channel picks this value this will only apply for new outbound
121 * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
123 * This cannot be changed after the initial channel handshake.
125 * Default value: false.
127 public void set_announced_channel(boolean val) {
128 bindings.ChannelConfig_set_announced_channel(this.ptr, val);
132 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
133 * supports it, they will then enforce the mutual-close output to us matches what we provided
134 * at intialization, preventing us from closing to an alternate pubkey.
136 * This is set to true by default to provide a slight increase in security, though ultimately
137 * any attacker who is able to take control of a channel can just as easily send the funds via
138 * lightning payments, so we never require that our counterparties support this option.
140 * This cannot be changed after a channel has been initialized.
142 * Default value: true.
144 public boolean get_commit_upfront_shutdown_pubkey() {
145 boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
150 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
151 * supports it, they will then enforce the mutual-close output to us matches what we provided
152 * at intialization, preventing us from closing to an alternate pubkey.
154 * This is set to true by default to provide a slight increase in security, though ultimately
155 * any attacker who is able to take control of a channel can just as easily send the funds via
156 * lightning payments, so we never require that our counterparties support this option.
158 * This cannot be changed after a channel has been initialized.
160 * Default value: true.
162 public void set_commit_upfront_shutdown_pubkey(boolean val) {
163 bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
167 * Constructs a new ChannelConfig given each field
169 public static ChannelConfig constructor_new(int fee_proportional_millionths_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) {
170 long ret = bindings.ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
171 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
172 ret_hu_conv.ptrs_to.add(ret_hu_conv);
177 * Creates a copy of the ChannelConfig
179 public ChannelConfig clone() {
180 long ret = bindings.ChannelConfig_clone(this.ptr);
181 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
182 ret_hu_conv.ptrs_to.add(this);
187 * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
189 public static ChannelConfig constructor_default() {
190 long ret = bindings.ChannelConfig_default();
191 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
192 ret_hu_conv.ptrs_to.add(ret_hu_conv);
197 * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
199 public byte[] write() {
200 byte[] ret = bindings.ChannelConfig_write(this.ptr);
205 * Read a ChannelConfig from a byte array, created by ChannelConfig_write
207 public static Result_ChannelConfigDecodeErrorZ constructor_read(byte[] ser) {
208 long ret = bindings.ChannelConfig_read(ser);
209 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);