9f42abadefd8b7820a2dbf86665b6961362e0570
[ldk-java] / src / main / java / org / ldk / structs / ChannelHandshakeConfig.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  * Configuration we set when applicable.
13  * 
14  * Default::default() provides sane defaults.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ChannelHandshakeConfig extends CommonBase {
18         ChannelHandshakeConfig(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.ChannelHandshakeConfig_free(ptr); }
23         }
24
25         /**
26          * Confirmations we will wait for before considering the channel locked in.
27          * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
28          * equivalent limit applied to outbound channels).
29          * 
30          * Default value: 6.
31          */
32         public int get_minimum_depth() {
33                 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
34                 Reference.reachabilityFence(this);
35                 return ret;
36         }
37
38         /**
39          * Confirmations we will wait for before considering the channel locked in.
40          * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
41          * equivalent limit applied to outbound channels).
42          * 
43          * Default value: 6.
44          */
45         public void set_minimum_depth(int val) {
46                 bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val);
47                 Reference.reachabilityFence(this);
48                 Reference.reachabilityFence(val);
49         }
50
51         /**
52          * Set to the number of blocks we require our counterparty to wait to claim their money (ie
53          * the number of blocks we have to punish our counterparty if they broadcast a revoked
54          * transaction).
55          * 
56          * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
57          * be online to check for revoked transactions on-chain at least once every our_to_self_delay
58          * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
59          * possibly with time in between to RBF the spending transaction).
60          * 
61          * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
62          * case of an honest unilateral channel close, which implicitly decrease the economic value of
63          * our channel.
64          * 
65          * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
66          * can tweak config to ask for more security, not less.
67          */
68         public short get_our_to_self_delay() {
69                 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * Set to the number of blocks we require our counterparty to wait to claim their money (ie
76          * the number of blocks we have to punish our counterparty if they broadcast a revoked
77          * transaction).
78          * 
79          * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
80          * be online to check for revoked transactions on-chain at least once every our_to_self_delay
81          * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
82          * possibly with time in between to RBF the spending transaction).
83          * 
84          * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
85          * case of an honest unilateral channel close, which implicitly decrease the economic value of
86          * our channel.
87          * 
88          * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
89          * can tweak config to ask for more security, not less.
90          */
91         public void set_our_to_self_delay(short val) {
92                 bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * Set to the smallest value HTLC we will accept to process.
99          * 
100          * This value is sent to our counterparty on channel-open and we close the channel any time
101          * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
102          * 
103          * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
104          * by the protocol.
105          */
106         public long get_our_htlc_minimum_msat() {
107                 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
108                 Reference.reachabilityFence(this);
109                 return ret;
110         }
111
112         /**
113          * Set to the smallest value HTLC we will accept to process.
114          * 
115          * This value is sent to our counterparty on channel-open and we close the channel any time
116          * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
117          * 
118          * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
119          * by the protocol.
120          */
121         public void set_our_htlc_minimum_msat(long val) {
122                 bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val);
123                 Reference.reachabilityFence(this);
124                 Reference.reachabilityFence(val);
125         }
126
127         /**
128          * Constructs a new ChannelHandshakeConfig given each field
129          */
130         public static ChannelHandshakeConfig of(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg) {
131                 long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
132                 Reference.reachabilityFence(minimum_depth_arg);
133                 Reference.reachabilityFence(our_to_self_delay_arg);
134                 Reference.reachabilityFence(our_htlc_minimum_msat_arg);
135                 if (ret >= 0 && ret <= 4096) { return null; }
136                 ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
137                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
138                 return ret_hu_conv;
139         }
140
141         long clone_ptr() {
142                 long ret = bindings.ChannelHandshakeConfig_clone_ptr(this.ptr);
143                 Reference.reachabilityFence(this);
144                 return ret;
145         }
146
147         /**
148          * Creates a copy of the ChannelHandshakeConfig
149          */
150         public ChannelHandshakeConfig clone() {
151                 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
152                 Reference.reachabilityFence(this);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
155                 ret_hu_conv.ptrs_to.add(this);
156                 return ret_hu_conv;
157         }
158
159         /**
160          * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
161          */
162         public static ChannelHandshakeConfig with_default() {
163                 long ret = bindings.ChannelHandshakeConfig_default();
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 ChannelHandshakeConfig ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelHandshakeConfig(null, ret); }
166                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
167                 return ret_hu_conv;
168         }
169
170 }