X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelCounterparty.java;h=d355cbf1cb55642668c8a92bb4bff2e53a1a574a;hb=1854b5cebef22ace9e9e4dd191f609818df9ce08;hp=c0bf5dd26261669030cf20108141a2981550499e;hpb=348009c7987109e810e7e31db6110fb71879fbc3;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelCounterparty.java b/src/main/java/org/ldk/structs/ChannelCounterparty.java index c0bf5dd2..d355cbf1 100644 --- a/src/main/java/org/ldk/structs/ChannelCounterparty.java +++ b/src/main/java/org/ldk/structs/ChannelCounterparty.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; /** @@ -24,6 +26,7 @@ public class ChannelCounterparty extends CommonBase { */ public byte[] get_node_id() { byte[] ret = bindings.ChannelCounterparty_get_node_id(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -31,7 +34,9 @@ public class ChannelCounterparty extends CommonBase { * The node_id of our counterparty */ public void set_node_id(byte[] val) { - bindings.ChannelCounterparty_set_node_id(this.ptr, val); + bindings.ChannelCounterparty_set_node_id(this.ptr, InternalUtils.check_arr_len(val, 33)); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -41,7 +46,9 @@ public class ChannelCounterparty extends CommonBase { */ public InitFeatures get_features() { long ret = bindings.ChannelCounterparty_get_features(this.ptr); - InitFeatures ret_hu_conv = new InitFeatures(null, ret); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + InitFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InitFeatures(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -53,7 +60,8 @@ public class ChannelCounterparty extends CommonBase { */ public void set_features(InitFeatures val) { bindings.ChannelCounterparty_set_features(this.ptr, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -67,6 +75,7 @@ public class ChannelCounterparty extends CommonBase { */ public long get_unspendable_punishment_reserve() { long ret = bindings.ChannelCounterparty_get_unspendable_punishment_reserve(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -81,6 +90,57 @@ public class ChannelCounterparty extends CommonBase { */ public void set_unspendable_punishment_reserve(long val) { bindings.ChannelCounterparty_set_unspendable_punishment_reserve(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable + public CounterpartyForwardingInfo get_forwarding_info() { + long ret = bindings.ChannelCounterparty_get_forwarding_info(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + CounterpartyForwardingInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new CounterpartyForwardingInfo(null, ret); } + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public void set_forwarding_info(@Nullable CounterpartyForwardingInfo val) { + bindings.ChannelCounterparty_set_forwarding_info(this.ptr, val == null ? 0 : val.ptr & ~1); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Constructs a new ChannelCounterparty given each field + */ + public static ChannelCounterparty of(byte[] node_id_arg, InitFeatures features_arg, long unspendable_punishment_reserve_arg, CounterpartyForwardingInfo forwarding_info_arg) { + long ret = bindings.ChannelCounterparty_new(InternalUtils.check_arr_len(node_id_arg, 33), features_arg == null ? 0 : features_arg.ptr & ~1, unspendable_punishment_reserve_arg, forwarding_info_arg == null ? 0 : forwarding_info_arg.ptr & ~1); + Reference.reachabilityFence(node_id_arg); + Reference.reachabilityFence(features_arg); + Reference.reachabilityFence(unspendable_punishment_reserve_arg); + Reference.reachabilityFence(forwarding_info_arg); + if (ret >= 0 && ret <= 4096) { return null; } + ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); } + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + long clone_ptr() { + long ret = bindings.ChannelCounterparty_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; } /** @@ -88,7 +148,9 @@ public class ChannelCounterparty extends CommonBase { */ public ChannelCounterparty clone() { long ret = bindings.ChannelCounterparty_clone(this.ptr); - ChannelCounterparty ret_hu_conv = new ChannelCounterparty(null, ret); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + ChannelCounterparty ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ChannelCounterparty(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; }