1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * Configuration we set when applicable.
12 * Default::default() provides sane defaults.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelHandshakeConfig extends CommonBase {
16 ChannelHandshakeConfig(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelHandshakeConfig_free(ptr); }
24 * Confirmations we will wait for before considering the channel locked in.
25 * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
26 * equivalent limit applied to outbound channels).
30 public int get_minimum_depth() {
31 int ret = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr);
36 * Confirmations we will wait for before considering the channel locked in.
37 * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
38 * equivalent limit applied to outbound channels).
42 public void set_minimum_depth(int val) {
43 bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val);
47 * Set to the number of blocks we require our counterparty to wait to claim their money (ie
48 * the number of blocks we have to punish our counterparty if they broadcast a revoked
51 * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
52 * be online to check for revoked transactions on-chain at least once every our_to_self_delay
53 * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
54 * possibly with time in between to RBF the spending transaction).
56 * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
57 * case of an honest unilateral channel close, which implicitly decrease the economic value of
60 * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
61 * can tweak config to ask for more security, not less.
63 public short get_our_to_self_delay() {
64 short ret = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr);
69 * Set to the number of blocks we require our counterparty to wait to claim their money (ie
70 * the number of blocks we have to punish our counterparty if they broadcast a revoked
73 * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST
74 * be online to check for revoked transactions on-chain at least once every our_to_self_delay
75 * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction,
76 * possibly with time in between to RBF the spending transaction).
78 * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
79 * case of an honest unilateral channel close, which implicitly decrease the economic value of
82 * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
83 * can tweak config to ask for more security, not less.
85 public void set_our_to_self_delay(short val) {
86 bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val);
90 * Set to the smallest value HTLC we will accept to process.
92 * This value is sent to our counterparty on channel-open and we close the channel any time
93 * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
95 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
98 public long get_our_htlc_minimum_msat() {
99 long ret = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr);
104 * Set to the smallest value HTLC we will accept to process.
106 * This value is sent to our counterparty on channel-open and we close the channel any time
107 * our counterparty misbehaves by sending us an HTLC with a value smaller than this.
109 * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required
112 public void set_our_htlc_minimum_msat(long val) {
113 bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val);
117 * Constructs a new ChannelHandshakeConfig given each field
119 public static ChannelHandshakeConfig of(int minimum_depth_arg, short our_to_self_delay_arg, long our_htlc_minimum_msat_arg) {
120 long ret = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
121 if (ret < 1024) { return null; }
122 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
123 ret_hu_conv.ptrs_to.add(ret_hu_conv);
128 * Creates a copy of the ChannelHandshakeConfig
130 public ChannelHandshakeConfig clone() {
131 long ret = bindings.ChannelHandshakeConfig_clone(this.ptr);
132 if (ret < 1024) { return null; }
133 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
134 ret_hu_conv.ptrs_to.add(this);
139 * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used.
141 public static ChannelHandshakeConfig with_default() {
142 long ret = bindings.ChannelHandshakeConfig_default();
143 if (ret < 1024) { return null; }
144 ChannelHandshakeConfig ret_hu_conv = new ChannelHandshakeConfig(null, ret);
145 ret_hu_conv.ptrs_to.add(ret_hu_conv);