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) charged per satoshi for payments forwarded outbound
25 * This may be allowed to change at runtime in a later update, however doing so must result in
26 * update messages sent to notify all nodes of our updated relay fee.
30 public int get_forwarding_fee_proportional_millionths() {
31 int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr);
36 * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
38 * This may be allowed to change at runtime in a later update, however doing so must result in
39 * update messages sent to notify all nodes of our updated relay fee.
43 public void set_forwarding_fee_proportional_millionths(int val) {
44 bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, val);
48 * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
49 * excess of [`forwarding_fee_proportional_millionths`].
50 * This may be allowed to change at runtime in a later update, however doing so must result in
51 * update messages sent to notify all nodes of our updated relay fee.
53 * The default value of a single satoshi roughly matches the market rate on many routing nodes
54 * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
57 * Default value: 1000.
59 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
61 public int get_forwarding_fee_base_msat() {
62 int ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr);
67 * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
68 * excess of [`forwarding_fee_proportional_millionths`].
69 * This may be allowed to change at runtime in a later update, however doing so must result in
70 * update messages sent to notify all nodes of our updated relay fee.
72 * The default value of a single satoshi roughly matches the market rate on many routing nodes
73 * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
76 * Default value: 1000.
78 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
80 public void set_forwarding_fee_base_msat(int val) {
81 bindings.ChannelConfig_set_forwarding_fee_base_msat(this.ptr, val);
85 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
86 * the channel this config applies to.
88 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
89 * HTLC balance when a channel appears on-chain whereas
90 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
91 * (non-HTLC-encumbered) balance.
93 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
94 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
95 * commitment transaction at least once per this many blocks (minus some margin to allow us
96 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
97 * the spending transaction).
99 * Default value: 72 (12 hours at an average of 6 blocks/hour).
100 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
101 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
103 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
105 public short get_cltv_expiry_delta() {
106 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
111 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
112 * the channel this config applies to.
114 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
115 * HTLC balance when a channel appears on-chain whereas
116 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
117 * (non-HTLC-encumbered) balance.
119 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
120 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
121 * commitment transaction at least once per this many blocks (minus some margin to allow us
122 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
123 * the spending transaction).
125 * Default value: 72 (12 hours at an average of 6 blocks/hour).
126 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
127 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
129 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
131 public void set_cltv_expiry_delta(short val) {
132 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
136 * Set to announce the channel publicly and notify all nodes that they can route via this
139 * This should only be set to true for nodes which expect to be online reliably.
141 * As the node which funds a channel picks this value this will only apply for new outbound
142 * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
144 * This cannot be changed after the initial channel handshake.
146 * Default value: false.
148 public boolean get_announced_channel() {
149 boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr);
154 * Set to announce the channel publicly and notify all nodes that they can route via this
157 * This should only be set to true for nodes which expect to be online reliably.
159 * As the node which funds a channel picks this value this will only apply for new outbound
160 * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
162 * This cannot be changed after the initial channel handshake.
164 * Default value: false.
166 public void set_announced_channel(boolean val) {
167 bindings.ChannelConfig_set_announced_channel(this.ptr, val);
171 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
172 * supports it, they will then enforce the mutual-close output to us matches what we provided
173 * at intialization, preventing us from closing to an alternate pubkey.
175 * This is set to true by default to provide a slight increase in security, though ultimately
176 * any attacker who is able to take control of a channel can just as easily send the funds via
177 * lightning payments, so we never require that our counterparties support this option.
179 * This cannot be changed after a channel has been initialized.
181 * Default value: true.
183 public boolean get_commit_upfront_shutdown_pubkey() {
184 boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
189 * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
190 * supports it, they will then enforce the mutual-close output to us matches what we provided
191 * at intialization, preventing us from closing to an alternate pubkey.
193 * This is set to true by default to provide a slight increase in security, though ultimately
194 * any attacker who is able to take control of a channel can just as easily send the funds via
195 * lightning payments, so we never require that our counterparties support this option.
197 * This cannot be changed after a channel has been initialized.
199 * Default value: true.
201 public void set_commit_upfront_shutdown_pubkey(boolean val) {
202 bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
206 * Constructs a new ChannelConfig given each field
208 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) {
209 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);
210 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
211 ret_hu_conv.ptrs_to.add(ret_hu_conv);
216 * Creates a copy of the ChannelConfig
218 public ChannelConfig clone() {
219 long ret = bindings.ChannelConfig_clone(this.ptr);
220 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
221 ret_hu_conv.ptrs_to.add(this);
226 * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
228 public static ChannelConfig with_default() {
229 long ret = bindings.ChannelConfig_default();
230 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
231 ret_hu_conv.ptrs_to.add(ret_hu_conv);
236 * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
238 public byte[] write() {
239 byte[] ret = bindings.ChannelConfig_write(this.ptr);
244 * Read a ChannelConfig from a byte array, created by ChannelConfig_write
246 public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
247 long ret = bindings.ChannelConfig_read(ser);
248 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);