[Java] Update auto-generated bindings to LDK 0.0.118
[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          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
148          * small to claim on-chain.
149          * 
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.
155          * 
156          * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
157          * channel negotiated throughout the channel open process, along with the fees required to have
158          * a broadcastable HTLC spending transaction. When a channel supports anchor outputs
159          * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
160          * account the HTLC transaction fee as it is zero. Because of this, you may want to set this
161          * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier
162          * variant is primarily intended for use with pre-anchor channels.
163          * 
164          * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total
165          * exposure across all three types per-channel.
166          * 
167          * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000.
168          */
169         public MaxDustHTLCExposure get_max_dust_htlc_exposure() {
170                 long ret = bindings.ChannelConfig_get_max_dust_htlc_exposure(this.ptr);
171                 Reference.reachabilityFence(this);
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
174                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
175                 return ret_hu_conv;
176         }
177
178         /**
179          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
180          * small to claim on-chain.
181          * 
182          * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
183          * not be claimable on-chain, instead being turned into additional miner fees if either
184          * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
185          * to such payments may be sustantial if there are many dust HTLCs present when the
186          * channel is force-closed.
187          * 
188          * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
189          * channel negotiated throughout the channel open process, along with the fees required to have
190          * a broadcastable HTLC spending transaction. When a channel supports anchor outputs
191          * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
192          * account the HTLC transaction fee as it is zero. Because of this, you may want to set this
193          * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier
194          * variant is primarily intended for use with pre-anchor channels.
195          * 
196          * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total
197          * exposure across all three types per-channel.
198          * 
199          * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000.
200          */
201         public void set_max_dust_htlc_exposure(org.ldk.structs.MaxDustHTLCExposure val) {
202                 bindings.ChannelConfig_set_max_dust_htlc_exposure(this.ptr, val.ptr);
203                 Reference.reachabilityFence(this);
204                 Reference.reachabilityFence(val);
205                 if (this != null) { this.ptrs_to.add(val); };
206         }
207
208         /**
209          * The additional fee we're willing to pay to avoid waiting for the counterparty's
210          * `to_self_delay` to reclaim funds.
211          * 
212          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
213          * closing transaction which both sides find acceptable, ultimately paid by the channel
214          * funder/initiator.
215          * 
216          * When we are the funder, because we have to pay the channel closing fee, we bound the
217          * acceptable fee by our [`ChannelCloseMinimum`] and [`NonAnchorChannelFee`] fees, with the upper bound increased by
218          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
219          * [`NonAnchorChannelFee`] feerate during normal operation, this value represents the additional fee we're
220          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
221          * funds.
222          * 
223          * When we are not the funder, we require the closing transaction fee pay at least our
224          * [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like.
225          * Thus, this value is ignored when we are not the funder.
226          * 
227          * Default value: 1000 satoshis.
228          * 
229          * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
230          * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
231          */
232         public long get_force_close_avoidance_max_fee_satoshis() {
233                 long ret = bindings.ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this.ptr);
234                 Reference.reachabilityFence(this);
235                 return ret;
236         }
237
238         /**
239          * The additional fee we're willing to pay to avoid waiting for the counterparty's
240          * `to_self_delay` to reclaim funds.
241          * 
242          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
243          * closing transaction which both sides find acceptable, ultimately paid by the channel
244          * funder/initiator.
245          * 
246          * When we are the funder, because we have to pay the channel closing fee, we bound the
247          * acceptable fee by our [`ChannelCloseMinimum`] and [`NonAnchorChannelFee`] fees, with the upper bound increased by
248          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
249          * [`NonAnchorChannelFee`] feerate during normal operation, this value represents the additional fee we're
250          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
251          * funds.
252          * 
253          * When we are not the funder, we require the closing transaction fee pay at least our
254          * [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like.
255          * Thus, this value is ignored when we are not the funder.
256          * 
257          * Default value: 1000 satoshis.
258          * 
259          * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
260          * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
261          */
262         public void set_force_close_avoidance_max_fee_satoshis(long val) {
263                 bindings.ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this.ptr, val);
264                 Reference.reachabilityFence(this);
265                 Reference.reachabilityFence(val);
266         }
267
268         /**
269          * If set, allows this channel's counterparty to skim an additional fee off this node's inbound
270          * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users.
271          * 
272          * Usage:
273          * - The payee will set this option and set its invoice route hints to use [intercept scids]
274          * generated by this channel's counterparty.
275          * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
276          * [`forward_intercepted_htlc`] with less than the amount provided in
277          * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
278          * actual forward amounts is their fee.
279          * 
280          * # Note
281          * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is
282          * as-expected if this feature is activated, otherwise they may lose money!
283          * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the
284          * counterparty.
285          * 
286          * # Note
287          * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116.
288          * Unsetting this flag between restarts may lead to payment receive failures.
289          * 
290          * Default value: false.
291          * 
292          * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
293          * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
294          * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
295          * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat
296          * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat
297          * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat
298          */
299         public boolean get_accept_underpaying_htlcs() {
300                 boolean ret = bindings.ChannelConfig_get_accept_underpaying_htlcs(this.ptr);
301                 Reference.reachabilityFence(this);
302                 return ret;
303         }
304
305         /**
306          * If set, allows this channel's counterparty to skim an additional fee off this node's inbound
307          * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users.
308          * 
309          * Usage:
310          * - The payee will set this option and set its invoice route hints to use [intercept scids]
311          * generated by this channel's counterparty.
312          * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
313          * [`forward_intercepted_htlc`] with less than the amount provided in
314          * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
315          * actual forward amounts is their fee.
316          * 
317          * # Note
318          * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is
319          * as-expected if this feature is activated, otherwise they may lose money!
320          * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the
321          * counterparty.
322          * 
323          * # Note
324          * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116.
325          * Unsetting this flag between restarts may lead to payment receive failures.
326          * 
327          * Default value: false.
328          * 
329          * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
330          * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
331          * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
332          * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat
333          * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat
334          * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat
335          */
336         public void set_accept_underpaying_htlcs(boolean val) {
337                 bindings.ChannelConfig_set_accept_underpaying_htlcs(this.ptr, val);
338                 Reference.reachabilityFence(this);
339                 Reference.reachabilityFence(val);
340         }
341
342         /**
343          * Constructs a new ChannelConfig given each field
344          */
345         public static ChannelConfig of(int forwarding_fee_proportional_millionths_arg, int forwarding_fee_base_msat_arg, short cltv_expiry_delta_arg, org.ldk.structs.MaxDustHTLCExposure max_dust_htlc_exposure_arg, long force_close_avoidance_max_fee_satoshis_arg, boolean accept_underpaying_htlcs_arg) {
346                 long ret = bindings.ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_arg.ptr, force_close_avoidance_max_fee_satoshis_arg, accept_underpaying_htlcs_arg);
347                 Reference.reachabilityFence(forwarding_fee_proportional_millionths_arg);
348                 Reference.reachabilityFence(forwarding_fee_base_msat_arg);
349                 Reference.reachabilityFence(cltv_expiry_delta_arg);
350                 Reference.reachabilityFence(max_dust_htlc_exposure_arg);
351                 Reference.reachabilityFence(force_close_avoidance_max_fee_satoshis_arg);
352                 Reference.reachabilityFence(accept_underpaying_htlcs_arg);
353                 if (ret >= 0 && ret <= 4096) { return null; }
354                 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
355                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
356                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(max_dust_htlc_exposure_arg); };
357                 return ret_hu_conv;
358         }
359
360         long clone_ptr() {
361                 long ret = bindings.ChannelConfig_clone_ptr(this.ptr);
362                 Reference.reachabilityFence(this);
363                 return ret;
364         }
365
366         /**
367          * Creates a copy of the ChannelConfig
368          */
369         public ChannelConfig clone() {
370                 long ret = bindings.ChannelConfig_clone(this.ptr);
371                 Reference.reachabilityFence(this);
372                 if (ret >= 0 && ret <= 4096) { return null; }
373                 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
374                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
375                 return ret_hu_conv;
376         }
377
378         /**
379          * Checks if two ChannelConfigs contain equal inner contents.
380          * This ignores pointers and is_owned flags and looks at the values in fields.
381          * Two objects with NULL inner values will be considered "equal" here.
382          */
383         public boolean eq(org.ldk.structs.ChannelConfig b) {
384                 boolean ret = bindings.ChannelConfig_eq(this.ptr, b == null ? 0 : b.ptr);
385                 Reference.reachabilityFence(this);
386                 Reference.reachabilityFence(b);
387                 if (this != null) { this.ptrs_to.add(b); };
388                 return ret;
389         }
390
391         @Override public boolean equals(Object o) {
392                 if (!(o instanceof ChannelConfig)) return false;
393                 return this.eq((ChannelConfig)o);
394         }
395         /**
396          * Applies the given [`ChannelConfigUpdate`] as a partial update to the [`ChannelConfig`].
397          */
398         public void apply(org.ldk.structs.ChannelConfigUpdate update) {
399                 bindings.ChannelConfig_apply(this.ptr, update == null ? 0 : update.ptr);
400                 Reference.reachabilityFence(this);
401                 Reference.reachabilityFence(update);
402                 if (this != null) { this.ptrs_to.add(update); };
403         }
404
405         /**
406          * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
407          */
408         public static ChannelConfig with_default() {
409                 long ret = bindings.ChannelConfig_default();
410                 if (ret >= 0 && ret <= 4096) { return null; }
411                 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
412                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
413                 return ret_hu_conv;
414         }
415
416         /**
417          * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
418          */
419         public byte[] write() {
420                 byte[] ret = bindings.ChannelConfig_write(this.ptr);
421                 Reference.reachabilityFence(this);
422                 return ret;
423         }
424
425         /**
426          * Read a ChannelConfig from a byte array, created by ChannelConfig_write
427          */
428         public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
429                 long ret = bindings.ChannelConfig_read(ser);
430                 Reference.reachabilityFence(ser);
431                 if (ret >= 0 && ret <= 4096) { return null; }
432                 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
433                 return ret_hu_conv;
434         }
435
436 }