Update auto-generated bindings
[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 javax.annotation.Nullable;
8
9
10 /**
11  * Options which apply on a per-channel basis and may change at runtime or based on negotiation
12  * with our counterparty.
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ChannelConfig_free(ptr); }
21         }
22
23         /**
24          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
25          * over the channel.
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.
28          * 
29          * Default value: 0.
30          */
31         public int get_forwarding_fee_proportional_millionths() {
32                 int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr);
33                 return ret;
34         }
35
36         /**
37          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
38          * over the channel.
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.
41          * 
42          * Default value: 0.
43          */
44         public void set_forwarding_fee_proportional_millionths(int val) {
45                 bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, val);
46         }
47
48         /**
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.
53          * 
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
56          * this node.
57          * 
58          * Default value: 1000.
59          * 
60          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
61          */
62         public int get_forwarding_fee_base_msat() {
63                 int ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr);
64                 return ret;
65         }
66
67         /**
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.
72          * 
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
75          * this node.
76          * 
77          * Default value: 1000.
78          * 
79          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
80          */
81         public void set_forwarding_fee_base_msat(int val) {
82                 bindings.ChannelConfig_set_forwarding_fee_base_msat(this.ptr, val);
83         }
84
85         /**
86          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
87          * the channel this config applies to.
88          * 
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.
93          * 
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).
99          * 
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.
103          * 
104          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
105          */
106         public short get_cltv_expiry_delta() {
107                 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
108                 return ret;
109         }
110
111         /**
112          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
113          * the channel this config applies to.
114          * 
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.
119          * 
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).
125          * 
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.
129          * 
130          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
131          */
132         public void set_cltv_expiry_delta(short val) {
133                 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
134         }
135
136         /**
137          * Set to announce the channel publicly and notify all nodes that they can route via this
138          * channel.
139          * 
140          * This should only be set to true for nodes which expect to be online reliably.
141          * 
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.
144          * 
145          * This cannot be changed after the initial channel handshake.
146          * 
147          * Default value: false.
148          */
149         public boolean get_announced_channel() {
150                 boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr);
151                 return ret;
152         }
153
154         /**
155          * Set to announce the channel publicly and notify all nodes that they can route via this
156          * channel.
157          * 
158          * This should only be set to true for nodes which expect to be online reliably.
159          * 
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.
162          * 
163          * This cannot be changed after the initial channel handshake.
164          * 
165          * Default value: false.
166          */
167         public void set_announced_channel(boolean val) {
168                 bindings.ChannelConfig_set_announced_channel(this.ptr, val);
169         }
170
171         /**
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.
175          * 
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.
179          * 
180          * This cannot be changed after a channel has been initialized.
181          * 
182          * Default value: true.
183          */
184         public boolean get_commit_upfront_shutdown_pubkey() {
185                 boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
186                 return ret;
187         }
188
189         /**
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.
193          * 
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.
197          * 
198          * This cannot be changed after a channel has been initialized.
199          * 
200          * Default value: true.
201          */
202         public void set_commit_upfront_shutdown_pubkey(boolean val) {
203                 bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
204         }
205
206         /**
207          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
208          * small to claim on-chain.
209          * 
210          * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
211          * not be claimable on-chain, instead being turned into additional miner fees if either
212          * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
213          * to such payments may be sustantial if there are many dust HTLCs present when the
214          * channel is force-closed.
215          * 
216          * This limit is applied for sent, forwarded, and received HTLCs and limits the total
217          * exposure across all three types per-channel. Setting this too low may prevent the
218          * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
219          * important to prevent stealing of dust HTLCs by miners.
220          * 
221          * Default value: 5_000_000 msat.
222          */
223         public long get_max_dust_htlc_exposure_msat() {
224                 long ret = bindings.ChannelConfig_get_max_dust_htlc_exposure_msat(this.ptr);
225                 return ret;
226         }
227
228         /**
229          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
230          * small to claim on-chain.
231          * 
232          * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
233          * not be claimable on-chain, instead being turned into additional miner fees if either
234          * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
235          * to such payments may be sustantial if there are many dust HTLCs present when the
236          * channel is force-closed.
237          * 
238          * This limit is applied for sent, forwarded, and received HTLCs and limits the total
239          * exposure across all three types per-channel. Setting this too low may prevent the
240          * sending or receipt of low-value HTLCs on high-traffic nodes, and this limit is very
241          * important to prevent stealing of dust HTLCs by miners.
242          * 
243          * Default value: 5_000_000 msat.
244          */
245         public void set_max_dust_htlc_exposure_msat(long val) {
246                 bindings.ChannelConfig_set_max_dust_htlc_exposure_msat(this.ptr, val);
247         }
248
249         /**
250          * The additional fee we're willing to pay to avoid waiting for the counterparty's
251          * `to_self_delay` to reclaim funds.
252          * 
253          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
254          * closing transaction which both sides find acceptable, ultimately paid by the channel
255          * funder/initiator.
256          * 
257          * When we are the funder, because we have to pay the channel closing fee, we bound the
258          * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
259          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
260          * [`Normal`] feerate during normal operation, this value represents the additional fee we're
261          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
262          * funds.
263          * 
264          * When we are not the funder, we require the closing transaction fee pay at least our
265          * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
266          * Thus, this value is ignored when we are not the funder.
267          * 
268          * Default value: 1000 satoshis.
269          * 
270          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
271          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
272          */
273         public long get_force_close_avoidance_max_fee_satoshis() {
274                 long ret = bindings.ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this.ptr);
275                 return ret;
276         }
277
278         /**
279          * The additional fee we're willing to pay to avoid waiting for the counterparty's
280          * `to_self_delay` to reclaim funds.
281          * 
282          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
283          * closing transaction which both sides find acceptable, ultimately paid by the channel
284          * funder/initiator.
285          * 
286          * When we are the funder, because we have to pay the channel closing fee, we bound the
287          * acceptable fee by our [`Background`] and [`Normal`] fees, with the upper bound increased by
288          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
289          * [`Normal`] feerate during normal operation, this value represents the additional fee we're
290          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
291          * funds.
292          * 
293          * When we are not the funder, we require the closing transaction fee pay at least our
294          * [`Background`] fee estimate, but allow our counterparty to pay as much fee as they like.
295          * Thus, this value is ignored when we are not the funder.
296          * 
297          * Default value: 1000 satoshis.
298          * 
299          * [`Normal`]: crate::chain::chaininterface::ConfirmationTarget::Normal
300          * [`Background`]: crate::chain::chaininterface::ConfirmationTarget::Background
301          */
302         public void set_force_close_avoidance_max_fee_satoshis(long val) {
303                 bindings.ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this.ptr, val);
304         }
305
306         /**
307          * Constructs a new ChannelConfig given each field
308          */
309         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) {
310                 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);
311                 if (ret >= 0 && ret <= 4096) { return null; }
312                 ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
313                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
314                 return ret_hu_conv;
315         }
316
317         long clone_ptr() {
318                 long ret = bindings.ChannelConfig_clone_ptr(this.ptr);
319                 return ret;
320         }
321
322         /**
323          * Creates a copy of the ChannelConfig
324          */
325         public ChannelConfig clone() {
326                 long ret = bindings.ChannelConfig_clone(this.ptr);
327                 if (ret >= 0 && ret <= 4096) { return null; }
328                 ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
329                 ret_hu_conv.ptrs_to.add(this);
330                 return ret_hu_conv;
331         }
332
333         /**
334          * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
335          */
336         public static ChannelConfig with_default() {
337                 long ret = bindings.ChannelConfig_default();
338                 if (ret >= 0 && ret <= 4096) { return null; }
339                 ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelConfig(null, ret); }
340                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
341                 return ret_hu_conv;
342         }
343
344         /**
345          * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
346          */
347         public byte[] write() {
348                 byte[] ret = bindings.ChannelConfig_write(this.ptr);
349                 return ret;
350         }
351
352         /**
353          * Read a ChannelConfig from a byte array, created by ChannelConfig_write
354          */
355         public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
356                 long ret = bindings.ChannelConfig_read(ser);
357                 if (ret >= 0 && ret <= 4096) { return null; }
358                 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
359                 return ret_hu_conv;
360         }
361
362 }