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