Update auto-generated bindings to LDK v0.0.99
[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
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 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ChannelConfig extends CommonBase {
15         ChannelConfig(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ChannelConfig_free(ptr); }
20         }
21
22         /**
23          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
24          * over the channel.
25          * This may be allowed to change at runtime in a later update, however doing so must result in
26          * update messages sent to notify all nodes of our updated relay fee.
27          * 
28          * Default value: 0.
29          */
30         public int get_forwarding_fee_proportional_millionths() {
31                 int ret = bindings.ChannelConfig_get_forwarding_fee_proportional_millionths(this.ptr);
32                 return ret;
33         }
34
35         /**
36          * Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound
37          * over the channel.
38          * This may be allowed to change at runtime in a later update, however doing so must result in
39          * update messages sent to notify all nodes of our updated relay fee.
40          * 
41          * Default value: 0.
42          */
43         public void set_forwarding_fee_proportional_millionths(int val) {
44                 bindings.ChannelConfig_set_forwarding_fee_proportional_millionths(this.ptr, 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                 return ret;
64         }
65
66         /**
67          * Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in
68          * excess of [`forwarding_fee_proportional_millionths`].
69          * This may be allowed to change at runtime in a later update, however doing so must result in
70          * update messages sent to notify all nodes of our updated relay fee.
71          * 
72          * The default value of a single satoshi roughly matches the market rate on many routing nodes
73          * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through
74          * this node.
75          * 
76          * Default value: 1000.
77          * 
78          * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths
79          */
80         public void set_forwarding_fee_base_msat(int val) {
81                 bindings.ChannelConfig_set_forwarding_fee_base_msat(this.ptr, val);
82         }
83
84         /**
85          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
86          * the channel this config applies to.
87          * 
88          * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
89          * HTLC balance when a channel appears on-chain whereas
90          * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
91          * (non-HTLC-encumbered) balance.
92          * 
93          * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
94          * we (or one of our watchtowers) MUST be online to check for broadcast of the current
95          * commitment transaction at least once per this many blocks (minus some margin to allow us
96          * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
97          * the spending transaction).
98          * 
99          * Default value: 72 (12 hours at an average of 6 blocks/hour).
100          * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
101          * [`MIN_CLTV_EXPIRY_DELTA`] instead.
102          * 
103          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
104          */
105         public short get_cltv_expiry_delta() {
106                 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
107                 return ret;
108         }
109
110         /**
111          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
112          * the channel this config applies to.
113          * 
114          * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
115          * HTLC balance when a channel appears on-chain whereas
116          * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
117          * (non-HTLC-encumbered) balance.
118          * 
119          * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
120          * we (or one of our watchtowers) MUST be online to check for broadcast of the current
121          * commitment transaction at least once per this many blocks (minus some margin to allow us
122          * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
123          * the spending transaction).
124          * 
125          * Default value: 72 (12 hours at an average of 6 blocks/hour).
126          * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
127          * [`MIN_CLTV_EXPIRY_DELTA`] instead.
128          * 
129          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
130          */
131         public void set_cltv_expiry_delta(short val) {
132                 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
133         }
134
135         /**
136          * Set to announce the channel publicly and notify all nodes that they can route via this
137          * channel.
138          * 
139          * This should only be set to true for nodes which expect to be online reliably.
140          * 
141          * As the node which funds a channel picks this value this will only apply for new outbound
142          * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
143          * 
144          * This cannot be changed after the initial channel handshake.
145          * 
146          * Default value: false.
147          */
148         public boolean get_announced_channel() {
149                 boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr);
150                 return ret;
151         }
152
153         /**
154          * Set to announce the channel publicly and notify all nodes that they can route via this
155          * channel.
156          * 
157          * This should only be set to true for nodes which expect to be online reliably.
158          * 
159          * As the node which funds a channel picks this value this will only apply for new outbound
160          * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set.
161          * 
162          * This cannot be changed after the initial channel handshake.
163          * 
164          * Default value: false.
165          */
166         public void set_announced_channel(boolean val) {
167                 bindings.ChannelConfig_set_announced_channel(this.ptr, val);
168         }
169
170         /**
171          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
172          * supports it, they will then enforce the mutual-close output to us matches what we provided
173          * at intialization, preventing us from closing to an alternate pubkey.
174          * 
175          * This is set to true by default to provide a slight increase in security, though ultimately
176          * any attacker who is able to take control of a channel can just as easily send the funds via
177          * lightning payments, so we never require that our counterparties support this option.
178          * 
179          * This cannot be changed after a channel has been initialized.
180          * 
181          * Default value: true.
182          */
183         public boolean get_commit_upfront_shutdown_pubkey() {
184                 boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
185                 return ret;
186         }
187
188         /**
189          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
190          * supports it, they will then enforce the mutual-close output to us matches what we provided
191          * at intialization, preventing us from closing to an alternate pubkey.
192          * 
193          * This is set to true by default to provide a slight increase in security, though ultimately
194          * any attacker who is able to take control of a channel can just as easily send the funds via
195          * lightning payments, so we never require that our counterparties support this option.
196          * 
197          * This cannot be changed after a channel has been initialized.
198          * 
199          * Default value: true.
200          */
201         public void set_commit_upfront_shutdown_pubkey(boolean val) {
202                 bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
203         }
204
205         /**
206          * Constructs a new ChannelConfig given each field
207          */
208         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) {
209                 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);
210                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
211                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
212                 return ret_hu_conv;
213         }
214
215         /**
216          * Creates a copy of the ChannelConfig
217          */
218         public ChannelConfig clone() {
219                 long ret = bindings.ChannelConfig_clone(this.ptr);
220                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
221                 ret_hu_conv.ptrs_to.add(this);
222                 return ret_hu_conv;
223         }
224
225         /**
226          * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
227          */
228         public static ChannelConfig with_default() {
229                 long ret = bindings.ChannelConfig_default();
230                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
231                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
232                 return ret_hu_conv;
233         }
234
235         /**
236          * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
237          */
238         public byte[] write() {
239                 byte[] ret = bindings.ChannelConfig_write(this.ptr);
240                 return ret;
241         }
242
243         /**
244          * Read a ChannelConfig from a byte array, created by ChannelConfig_write
245          */
246         public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
247                 long ret = bindings.ChannelConfig_read(ser);
248                 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
249                 return ret_hu_conv;
250         }
251
252 }