X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelHandshakeLimits.java;h=6f9f5443cfc9a67f08b1fb520e9255e60272c1f6;hb=ca313f2eee377bec222fa82b2939751fa9eab32e;hp=619b10511e9602e0fd607ec6240dbe1cf3832dcf;hpb=a3b773365e6ff5622cca25de409ceaa5a8ba69fe;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java index 619b1051..6f9f5443 100644 --- a/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java +++ b/src/main/java/org/ldk/structs/ChannelHandshakeLimits.java @@ -4,6 +4,8 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; /** @@ -11,7 +13,7 @@ import java.util.Arrays; * * These limits are only applied to our counterparty's limits, not our own. * - * Use 0/::max_value() as appropriate to skip checking. + * Use 0/`::max_value()` as appropriate to skip checking. * * Provides sane defaults for most configurations. * @@ -29,24 +31,51 @@ public class ChannelHandshakeLimits extends CommonBase { } /** - * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so + * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * * Default value: 0. */ public long get_min_funding_satoshis() { long ret = bindings.ChannelHandshakeLimits_get_min_funding_satoshis(this.ptr); + Reference.reachabilityFence(this); return ret; } /** - * Minimum allowed satoshis when a channel is funded, this is supplied by the sender and so + * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * * Default value: 0. */ public void set_min_funding_satoshis(long val) { bindings.ChannelHandshakeLimits_set_min_funding_satoshis(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 2^24 - 1. + */ + public long get_max_funding_satoshis() { + long ret = bindings.ChannelHandshakeLimits_get_max_funding_satoshis(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so + * only applies to inbound channels. + * + * Default value: 2^24 - 1. + */ + public void set_max_funding_satoshis(long val) { + bindings.ChannelHandshakeLimits_set_max_funding_satoshis(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -57,6 +86,7 @@ public class ChannelHandshakeLimits extends CommonBase { */ public long get_max_htlc_minimum_msat() { long ret = bindings.ChannelHandshakeLimits_get_max_htlc_minimum_msat(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -68,6 +98,8 @@ public class ChannelHandshakeLimits extends CommonBase { */ public void set_max_htlc_minimum_msat(long val) { bindings.ChannelHandshakeLimits_set_max_htlc_minimum_msat(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -78,6 +110,7 @@ public class ChannelHandshakeLimits extends CommonBase { */ public long get_min_max_htlc_value_in_flight_msat() { long ret = bindings.ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -89,6 +122,8 @@ public class ChannelHandshakeLimits extends CommonBase { */ public void set_min_max_htlc_value_in_flight_msat(long val) { bindings.ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -100,6 +135,7 @@ public class ChannelHandshakeLimits extends CommonBase { */ public long get_max_channel_reserve_satoshis() { long ret = bindings.ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -112,6 +148,8 @@ public class ChannelHandshakeLimits extends CommonBase { */ public void set_max_channel_reserve_satoshis(long val) { bindings.ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -122,6 +160,7 @@ public class ChannelHandshakeLimits extends CommonBase { */ public short get_min_max_accepted_htlcs() { short ret = bindings.ChannelHandshakeLimits_get_min_max_accepted_htlcs(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -133,60 +172,8 @@ public class ChannelHandshakeLimits extends CommonBase { */ public void set_min_max_accepted_htlcs(short val) { bindings.ChannelHandshakeLimits_set_min_max_accepted_htlcs(this.ptr, val); - } - - /** - * Outputs below a certain value will not be added to on-chain transactions. The dust value is - * required to always be higher than this value so this only applies to HTLC outputs (and - * potentially to-self outputs before any payments have been made). - * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. - * This setting allows you to set a minimum dust limit for their commitment transactions, - * reflecting the reality that tiny outputs are not considered standard transactions and will - * not propagate through the Bitcoin network. - * - * Default value: 546, the current dust limit on the Bitcoin network. - */ - public long get_min_dust_limit_satoshis() { - long ret = bindings.ChannelHandshakeLimits_get_min_dust_limit_satoshis(this.ptr); - return ret; - } - - /** - * Outputs below a certain value will not be added to on-chain transactions. The dust value is - * required to always be higher than this value so this only applies to HTLC outputs (and - * potentially to-self outputs before any payments have been made). - * Thus, HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. - * This setting allows you to set a minimum dust limit for their commitment transactions, - * reflecting the reality that tiny outputs are not considered standard transactions and will - * not propagate through the Bitcoin network. - * - * Default value: 546, the current dust limit on the Bitcoin network. - */ - public void set_min_dust_limit_satoshis(long val) { - bindings.ChannelHandshakeLimits_set_min_dust_limit_satoshis(this.ptr, val); - } - - /** - * Maximum allowed threshold above which outputs will not be generated in their commitment - * transactions. - * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. - * - * Default value: u64::max_value. - */ - public long get_max_dust_limit_satoshis() { - long ret = bindings.ChannelHandshakeLimits_get_max_dust_limit_satoshis(this.ptr); - return ret; - } - - /** - * Maximum allowed threshold above which outputs will not be generated in their commitment - * transactions. - * HTLCs below this amount plus HTLC transaction fees are not enforceable on-chain. - * - * Default value: u64::max_value. - */ - public void set_max_dust_limit_satoshis(long val) { - bindings.ChannelHandshakeLimits_set_max_dust_limit_satoshis(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -199,6 +186,7 @@ public class ChannelHandshakeLimits extends CommonBase { */ public int get_max_minimum_depth() { int ret = bindings.ChannelHandshakeLimits_get_max_minimum_depth(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -212,29 +200,90 @@ public class ChannelHandshakeLimits extends CommonBase { */ public void set_max_minimum_depth(int val) { bindings.ChannelHandshakeLimits_set_max_minimum_depth(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** - * Set to force the incoming channel to match our announced channel preference in - * ChannelConfig. + * Whether we implicitly trust funding transactions generated by us for our own outbound + * channels to not be double-spent. + * + * If this is set, we assume that our own funding transactions are *never* double-spent, and + * thus we can trust them without any confirmations. This is generally a reasonable + * assumption, given we're the only ones who could ever double-spend it (assuming we have sole + * control of the signing keys). * - * Default value: true, to make the default that no announced channels are possible (which is - * appropriate for any nodes which are not online very reliably). + * You may wish to un-set this if you allow the user to (or do in an automated fashion) + * double-spend the funding transaction to RBF with an alternative channel open. + * + * This only applies if our counterparty set their confirmations-required value to 0, and we + * always trust our own funding transaction at 1 confirmation irrespective of this value. + * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being + * `true` (0) and `false` (1). + * + * Default value: true + */ + public boolean get_trust_own_funding_0conf() { + boolean ret = bindings.ChannelHandshakeLimits_get_trust_own_funding_0conf(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Whether we implicitly trust funding transactions generated by us for our own outbound + * channels to not be double-spent. + * + * If this is set, we assume that our own funding transactions are *never* double-spent, and + * thus we can trust them without any confirmations. This is generally a reasonable + * assumption, given we're the only ones who could ever double-spend it (assuming we have sole + * control of the signing keys). + * + * You may wish to un-set this if you allow the user to (or do in an automated fashion) + * double-spend the funding transaction to RBF with an alternative channel open. + * + * This only applies if our counterparty set their confirmations-required value to 0, and we + * always trust our own funding transaction at 1 confirmation irrespective of this value. + * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being + * `true` (0) and `false` (1). + * + * Default value: true + */ + public void set_trust_own_funding_0conf(boolean val) { + bindings.ChannelHandshakeLimits_set_trust_own_funding_0conf(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelHandshakeConfig::announced_channel`]. + * + * For a node which is not online reliably, this should be set to true and + * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. + * + * Default value: true. */ public boolean get_force_announced_channel_preference() { boolean ret = bindings.ChannelHandshakeLimits_get_force_announced_channel_preference(this.ptr); + Reference.reachabilityFence(this); return ret; } /** - * Set to force the incoming channel to match our announced channel preference in - * ChannelConfig. + * Set to force an incoming channel to match our announced channel preference in + * [`ChannelHandshakeConfig::announced_channel`]. + * + * For a node which is not online reliably, this should be set to true and + * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * channels will ever be opened. * - * Default value: true, to make the default that no announced channels are possible (which is - * appropriate for any nodes which are not online very reliably). + * Default value: true. */ public void set_force_announced_channel_preference(boolean val) { bindings.ChannelHandshakeLimits_set_force_announced_channel_preference(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -248,6 +297,7 @@ public class ChannelHandshakeLimits extends CommonBase { */ public short get_their_to_self_delay() { short ret = bindings.ChannelHandshakeLimits_get_their_to_self_delay(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -262,35 +312,57 @@ public class ChannelHandshakeLimits extends CommonBase { */ public void set_their_to_self_delay(short val) { bindings.ChannelHandshakeLimits_set_their_to_self_delay(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** * Constructs a new ChannelHandshakeLimits given each field */ - public static ChannelHandshakeLimits constructor_new(long min_funding_satoshis_arg, long max_htlc_minimum_msat_arg, long min_max_htlc_value_in_flight_msat_arg, long max_channel_reserve_satoshis_arg, short min_max_accepted_htlcs_arg, long min_dust_limit_satoshis_arg, long max_dust_limit_satoshis_arg, int max_minimum_depth_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) { - long ret = bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, min_dust_limit_satoshis_arg, max_dust_limit_satoshis_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg); - ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + public static ChannelHandshakeLimits of(long min_funding_satoshis_arg, long max_funding_satoshis_arg, long max_htlc_minimum_msat_arg, long min_max_htlc_value_in_flight_msat_arg, long max_channel_reserve_satoshis_arg, short min_max_accepted_htlcs_arg, int max_minimum_depth_arg, boolean trust_own_funding_0conf_arg, boolean force_announced_channel_preference_arg, short their_to_self_delay_arg) { + long ret = bindings.ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg); + Reference.reachabilityFence(min_funding_satoshis_arg); + Reference.reachabilityFence(max_funding_satoshis_arg); + Reference.reachabilityFence(max_htlc_minimum_msat_arg); + Reference.reachabilityFence(min_max_htlc_value_in_flight_msat_arg); + Reference.reachabilityFence(max_channel_reserve_satoshis_arg); + Reference.reachabilityFence(min_max_accepted_htlcs_arg); + Reference.reachabilityFence(max_minimum_depth_arg); + Reference.reachabilityFence(trust_own_funding_0conf_arg); + Reference.reachabilityFence(force_announced_channel_preference_arg); + Reference.reachabilityFence(their_to_self_delay_arg); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } + long clone_ptr() { + long ret = bindings.ChannelHandshakeLimits_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + /** * Creates a copy of the ChannelHandshakeLimits */ public ChannelHandshakeLimits clone() { long ret = bindings.ChannelHandshakeLimits_clone(this.ptr); - ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } /** * Creates a "default" ChannelHandshakeLimits. See struct and individual field documentaiton for details on which values are used. */ - public static ChannelHandshakeLimits constructor_default() { + public static ChannelHandshakeLimits with_default() { long ret = bindings.ChannelHandshakeLimits_default(); - ChannelHandshakeLimits ret_hu_conv = new ChannelHandshakeLimits(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelHandshakeLimits ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelHandshakeLimits(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; }