Update auto-updated Java files
[ldk-java] / src / main / java / org / ldk / structs / ChannelConfig.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Options which apply on a per-channel basis and may change at runtime or based on negotiation
13  * with our counterparty.
14  */
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 {
20                 super.finalize();
21                 if (ptr != 0) { bindings.ChannelConfig_free(ptr); }
22         }
23
24         /**
25          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
26          * over the channel.
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.
29          * 
30          * Default value: 0.
31          */
32         public int get_forwarding_fee_proportional_millionths() {
33                 int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr);
34                 Reference.reachabilityFence(this);
35                 return ret;
36         }
37
38         /**
39          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
40          * over the channel.
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.
43          * 
44          * Default value: 0.
45          */
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);
50         }
51
52         /**
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.
57          * 
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
60          * this node.
61          * 
62          * Default value: 1000.
63          * 
64          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
65          */
66         public int get_forwarding_fee_base_msat() {
67                 int ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         /**
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.
77          * 
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
80          * this node.
81          * 
82          * Default value: 1000.
83          * 
84          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
85          */
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);
90         }
91
92         /**
93          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
94          * the channel this config applies to.
95          * 
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.
100          * 
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).
106          * 
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.
110          * 
111          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
112          */
113         public short get_cltv_expiry_delta() {
114                 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
115                 Reference.reachabilityFence(this);
116                 return ret;
117         }
118
119         /**
120          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
121          * the channel this config applies to.
122          * 
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.
127          * 
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).
133          * 
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.
137          * 
138          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
139          */
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);
144         }
145
146         /**
147          * Set to announce the channel publicly and notify all nodes that they can route via this
148          * channel.
149          * 
150          * This should only be set to true for nodes which expect to be online reliably.
151          * 
152          * As the node which funds a channel picks this value this will only apply for new outbound
153          * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
154          * 
155          * This cannot be changed after the initial channel handshake.
156          * 
157          * Default value: false.
158          */
159         public boolean get_announced_channel() {
160                 boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr);
161                 Reference.reachabilityFence(this);
162                 return ret;
163         }
164
165         /**
166          * Set to announce the channel publicly and notify all nodes that they can route via this
167          * channel.
168          * 
169          * This should only be set to true for nodes which expect to be online reliably.
170          * 
171          * As the node which funds a channel picks this value this will only apply for new outbound
172          * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
173          * 
174          * This cannot be changed after the initial channel handshake.
175          * 
176          * Default value: false.
177          */
178         public void set_announced_channel(boolean val) {
179                 bindings.ChannelConfig_set_announced_channel(this.ptr, val);
180                 Reference.reachabilityFence(this);
181                 Reference.reachabilityFence(val);
182         }
183
184         /**
185          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
186          * supports it, they will then enforce the mutual-close output to us matches what we provided
187          * at intialization, preventing us from closing to an alternate pubkey.
188          * 
189          * This is set to true by default to provide a slight increase in security, though ultimately
190          * any attacker who is able to take control of a channel can just as easily send the funds via
191          * lightning payments, so we never require that our counterparties support this option.
192          * 
193          * This cannot be changed after a channel has been initialized.
194          * 
195          * Default value: true.
196          */
197         public boolean get_commit_upfront_shutdown_pubkey() {
198                 boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
199                 Reference.reachabilityFence(this);
200                 return ret;
201         }
202
203         /**
204          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
205          * supports it, they will then enforce the mutual-close output to us matches what we provided
206          * at intialization, preventing us from closing to an alternate pubkey.
207          * 
208          * This is set to true by default to provide a slight increase in security, though ultimately
209          * any attacker who is able to take control of a channel can just as easily send the funds via
210          * lightning payments, so we never require that our counterparties support this option.
211          * 
212          * This cannot be changed after a channel has been initialized.
213          * 
214          * Default value: true.
215          */
216         public void set_commit_upfront_shutdown_pubkey(boolean val) {
217                 bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
218                 Reference.reachabilityFence(this);
219                 Reference.reachabilityFence(val);
220         }
221
222         /**
223          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
224          * small to claim on-chain.
225          * 
226          * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
227          * not be claimable on-chain, instead being turned into additional miner fees if either
228          * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
229          * to such payments may be sustantial if there are many dust HTLCs present when the
230          * channel is force-closed.
231          * 
232          * This limit is applied for sent, forwarded, and received HTLCs and limits the total
233          * exposure across all three types per-channel. Setting this too low may prevent the
234          * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
235          * important to prevent stealing of dust HTLCs by miners.
236          * 
237          * Default value: 5_000_000 msat.
238          */
239         public long get_max_dust_htlc_exposure_msat() {
240                 long ret = bindings.ChannelConfig_get_max_dust_htlc_exposure_msat(this.ptr);
241                 Reference.reachabilityFence(this);
242                 return ret;
243         }
244
245         /**
246          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
247          * small to claim on-chain.
248          * 
249          * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
250          * not be claimable on-chain, instead being turned into additional miner fees if either
251          * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
252          * to such payments may be sustantial if there are many dust HTLCs present when the
253          * channel is force-closed.
254          * 
255          * This limit is applied for sent, forwarded, and received HTLCs and limits the total
256          * exposure across all three types per-channel. Setting this too low may prevent the
257          * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
258          * important to prevent stealing of dust HTLCs by miners.
259          * 
260          * Default value: 5_000_000 msat.
261          */
262         public void set_max_dust_htlc_exposure_msat(long val) {
263                 bindings.ChannelConfig_set_max_dust_htlc_exposure_msat(this.ptr, val);
264                 Reference.reachabilityFence(this);
265                 Reference.reachabilityFence(val);
266         }
267
268         /**
269          * The additional fee we're willing to pay to avoid waiting for the counterparty's
270          * `to_self_delay` to reclaim funds.
271          * 
272          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
273          * closing transaction which both sides find acceptable, ultimately paid by the channel
274          * funder/initiator.
275          * 
276          * When we are the funder, because we have to pay the channel closing fee, we bound the
277          * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
278          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
279          * [`Normal`] feerate during normal operation, this value represents the additional fee we're
280          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
281          * funds.
282          * 
283          * When we are not the funder, we require the closing transaction fee pay at least our
284          * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
285          * Thus, this value is ignored when we are not the funder.
286          * 
287          * Default value: 1000 satoshis.
288          * 
289          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
290          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
291          */
292         public long get_force_close_avoidance_max_fee_satoshis() {
293                 long ret = bindings.ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this.ptr);
294                 Reference.reachabilityFence(this);
295                 return ret;
296         }
297
298         /**
299          * The additional fee we're willing to pay to avoid waiting for the counterparty's
300          * `to_self_delay` to reclaim funds.
301          * 
302          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
303          * closing transaction which both sides find acceptable, ultimately paid by the channel
304          * funder/initiator.
305          * 
306          * When we are the funder, because we have to pay the channel closing fee, we bound the
307          * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
308          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
309          * [`Normal`] feerate during normal operation, this value represents the additional fee we're
310          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
311          * funds.
312          * 
313          * When we are not the funder, we require the closing transaction fee pay at least our
314          * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
315          * Thus, this value is ignored when we are not the funder.
316          * 
317          * Default value: 1000 satoshis.
318          * 
319          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
320          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
321          */
322         public void set_force_close_avoidance_max_fee_satoshis(long val) {
323                 bindings.ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this.ptr, val);
324                 Reference.reachabilityFence(this);
325                 Reference.reachabilityFence(val);
326         }
327
328         /**
329          * Constructs a new ChannelConfig given each field
330          */
331         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, long max_dust_htlc_exposure_msat_arg, long force_close_avoidance_max_fee_satoshis_arg) {
332                 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, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
333                 Reference.reachabilityFence(forwarding_fee_proportional_millionths_arg);
334                 Reference.reachabilityFence(forwarding_fee_base_msat_arg);
335                 Reference.reachabilityFence(cltv_expiry_delta_arg);
336                 Reference.reachabilityFence(announced_channel_arg);
337                 Reference.reachabilityFence(commit_upfront_shutdown_pubkey_arg);
338                 Reference.reachabilityFence(max_dust_htlc_exposure_msat_arg);
339                 Reference.reachabilityFence(force_close_avoidance_max_fee_satoshis_arg);
340                 if (ret >= 0 && ret <= 4096) { return null; }
341                 ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
342                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
343                 return ret_hu_conv;
344         }
345
346         long clone_ptr() {
347                 long ret = bindings.ChannelConfig_clone_ptr(this.ptr);
348                 Reference.reachabilityFence(this);
349                 return ret;
350         }
351
352         /**
353          * Creates a copy of the ChannelConfig
354          */
355         public ChannelConfig clone() {
356                 long ret = bindings.ChannelConfig_clone(this.ptr);
357                 Reference.reachabilityFence(this);
358                 if (ret >= 0 && ret <= 4096) { return null; }
359                 ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
360                 ret_hu_conv.ptrs_to.add(this);
361                 return ret_hu_conv;
362         }
363
364         /**
365          * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
366          */
367         public static ChannelConfig with_default() {
368                 long ret = bindings.ChannelConfig_default();
369                 if (ret >= 0 && ret <= 4096) { return null; }
370                 ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
371                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
372                 return ret_hu_conv;
373         }
374
375         /**
376          * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
377          */
378         public byte[] write() {
379                 byte[] ret = bindings.ChannelConfig_write(this.ptr);
380                 Reference.reachabilityFence(this);
381                 return ret;
382         }
383
384         /**
385          * Read a ChannelConfig from a byte array, created by ChannelConfig_write
386          */
387         public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
388                 long ret = bindings.ChannelConfig_read(ser);
389                 Reference.reachabilityFence(ser);
390                 if (ret >= 0 && ret <= 4096) { return null; }
391                 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
392                 return ret_hu_conv;
393         }
394
395 }