X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelInfo.java;h=db9f3589bac668671062d87ce8f165f48b7d6f05;hb=f385eff0dd0aa61fbf21ae946c424f4a6a26de04;hp=c105359680ea2a8cbc9616dd444934c611998e08;hpb=e6173a79ce766cef7a660f22fc8fd1220975f6ea;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelInfo.java b/src/main/java/org/ldk/structs/ChannelInfo.java index c1053596..db9f3589 100644 --- a/src/main/java/org/ldk/structs/ChannelInfo.java +++ b/src/main/java/org/ldk/structs/ChannelInfo.java @@ -4,6 +4,7 @@ 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; @@ -25,9 +26,10 @@ public class ChannelInfo extends CommonBase { */ public ChannelFeatures get_features() { long ret = bindings.ChannelInfo_get_features(this.ptr); - if (ret >= 0 && ret < 1024) { return null; } - ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelFeatures(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -35,22 +37,32 @@ public class ChannelInfo extends CommonBase { * Protocol features of a channel communicated during its announcement */ public void set_features(ChannelFeatures val) { - bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1); + bindings.ChannelInfo_set_features(this.ptr, val == null ? 0 : val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** * Source node of the first direction of a channel */ - public byte[] get_node_one() { - byte[] ret = bindings.ChannelInfo_get_node_one(this.ptr); - return ret; + public NodeId get_node_one() { + long ret = bindings.ChannelInfo_get_node_one(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** * Source node of the first direction of a channel */ - public void set_node_one(byte[] val) { - bindings.ChannelInfo_set_node_one(this.ptr, val); + public void set_node_one(NodeId val) { + bindings.ChannelInfo_set_node_one(this.ptr, val == null ? 0 : val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -59,11 +71,12 @@ public class ChannelInfo extends CommonBase { * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ @Nullable - public DirectionalChannelInfo get_one_to_two() { + public ChannelUpdateInfo get_one_to_two() { long ret = bindings.ChannelInfo_get_one_to_two(this.ptr); - if (ret >= 0 && ret < 1024) { return null; } - DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -72,23 +85,33 @@ public class ChannelInfo extends CommonBase { * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public void set_one_to_two(@Nullable DirectionalChannelInfo val) { - bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr & ~1); + public void set_one_to_two(@Nullable ChannelUpdateInfo val) { + bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** * Source node of the second direction of a channel */ - public byte[] get_node_two() { - byte[] ret = bindings.ChannelInfo_get_node_two(this.ptr); - return ret; + public NodeId get_node_two() { + long ret = bindings.ChannelInfo_get_node_two(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } /** * Source node of the second direction of a channel */ - public void set_node_two(byte[] val) { - bindings.ChannelInfo_set_node_two(this.ptr, val); + public void set_node_two(NodeId val) { + bindings.ChannelInfo_set_node_two(this.ptr, val == null ? 0 : val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -97,11 +120,12 @@ public class ChannelInfo extends CommonBase { * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ @Nullable - public DirectionalChannelInfo get_two_to_one() { + public ChannelUpdateInfo get_two_to_one() { long ret = bindings.ChannelInfo_get_two_to_one(this.ptr); - if (ret >= 0 && ret < 1024) { return null; } - DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -110,8 +134,11 @@ public class ChannelInfo extends CommonBase { * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public void set_two_to_one(@Nullable DirectionalChannelInfo val) { - bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr & ~1); + public void set_two_to_one(@Nullable ChannelUpdateInfo val) { + bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } /** @@ -119,9 +146,10 @@ public class ChannelInfo extends CommonBase { */ public Option_u64Z get_capacity_sats() { long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr); - if (ret >= 0 && ret < 1024) { return null; } - Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -130,6 +158,8 @@ public class ChannelInfo extends CommonBase { */ public void set_capacity_sats(Option_u64Z val) { bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } /** @@ -143,9 +173,10 @@ public class ChannelInfo extends CommonBase { @Nullable public ChannelAnnouncement get_announcement_message() { long ret = bindings.ChannelInfo_get_announcement_message(this.ptr); - if (ret >= 0 && ret < 1024) { return null; } - ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelAnnouncement ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelAnnouncement(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -158,18 +189,16 @@ public class ChannelInfo extends CommonBase { * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ public void set_announcement_message(@Nullable ChannelAnnouncement val) { - bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1); + bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + if (this != null) { this.ptrs_to.add(val); }; } - /** - * Constructs a new ChannelInfo given each field - */ - public static ChannelInfo of(ChannelFeatures features_arg, byte[] node_one_arg, DirectionalChannelInfo one_to_two_arg, byte[] node_two_arg, DirectionalChannelInfo two_to_one_arg, Option_u64Z capacity_sats_arg, ChannelAnnouncement announcement_message_arg) { - long ret = bindings.ChannelInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, node_one_arg, one_to_two_arg == null ? 0 : one_to_two_arg.ptr & ~1, node_two_arg, two_to_one_arg == null ? 0 : two_to_one_arg.ptr & ~1, capacity_sats_arg.ptr, announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1); - if (ret >= 0 && ret < 1024) { return null; } - ChannelInfo ret_hu_conv = new ChannelInfo(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - return ret_hu_conv; + long clone_ptr() { + long ret = bindings.ChannelInfo_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; } /** @@ -177,9 +206,26 @@ public class ChannelInfo extends CommonBase { */ public ChannelInfo clone() { long ret = bindings.ChannelInfo_clone(this.ptr); - if (ret >= 0 && ret < 1024) { return null; } - ChannelInfo ret_hu_conv = new ChannelInfo(null, ret); - ret_hu_conv.ptrs_to.add(this); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelInfo(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; + } + + /** + * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable + public ChannelUpdateInfo get_directional_info(byte channel_flags) { + long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags); + Reference.reachabilityFence(this); + Reference.reachabilityFence(channel_flags); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelUpdateInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdateInfo(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -188,6 +234,7 @@ public class ChannelInfo extends CommonBase { */ public byte[] write() { byte[] ret = bindings.ChannelInfo_write(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -196,7 +243,8 @@ public class ChannelInfo extends CommonBase { */ public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) { long ret = bindings.ChannelInfo_read(ser); - if (ret >= 0 && ret < 1024) { return null; } + Reference.reachabilityFence(ser); + if (ret >= 0 && ret <= 4096) { return null; } Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; }