using org.ldk.impl; using org.ldk.enums; using org.ldk.util; using System; namespace org { namespace ldk { namespace structs { /** * Details about a channel (both directions). * Received within a channel announcement. */ public class ChannelInfo : CommonBase { internal ChannelInfo(object _dummy, long ptr) : base(ptr) { } ~ChannelInfo() { if (ptr != 0) { bindings.ChannelInfo_free(ptr); } } /** * Protocol features of a channel communicated during its announcement */ public ChannelFeatures get_features() { long ret = bindings.ChannelInfo_get_features(this.ptr); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * Protocol features of a channel communicated during its announcement */ public void set_features(org.ldk.structs.ChannelFeatures val) { bindings.ChannelInfo_set_features(this.ptr, val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } /** * Source node of the first direction of a channel */ public NodeId get_node_one() { long ret = bindings.ChannelInfo_get_node_one(this.ptr); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * Source node of the first direction of a channel */ public void set_node_one(org.ldk.structs.NodeId val) { bindings.ChannelInfo_set_node_one(this.ptr, val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } /** * Details about the first direction of a channel * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ public ChannelUpdateInfo get_one_to_two() { long ret = bindings.ChannelInfo_get_one_to_two(this.ptr); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * Details about the first direction of a channel * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ public void set_one_to_two(org.ldk.structs.ChannelUpdateInfo val) { bindings.ChannelInfo_set_one_to_two(this.ptr, val == null ? 0 : val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } /** * Source node of the second direction of a channel */ public NodeId get_node_two() { long ret = bindings.ChannelInfo_get_node_two(this.ptr); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * Source node of the second direction of a channel */ public void set_node_two(org.ldk.structs.NodeId val) { bindings.ChannelInfo_set_node_two(this.ptr, val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } /** * Details about the second direction of a channel * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ public ChannelUpdateInfo get_two_to_one() { long ret = bindings.ChannelInfo_get_two_to_one(this.ptr); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * Details about the second direction of a channel * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ public void set_two_to_one(org.ldk.structs.ChannelUpdateInfo val) { bindings.ChannelInfo_set_two_to_one(this.ptr, val == null ? 0 : val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } /** * 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); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * The channel capacity as seen on-chain, if chain lookup is available. */ public void set_capacity_sats(org.ldk.structs.Option_u64Z val) { bindings.ChannelInfo_set_capacity_sats(this.ptr, val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } /** * 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. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ public ChannelAnnouncement get_announcement_message() { long ret = bindings.ChannelInfo_get_announcement_message(this.ptr); GC.KeepAlive(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.AddLast(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. * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ public void set_announcement_message(org.ldk.structs.ChannelAnnouncement val) { bindings.ChannelInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr); GC.KeepAlive(this); GC.KeepAlive(val); if (this != null) { this.ptrs_to.AddLast(val); }; } internal long clone_ptr() { long ret = bindings.ChannelInfo_clone_ptr(this.ptr); GC.KeepAlive(this); return ret; } /** * Creates a copy of the ChannelInfo */ public ChannelInfo clone() { long ret = bindings.ChannelInfo_clone(this.ptr); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * Checks if two ChannelInfos contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ public bool eq(org.ldk.structs.ChannelInfo b) { bool ret = bindings.ChannelInfo_eq(this.ptr, b.ptr); GC.KeepAlive(this); GC.KeepAlive(b); if (this != null) { this.ptrs_to.AddLast(b); }; return ret; } public override bool Equals(object o) { if (!(o is ChannelInfo)) return false; return this.eq((ChannelInfo)o); } /** * 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 */ public ChannelUpdateInfo get_directional_info(byte channel_flags) { long ret = bindings.ChannelInfo_get_directional_info(this.ptr, channel_flags); GC.KeepAlive(this); GC.KeepAlive(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.AddLast(this); }; return ret_hu_conv; } /** * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read */ public byte[] write() { long ret = bindings.ChannelInfo_write(this.ptr); GC.KeepAlive(this); if (ret >= 0 && ret <= 4096) { return null; } byte[] ret_conv = InternalUtils.decodeUint8Array(ret); return ret_conv; } /** * Read a ChannelInfo from a byte array, created by ChannelInfo_write */ public static Result_ChannelInfoDecodeErrorZ read(byte[] ser) { long ret = bindings.ChannelInfo_read(InternalUtils.encodeUint8Array(ser)); GC.KeepAlive(ser); if (ret >= 0 && ret <= 4096) { return null; } Result_ChannelInfoDecodeErrorZ ret_hu_conv = Result_ChannelInfoDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } } } } }