X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChannelInfo.java;h=dc995e791035cc919e7207e7c9f67442983ad1a2;hb=c3ae2d6897e5a809459c8d9a72a4b3aa0052c8c8;hp=b0de8cbede3f1c43d5372b065f58777e294dde28;hpb=de28908caacda7226bac70837a33cfe6e16417ab;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChannelInfo.java b/src/main/java/org/ldk/structs/ChannelInfo.java index b0de8cbe..dc995e79 100644 --- a/src/main/java/org/ldk/structs/ChannelInfo.java +++ b/src/main/java/org/ldk/structs/ChannelInfo.java @@ -2,72 +2,187 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; + +/** + * Details about a channel (both directions). + * Received within a channel announcement. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ChannelInfo extends CommonBase { ChannelInfo(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { - bindings.ChannelInfo_free(ptr); super.finalize(); + super.finalize(); + if (ptr != 0) { bindings.ChannelInfo_free(ptr); } } - public ChannelFeatures get_features(ChannelInfo this_ptr) { - ChannelFeatures ret = new ChannelFeatures(null, bindings.ChannelInfo_get_features(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + /** + * Protocol features of a channel communicated during its announcement + */ + public ChannelFeatures get_features() { + long ret = bindings.ChannelInfo_get_features(this.ptr); + ChannelFeatures ret_hu_conv = new ChannelFeatures(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - // Skipped ChannelInfo_set_features - public byte[] get_node_one(ChannelInfo this_ptr) { - byte[] ret = bindings.ChannelInfo_get_node_one(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * 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); + 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 void set_node_one(ChannelInfo this_ptr, byte[] val) { - bindings.ChannelInfo_set_node_one(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * 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 DirectionalChannelInfo get_one_to_two(ChannelInfo this_ptr) { - DirectionalChannelInfo ret = new DirectionalChannelInfo(null, bindings.ChannelInfo_get_one_to_two(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + /** + * Details about the first direction of a channel + */ + public DirectionalChannelInfo get_one_to_two() { + long ret = bindings.ChannelInfo_get_one_to_two(this.ptr); + DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - // Skipped ChannelInfo_set_one_to_two - public byte[] get_node_two(ChannelInfo this_ptr) { - byte[] ret = bindings.ChannelInfo_get_node_two(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * Details about the first direction of a channel + */ + public void set_one_to_two(DirectionalChannelInfo val) { + bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr & ~1); + 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 void set_node_two(ChannelInfo this_ptr, byte[] val) { - bindings.ChannelInfo_set_node_two(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * 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 DirectionalChannelInfo get_two_to_one(ChannelInfo this_ptr) { - DirectionalChannelInfo ret = new DirectionalChannelInfo(null, bindings.ChannelInfo_get_two_to_one(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + /** + * Details about the second direction of a channel + */ + public DirectionalChannelInfo get_two_to_one() { + long ret = bindings.ChannelInfo_get_two_to_one(this.ptr); + DirectionalChannelInfo ret_hu_conv = new DirectionalChannelInfo(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; } - // Skipped ChannelInfo_set_two_to_one - public ChannelAnnouncement get_announcement_message(ChannelInfo this_ptr) { - ChannelAnnouncement ret = new ChannelAnnouncement(null, bindings.ChannelInfo_get_announcement_message(this_ptr == null ? 0 : this_ptr.ptr & ~1)); - this.ptrs_to.add(this_ptr); - return ret; + /** + * Details about the second direction of a channel + */ + public void set_two_to_one(DirectionalChannelInfo val) { + bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr & ~1); + this.ptrs_to.add(val); } - public void set_announcement_message(ChannelInfo this_ptr, ChannelAnnouncement val) { - bindings.ChannelInfo_set_announcement_message(this_ptr == null ? 0 : this_ptr.ptr & ~1, val == null ? 0 : val.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The channel capacity as seen on-chain, if chain lookup is available. + */ + public Option_u64Z get_capacity_sats() { + long ret = bindings.ChannelInfo_get_capacity_sats(this.ptr); + Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * The channel capacity as seen on-chain, if chain lookup is available. + */ + public void set_capacity_sats(Option_u64Z val) { + bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr); + } + + /** + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + */ + public ChannelAnnouncement get_announcement_message() { + long ret = bindings.ChannelInfo_get_announcement_message(this.ptr); + ChannelAnnouncement ret_hu_conv = new ChannelAnnouncement(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + */ + public void set_announcement_message(ChannelAnnouncement val) { + bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1); this.ptrs_to.add(val); } - // Skipped ChannelInfo_write - public ChannelInfo(byte[] ser) { - super(bindings.ChannelInfo_read(ser)); + /** + * Constructs a new ChannelInfo given each field + */ + public static ChannelInfo constructor_new(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); + ChannelInfo ret_hu_conv = new ChannelInfo(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + ret_hu_conv.ptrs_to.add(features_arg); + ret_hu_conv.ptrs_to.add(one_to_two_arg); + ret_hu_conv.ptrs_to.add(two_to_one_arg); + ret_hu_conv.ptrs_to.add(announcement_message_arg); + return ret_hu_conv; + } + + /** + * Creates a copy of the ChannelInfo + */ + public ChannelInfo clone() { + long ret = bindings.ChannelInfo_clone(this.ptr); + ChannelInfo ret_hu_conv = new ChannelInfo(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + */ + public byte[] write() { + byte[] ret = bindings.ChannelInfo_write(this.ptr); + return ret; + } + + /** + * Read a ChannelInfo from a byte array, created by ChannelInfo_write + */ + public static Result_ChannelInfoDecodeErrorZ constructor_read(byte[] ser) { + long ret = bindings.ChannelInfo_read(ser); + Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; } }