[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelConfig.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Options which apply on a per-channel basis and may change at runtime or based on negotiation
11  * with our counterparty.
12  */
13 public class ChannelConfig : CommonBase {
14         internal ChannelConfig(object _dummy, long ptr) : base(ptr) { }
15         ~ChannelConfig() {
16                 if (ptr != 0) { bindings.ChannelConfig_free(ptr); }
17         }
18
19         /**
20          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
21          * over the channel.
22          * This may be allowed to change at runtime in a later update, however doing so must result in
23          * update messages sent to notify all nodes of our updated relay fee.
24          * 
25          * Default value: 0.
26          */
27         public int get_forwarding_fee_proportional_millionths() {
28                 int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr);
29                 GC.KeepAlive(this);
30                 return ret;
31         }
32
33         /**
34          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
35          * over the channel.
36          * This may be allowed to change at runtime in a later update, however doing so must result in
37          * update messages sent to notify all nodes of our updated relay fee.
38          * 
39          * Default value: 0.
40          */
41         public void set_forwarding_fee_proportional_millionths(int val) {
42                 bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, val);
43                 GC.KeepAlive(this);
44                 GC.KeepAlive(val);
45         }
46
47         /**
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.
52          * 
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
55          * this node.
56          * 
57          * Default value: 1000.
58          * 
59          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
60          */
61         public int get_forwarding_fee_base_msat() {
62                 int ret = bindings.ChannelConfig_get_forwarding_fee_base_msat(this.ptr);
63                 GC.KeepAlive(this);
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                 GC.KeepAlive(this);
84                 GC.KeepAlive(val);
85         }
86
87         /**
88          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
89          * the channel this config applies to.
90          * 
91          * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
92          * HTLC balance when a channel appears on-chain whereas
93          * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
94          * (non-HTLC-encumbered) balance.
95          * 
96          * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
97          * we (or one of our watchtowers) MUST be online to check for broadcast of the current
98          * commitment transaction at least once per this many blocks (minus some margin to allow us
99          * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
100          * the spending transaction).
101          * 
102          * Default value: 72 (12 hours at an average of 6 blocks/hour).
103          * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
104          * [`MIN_CLTV_EXPIRY_DELTA`] instead.
105          * 
106          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
107          */
108         public short get_cltv_expiry_delta() {
109                 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
110                 GC.KeepAlive(this);
111                 return ret;
112         }
113
114         /**
115          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
116          * the channel this config applies to.
117          * 
118          * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
119          * HTLC balance when a channel appears on-chain whereas
120          * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
121          * (non-HTLC-encumbered) balance.
122          * 
123          * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
124          * we (or one of our watchtowers) MUST be online to check for broadcast of the current
125          * commitment transaction at least once per this many blocks (minus some margin to allow us
126          * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
127          * the spending transaction).
128          * 
129          * Default value: 72 (12 hours at an average of 6 blocks/hour).
130          * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
131          * [`MIN_CLTV_EXPIRY_DELTA`] instead.
132          * 
133          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
134          */
135         public void set_cltv_expiry_delta(short val) {
136                 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(val);
139         }
140
141         /**
142          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
143          * small to claim on-chain.
144          * 
145          * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
146          * not be claimable on-chain, instead being turned into additional miner fees if either
147          * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
148          * to such payments may be sustantial if there are many dust HTLCs present when the
149          * channel is force-closed.
150          * 
151          * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
152          * channel negotiated throughout the channel open process, along with the fees required to have
153          * a broadcastable HTLC spending transaction. When a channel supports anchor outputs
154          * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
155          * account the HTLC transaction fee as it is zero. Because of this, you may want to set this
156          * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier
157          * variant is primarily intended for use with pre-anchor channels.
158          * 
159          * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total
160          * exposure across all three types per-channel.
161          * 
162          * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000.
163          */
164         public MaxDustHTLCExposure get_max_dust_htlc_exposure() {
165                 long ret = bindings.ChannelConfig_get_max_dust_htlc_exposure(this.ptr);
166                 GC.KeepAlive(this);
167                 if (ret >= 0 && ret <= 4096) { return null; }
168                 org.ldk.structs.MaxDustHTLCExposure ret_hu_conv = org.ldk.structs.MaxDustHTLCExposure.constr_from_ptr(ret);
169                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
170                 return ret_hu_conv;
171         }
172
173         /**
174          * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too
175          * small to claim on-chain.
176          * 
177          * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will
178          * not be claimable on-chain, instead being turned into additional miner fees if either
179          * party force-closes the channel. Because the threshold is per-HTLC, our total exposure
180          * to such payments may be sustantial if there are many dust HTLCs present when the
181          * channel is force-closed.
182          * 
183          * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a
184          * channel negotiated throughout the channel open process, along with the fees required to have
185          * a broadcastable HTLC spending transaction. When a channel supports anchor outputs
186          * (specifically the zero fee HTLC transaction variant), this threshold no longer takes into
187          * account the HTLC transaction fee as it is zero. Because of this, you may want to set this
188          * value to a fixed limit for channels using anchor outputs, while the fee rate multiplier
189          * variant is primarily intended for use with pre-anchor channels.
190          * 
191          * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total
192          * exposure across all three types per-channel.
193          * 
194          * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000.
195          */
196         public void set_max_dust_htlc_exposure(org.ldk.structs.MaxDustHTLCExposure val) {
197                 bindings.ChannelConfig_set_max_dust_htlc_exposure(this.ptr, val.ptr);
198                 GC.KeepAlive(this);
199                 GC.KeepAlive(val);
200                 if (this != null) { this.ptrs_to.AddLast(val); };
201         }
202
203         /**
204          * The additional fee we're willing to pay to avoid waiting for the counterparty's
205          * `to_self_delay` to reclaim funds.
206          * 
207          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
208          * closing transaction which both sides find acceptable, ultimately paid by the channel
209          * funder/initiator.
210          * 
211          * When we are the funder, because we have to pay the channel closing fee, we bound the
212          * acceptable fee by our [`ChannelCloseMinimum`] and [`NonAnchorChannelFee`] fees, with the upper bound increased by
213          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
214          * [`NonAnchorChannelFee`] feerate during normal operation, this value represents the additional fee we're
215          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
216          * funds.
217          * 
218          * When we are not the funder, we require the closing transaction fee pay at least our
219          * [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like.
220          * Thus, this value is ignored when we are not the funder.
221          * 
222          * Default value: 1000 satoshis.
223          * 
224          * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
225          * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
226          */
227         public long get_force_close_avoidance_max_fee_satoshis() {
228                 long ret = bindings.ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this.ptr);
229                 GC.KeepAlive(this);
230                 return ret;
231         }
232
233         /**
234          * The additional fee we're willing to pay to avoid waiting for the counterparty's
235          * `to_self_delay` to reclaim funds.
236          * 
237          * When we close a channel cooperatively with our counterparty, we negotiate a fee for the
238          * closing transaction which both sides find acceptable, ultimately paid by the channel
239          * funder/initiator.
240          * 
241          * When we are the funder, because we have to pay the channel closing fee, we bound the
242          * acceptable fee by our [`ChannelCloseMinimum`] and [`NonAnchorChannelFee`] fees, with the upper bound increased by
243          * this value. Because the on-chain fee we'd pay to force-close the channel is kept near our
244          * [`NonAnchorChannelFee`] feerate during normal operation, this value represents the additional fee we're
245          * willing to pay in order to avoid waiting for our counterparty's to_self_delay to reclaim our
246          * funds.
247          * 
248          * When we are not the funder, we require the closing transaction fee pay at least our
249          * [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like.
250          * Thus, this value is ignored when we are not the funder.
251          * 
252          * Default value: 1000 satoshis.
253          * 
254          * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee
255          * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum
256          */
257         public void set_force_close_avoidance_max_fee_satoshis(long val) {
258                 bindings.ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this.ptr, val);
259                 GC.KeepAlive(this);
260                 GC.KeepAlive(val);
261         }
262
263         /**
264          * If set, allows this channel's counterparty to skim an additional fee off this node's inbound
265          * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users.
266          * 
267          * Usage:
268          * - The payee will set this option and set its invoice route hints to use [intercept scids]
269          * generated by this channel's counterparty.
270          * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
271          * [`forward_intercepted_htlc`] with less than the amount provided in
272          * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
273          * actual forward amounts is their fee. See
274          * <https://github.com/BitcoinAndLightningLayerSpecs/lsp/tree/main/LSPS2#flow-lsp-trusts-client-model>
275          * for how this feature may be used in the LSP use case.
276          * 
277          * # Note
278          * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is
279          * as-expected if this feature is activated, otherwise they may lose money!
280          * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the
281          * counterparty.
282          * 
283          * # Note
284          * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116.
285          * Unsetting this flag between restarts may lead to payment receive failures.
286          * 
287          * Default value: false.
288          * 
289          * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
290          * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
291          * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
292          * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat
293          * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat
294          * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat
295          */
296         public bool get_accept_underpaying_htlcs() {
297                 bool ret = bindings.ChannelConfig_get_accept_underpaying_htlcs(this.ptr);
298                 GC.KeepAlive(this);
299                 return ret;
300         }
301
302         /**
303          * If set, allows this channel's counterparty to skim an additional fee off this node's inbound
304          * HTLCs. Useful for liquidity providers to offload on-chain channel costs to end users.
305          * 
306          * Usage:
307          * - The payee will set this option and set its invoice route hints to use [intercept scids]
308          * generated by this channel's counterparty.
309          * - The counterparty will get an [`HTLCIntercepted`] event upon payment forward, and call
310          * [`forward_intercepted_htlc`] with less than the amount provided in
311          * [`HTLCIntercepted::expected_outbound_amount_msat`]. The difference between the expected and
312          * actual forward amounts is their fee. See
313          * <https://github.com/BitcoinAndLightningLayerSpecs/lsp/tree/main/LSPS2#flow-lsp-trusts-client-model>
314          * for how this feature may be used in the LSP use case.
315          * 
316          * # Note
317          * It's important for payee wallet software to verify that [`PaymentClaimable::amount_msat`] is
318          * as-expected if this feature is activated, otherwise they may lose money!
319          * [`PaymentClaimable::counterparty_skimmed_fee_msat`] provides the fee taken by the
320          * counterparty.
321          * 
322          * # Note
323          * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116.
324          * Unsetting this flag between restarts may lead to payment receive failures.
325          * 
326          * Default value: false.
327          * 
328          * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid
329          * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc
330          * [`HTLCIntercepted`]: crate::events::Event::HTLCIntercepted
331          * [`HTLCIntercepted::expected_outbound_amount_msat`]: crate::events::Event::HTLCIntercepted::expected_outbound_amount_msat
332          * [`PaymentClaimable::amount_msat`]: crate::events::Event::PaymentClaimable::amount_msat
333          * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: crate::events::Event::PaymentClaimable::counterparty_skimmed_fee_msat
334          */
335         public void set_accept_underpaying_htlcs(bool val) {
336                 bindings.ChannelConfig_set_accept_underpaying_htlcs(this.ptr, val);
337                 GC.KeepAlive(this);
338                 GC.KeepAlive(val);
339         }
340
341         /**
342          * Constructs a new ChannelConfig given each field
343          */
344         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, bool accept_underpaying_htlcs_arg) {
345                 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);
346                 GC.KeepAlive(forwarding_fee_proportional_millionths_arg);
347                 GC.KeepAlive(forwarding_fee_base_msat_arg);
348                 GC.KeepAlive(cltv_expiry_delta_arg);
349                 GC.KeepAlive(max_dust_htlc_exposure_arg);
350                 GC.KeepAlive(force_close_avoidance_max_fee_satoshis_arg);
351                 GC.KeepAlive(accept_underpaying_htlcs_arg);
352                 if (ret >= 0 && ret <= 4096) { return null; }
353                 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
354                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
355                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(max_dust_htlc_exposure_arg); };
356                 return ret_hu_conv;
357         }
358
359         internal long clone_ptr() {
360                 long ret = bindings.ChannelConfig_clone_ptr(this.ptr);
361                 GC.KeepAlive(this);
362                 return ret;
363         }
364
365         /**
366          * Creates a copy of the ChannelConfig
367          */
368         public ChannelConfig clone() {
369                 long ret = bindings.ChannelConfig_clone(this.ptr);
370                 GC.KeepAlive(this);
371                 if (ret >= 0 && ret <= 4096) { return null; }
372                 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
373                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
374                 return ret_hu_conv;
375         }
376
377         /**
378          * Checks if two ChannelConfigs contain equal inner contents.
379          * This ignores pointers and is_owned flags and looks at the values in fields.
380          * Two objects with NULL inner values will be considered "equal" here.
381          */
382         public bool eq(org.ldk.structs.ChannelConfig b) {
383                 bool ret = bindings.ChannelConfig_eq(this.ptr, b == null ? 0 : b.ptr);
384                 GC.KeepAlive(this);
385                 GC.KeepAlive(b);
386                 if (this != null) { this.ptrs_to.AddLast(b); };
387                 return ret;
388         }
389
390         public override bool Equals(object o) {
391                 if (!(o is ChannelConfig)) return false;
392                 return this.eq((ChannelConfig)o);
393         }
394         /**
395          * Applies the given [`ChannelConfigUpdate`] as a partial update to the [`ChannelConfig`].
396          */
397         public void apply(org.ldk.structs.ChannelConfigUpdate update) {
398                 bindings.ChannelConfig_apply(this.ptr, update == null ? 0 : update.ptr);
399                 GC.KeepAlive(this);
400                 GC.KeepAlive(update);
401                 if (this != null) { this.ptrs_to.AddLast(update); };
402         }
403
404         /**
405          * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
406          */
407         public static ChannelConfig with_default() {
408                 long ret = bindings.ChannelConfig_default();
409                 if (ret >= 0 && ret <= 4096) { return null; }
410                 org.ldk.structs.ChannelConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelConfig(null, ret); }
411                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
412                 return ret_hu_conv;
413         }
414
415         /**
416          * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
417          */
418         public byte[] write() {
419                 long ret = bindings.ChannelConfig_write(this.ptr);
420                 GC.KeepAlive(this);
421                 if (ret >= 0 && ret <= 4096) { return null; }
422                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
423                 return ret_conv;
424         }
425
426         /**
427          * Read a ChannelConfig from a byte array, created by ChannelConfig_write
428          */
429         public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
430                 long ret = bindings.ChannelConfig_read(InternalUtils.encodeUint8Array(ser));
431                 GC.KeepAlive(ser);
432                 if (ret >= 0 && ret <= 4096) { return null; }
433                 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
434                 return ret_hu_conv;
435         }
436
437 }
438 } } }