1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Configuration we set when applicable.
14 * Default::default() provides sane defaults.
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 {
22 if (ptr != 0) { bindings.ChannelHandshakeConfig_free(ptr); }
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).
32 public int get_minimum_depth() {
33 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
34 Reference.reachabilityFence(this);
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).
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);
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
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).
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
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.
68 public short get_our_to_self_delay() {
69 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
70 Reference.reachabilityFence(this);
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
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).
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
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.
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);
98 * Set to the smallest value HTLC we will accept to process.
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.
103 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
106 public long get_our_htlc_minimum_msat() {
107 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
108 Reference.reachabilityFence(this);
113 * Set to the smallest value HTLC we will accept to process.
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.
118 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
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);
128 * Constructs a new ChannelHandshakeConfig given each field
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);
142 long ret = bindings.ChannelHandshakeConfig_clone_ptr(this.ptr);
143 Reference.reachabilityFence(this);
148 * Creates a copy of the ChannelHandshakeConfig
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);
160 * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
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);