1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Options which apply on a per-channel basis and may change at runtime or based on negotiation
13 * with our counterparty.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class ChannelConfig extends CommonBase {
17 ChannelConfig(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.ChannelConfig_free(ptr); }
25 * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
27 * This may be allowed to change at runtime in a later update, however doing so must result in
28 * update messages sent to notify all nodes of our updated relay fee.
32 public int get_forwarding_fee_proportional_millionths() {
33 int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr);
34 Reference.reachabilityFence(this);
39 * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
41 * This may be allowed to change at runtime in a later update, however doing so must result in
42 * update messages sent to notify all nodes of our updated relay fee.
46 public void set_forwarding_fee_proportional_millionths(int val) {
47 bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, val);
48 Reference.reachabilityFence(this);
49 Reference.reachabilityFence(val);
53 * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
54 * excess of [`forwarding_fee_proportional_millionths`].
55 * This may be allowed to change at runtime in a later update, however doing so must result in
56 * update messages sent to notify all nodes of our updated relay fee.
58 * The default value of a single satoshi roughly matches the market rate on many routing nodes
59 * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
62 * Default value: 1000.
64 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
66 public int get_forwarding_fee_base_msat() {
67 int ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr);
68 Reference.reachabilityFence(this);
73 * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
74 * excess of [`forwarding_fee_proportional_millionths`].
75 * This may be allowed to change at runtime in a later update, however doing so must result in
76 * update messages sent to notify all nodes of our updated relay fee.
78 * The default value of a single satoshi roughly matches the market rate on many routing nodes
79 * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
82 * Default value: 1000.
84 * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
86 public void set_forwarding_fee_base_msat(int val) {
87 bindings.ChannelConfig_set_forwarding_fee_base_msat(this.ptr, val);
88 Reference.reachabilityFence(this);
89 Reference.reachabilityFence(val);
93 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
94 * the channel this config applies to.
96 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
97 * HTLC balance when a channel appears on-chain whereas
98 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
99 * (non-HTLC-encumbered) balance.
101 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
102 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
103 * commitment transaction at least once per this many blocks (minus some margin to allow us
104 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
105 * the spending transaction).
107 * Default value: 72 (12 hours at an average of 6 blocks/hour).
108 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
109 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
111 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
113 public short get_cltv_expiry_delta() {
114 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
115 Reference.reachabilityFence(this);
120 * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
121 * the channel this config applies to.
123 * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
124 * HTLC balance when a channel appears on-chain whereas
125 * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
126 * (non-HTLC-encumbered) balance.
128 * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
129 * we (or one of our watchtowers) MUST be online to check for broadcast of the current
130 * commitment transaction at least once per this many blocks (minus some margin to allow us
131 * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
132 * the spending transaction).
134 * Default value: 72 (12 hours at an average of 6 blocks/hour).
135 * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
136 * [`MIN_CLTV_EXPIRY_DELTA`] instead.
138 * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
140 public void set_cltv_expiry_delta(short val) {
141 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
142 Reference.reachabilityFence(this);
143 Reference.reachabilityFence(val);
147 * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
148 * small to claim on-chain.
150 * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
151 * not be claimable on-chain, instead being turned into additional miner fees if either
152 * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
153 * to such payments may be sustantial if there are many dust HTLCs present when the
154 * channel is force-closed.
156 * This limit is applied for sent, forwarded, and received HTLCs and limits the total
157 * exposure across all three types per-channel. Setting this too low may prevent the
158 * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
159 * important to prevent stealing of dust HTLCs by miners.
161 * Default value: 5_000_000 msat.
163 public long get_max_dust_htlc_exposure_msat() {
164 long ret = bindings.ChannelConfig_get_max_dust_htlc_exposure_msat(this.ptr);
165 Reference.reachabilityFence(this);
170 * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
171 * small to claim on-chain.
173 * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
174 * not be claimable on-chain, instead being turned into additional miner fees if either
175 * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
176 * to such payments may be sustantial if there are many dust HTLCs present when the
177 * channel is force-closed.
179 * This limit is applied for sent, forwarded, and received HTLCs and limits the total
180 * exposure across all three types per-channel. Setting this too low may prevent the
181 * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
182 * important to prevent stealing of dust HTLCs by miners.
184 * Default value: 5_000_000 msat.
186 public void set_max_dust_htlc_exposure_msat(long val) {
187 bindings.ChannelConfig_set_max_dust_htlc_exposure_msat(this.ptr, val);
188 Reference.reachabilityFence(this);
189 Reference.reachabilityFence(val);
193 * The additional fee we're willing to pay to avoid waiting for the counterparty's
194 * `to_self_delay` to reclaim funds.
196 * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
197 * closing transaction which both sides find acceptable, ultimately paid by the channel
200 * When we are the funder, because we have to pay the channel closing fee, we bound the
201 * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
202 * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
203 * [`Normal`] feerate during normal operation, this value represents the additional fee we're
204 * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
207 * When we are not the funder, we require the closing transaction fee pay at least our
208 * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
209 * Thus, this value is ignored when we are not the funder.
211 * Default value: 1000 satoshis.
213 * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
214 * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
216 public long get_force_close_avoidance_max_fee_satoshis() {
217 long ret = bindings.ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this.ptr);
218 Reference.reachabilityFence(this);
223 * The additional fee we're willing to pay to avoid waiting for the counterparty's
224 * `to_self_delay` to reclaim funds.
226 * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
227 * closing transaction which both sides find acceptable, ultimately paid by the channel
230 * When we are the funder, because we have to pay the channel closing fee, we bound the
231 * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
232 * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
233 * [`Normal`] feerate during normal operation, this value represents the additional fee we're
234 * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
237 * When we are not the funder, we require the closing transaction fee pay at least our
238 * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
239 * Thus, this value is ignored when we are not the funder.
241 * Default value: 1000 satoshis.
243 * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
244 * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
246 public void set_force_close_avoidance_max_fee_satoshis(long val) {
247 bindings.ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this.ptr, val);
248 Reference.reachabilityFence(this);
249 Reference.reachabilityFence(val);
253 * Constructs a new ChannelConfig given each field
255 public static ChannelConfig of(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, long max_dust_htlc_exposure_msat_arg, long force_close_avoidance_max_fee_satoshis_arg) {
256 long ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
257 Reference.reachabilityFence(forwarding_fee_proportional_millionths_arg);
258 Reference.reachabilityFence(forwarding_fee_base_msat_arg);
259 Reference.reachabilityFence(cltv_expiry_delta_arg);
260 Reference.reachabilityFence(max_dust_htlc_exposure_msat_arg);
261 Reference.reachabilityFence(force_close_avoidance_max_fee_satoshis_arg);
262 if (ret >= 0 && ret <= 4096) { return null; }
263 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
264 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
269 long ret = bindings.ChannelConfig_clone_ptr(this.ptr);
270 Reference.reachabilityFence(this);
275 * Creates a copy of the ChannelConfig
277 public ChannelConfig clone() {
278 long ret = bindings.ChannelConfig_clone(this.ptr);
279 Reference.reachabilityFence(this);
280 if (ret >= 0 && ret <= 4096) { return null; }
281 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
282 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
287 * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
289 public static ChannelConfig with_default() {
290 long ret = bindings.ChannelConfig_default();
291 if (ret >= 0 && ret <= 4096) { return null; }
292 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
293 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
298 * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
300 public byte[] write() {
301 byte[] ret = bindings.ChannelConfig_write(this.ptr);
302 Reference.reachabilityFence(this);
307 * Read a ChannelConfig from a byte array, created by ChannelConfig_write
309 public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
310 long ret = bindings.ChannelConfig_read(ser);
311 Reference.reachabilityFence(ser);
312 if (ret >= 0 && ret <= 4096) { return null; }
313 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);