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
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) the channel will charge per transferred satoshi.
24          * This may be allowed to change at runtime in a later update, however doing so must result in
25          * update messages sent to notify all nodes of our updated relay fee.
26          * 
27          * Default value: 0.
28          */
29         public int get_fee_proportional_millionths() {
30                 int ret = bindings.ChannelConfig_get_fee_proportional_millionths(this.ptr);
31                 return ret;
32         }
33
34         /**
35          * Amount (in millionths of a satoshi) the channel will charge per transferred satoshi.
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_fee_proportional_millionths(int val) {
42                 bindings.ChannelConfig_set_fee_proportional_millionths(this.ptr, val);
43         }
44
45         /**
46          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
47          * the channel this config applies to.
48          * 
49          * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
50          * HTLC balance when a channel appears on-chain whereas
51          * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
52          * (non-HTLC-encumbered) balance.
53          * 
54          * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
55          * we (or one of our watchtowers) MUST be online to check for broadcast of the current
56          * commitment transaction at least once per this many blocks (minus some margin to allow us
57          * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
58          * the spending transaction).
59          * 
60          * Default value: 72 (12 hours at an average of 6 blocks/hour).
61          * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
62          * [`MIN_CLTV_EXPIRY_DELTA`] instead.
63          * 
64          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
65          */
66         public short get_cltv_expiry_delta() {
67                 short ret = bindings.ChannelConfig_get_cltv_expiry_delta(this.ptr);
68                 return ret;
69         }
70
71         /**
72          * The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over
73          * the channel this config applies to.
74          * 
75          * This is analogous to [`ChannelHandshakeConfig::our_to_self_delay`] but applies to in-flight
76          * HTLC balance when a channel appears on-chain whereas
77          * [`ChannelHandshakeConfig::our_to_self_delay`] applies to the remaining
78          * (non-HTLC-encumbered) balance.
79          * 
80          * Thus, for HTLC-encumbered balances to be enforced on-chain when a channel is force-closed,
81          * we (or one of our watchtowers) MUST be online to check for broadcast of the current
82          * commitment transaction at least once per this many blocks (minus some margin to allow us
83          * enough time to broadcast and confirm a transaction, possibly with time in between to RBF
84          * the spending transaction).
85          * 
86          * Default value: 72 (12 hours at an average of 6 blocks/hour).
87          * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as
88          * [`MIN_CLTV_EXPIRY_DELTA`] instead.
89          * 
90          * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA
91          */
92         public void set_cltv_expiry_delta(short val) {
93                 bindings.ChannelConfig_set_cltv_expiry_delta(this.ptr, val);
94         }
95
96         /**
97          * Set to announce the channel publicly and notify all nodes that they can route via this
98          * channel.
99          * 
100          * This should only be set to true for nodes which expect to be online reliably.
101          * 
102          * As the node which funds a channel picks this value this will only apply for new outbound
103          * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
104          * 
105          * This cannot be changed after the initial channel handshake.
106          * 
107          * Default value: false.
108          */
109         public boolean get_announced_channel() {
110                 boolean ret = bindings.ChannelConfig_get_announced_channel(this.ptr);
111                 return ret;
112         }
113
114         /**
115          * Set to announce the channel publicly and notify all nodes that they can route via this
116          * channel.
117          * 
118          * This should only be set to true for nodes which expect to be online reliably.
119          * 
120          * As the node which funds a channel picks this value this will only apply for new outbound
121          * channels unless ChannelHandshakeLimits::force_announced_channel_preferences is set.
122          * 
123          * This cannot be changed after the initial channel handshake.
124          * 
125          * Default value: false.
126          */
127         public void set_announced_channel(boolean val) {
128                 bindings.ChannelConfig_set_announced_channel(this.ptr, val);
129         }
130
131         /**
132          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
133          * supports it, they will then enforce the mutual-close output to us matches what we provided
134          * at intialization, preventing us from closing to an alternate pubkey.
135          * 
136          * This is set to true by default to provide a slight increase in security, though ultimately
137          * any attacker who is able to take control of a channel can just as easily send the funds via
138          * lightning payments, so we never require that our counterparties support this option.
139          * 
140          * This cannot be changed after a channel has been initialized.
141          * 
142          * Default value: true.
143          */
144         public boolean get_commit_upfront_shutdown_pubkey() {
145                 boolean ret = bindings.ChannelConfig_get_commit_upfront_shutdown_pubkey(this.ptr);
146                 return ret;
147         }
148
149         /**
150          * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty
151          * supports it, they will then enforce the mutual-close output to us matches what we provided
152          * at intialization, preventing us from closing to an alternate pubkey.
153          * 
154          * This is set to true by default to provide a slight increase in security, though ultimately
155          * any attacker who is able to take control of a channel can just as easily send the funds via
156          * lightning payments, so we never require that our counterparties support this option.
157          * 
158          * This cannot be changed after a channel has been initialized.
159          * 
160          * Default value: true.
161          */
162         public void set_commit_upfront_shutdown_pubkey(boolean val) {
163                 bindings.ChannelConfig_set_commit_upfront_shutdown_pubkey(this.ptr, val);
164         }
165
166         /**
167          * Constructs a new ChannelConfig given each field
168          */
169         public static ChannelConfig of(int fee_proportional_millionths_arg, short cltv_expiry_delta_arg, boolean announced_channel_arg, boolean commit_upfront_shutdown_pubkey_arg) {
170                 long ret = bindings.ChannelConfig_new(fee_proportional_millionths_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
171                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
172                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
173                 return ret_hu_conv;
174         }
175
176         /**
177          * Creates a copy of the ChannelConfig
178          */
179         public ChannelConfig clone() {
180                 long ret = bindings.ChannelConfig_clone(this.ptr);
181                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
182                 ret_hu_conv.ptrs_to.add(this);
183                 return ret_hu_conv;
184         }
185
186         /**
187          * Creates a "default" ChannelConfig. See struct and individual field documentaiton for details on which values are used.
188          */
189         public static ChannelConfig with_default() {
190                 long ret = bindings.ChannelConfig_default();
191                 ChannelConfig ret_hu_conv = new ChannelConfig(null, ret);
192                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
193                 return ret_hu_conv;
194         }
195
196         /**
197          * Serialize the ChannelConfig object into a byte array which can be read by ChannelConfig_read
198          */
199         public byte[] write() {
200                 byte[] ret = bindings.ChannelConfig_write(this.ptr);
201                 return ret;
202         }
203
204         /**
205          * Read a ChannelConfig from a byte array, created by ChannelConfig_write
206          */
207         public static Result_ChannelConfigDecodeErrorZ read(byte[] ser) {
208                 long ret = bindings.ChannelConfig_read(ser);
209                 Result_ChannelConfigDecodeErrorZ ret_hu_conv = Result_ChannelConfigDecodeErrorZ.constr_from_ptr(ret);
210                 return ret_hu_conv;
211         }
212
213 }