1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * Configuration we set when applicable.
13 * Default::default() provides sane defaults.
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 {
21 if (ptr != 0) { bindings.ChannelHandshakeConfig_free(ptr); }
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).
31 public int get_minimum_depth() {
32 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
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).
43 public void set_minimum_depth(int val) {
44 bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val);
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
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).
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
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.
64 public short get_our_to_self_delay() {
65 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
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
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).
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
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.
86 public void set_our_to_self_delay(short val) {
87 bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val);
91 * Set to the smallest value HTLC we will accept to process.
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.
96 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
99 public long get_our_htlc_minimum_msat() {
100 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
105 * Set to the smallest value HTLC we will accept to process.
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.
110 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
113 public void set_our_htlc_minimum_msat(long val) {
114 bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val);
118 * Constructs a new ChannelHandshakeConfig given each field
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 < 1024) { return null; }
123 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
124 ret_hu_conv.ptrs_to.add(ret_hu_conv);
129 * Creates a copy of the ChannelHandshakeConfig
131 public ChannelHandshakeConfig clone() {
132 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
133 if (ret < 1024) { return null; }
134 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
135 ret_hu_conv.ptrs_to.add(this);
140 * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
142 public static ChannelHandshakeConfig with_default() {
143 long ret = bindings.ChannelHandshakeConfig_default();
144 if (ret < 1024) { return null; }
145 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
146 ret_hu_conv.ptrs_to.add(ret_hu_conv);