6 namespace org { namespace ldk { namespace structs {
10 * A [`channel_update`] message to be sent to or received from a peer.
12 * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
14 public class ChannelUpdate : CommonBase {
15 internal ChannelUpdate(object _dummy, long ptr) : base(ptr) { }
17 if (ptr != 0) { bindings.ChannelUpdate_free(ptr); }
21 * A signature of the channel update
23 public byte[] get_signature() {
24 byte[] ret = bindings.ChannelUpdate_get_signature(this.ptr);
30 * A signature of the channel update
32 public void set_signature(byte[] val) {
33 bindings.ChannelUpdate_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
39 * The actual channel update
41 public UnsignedChannelUpdate get_contents() {
42 long ret = bindings.ChannelUpdate_get_contents(this.ptr);
44 if (ret >= 0 && ret <= 4096) { return null; }
45 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
46 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
51 * The actual channel update
53 public void set_contents(org.ldk.structs.UnsignedChannelUpdate val) {
54 bindings.ChannelUpdate_set_contents(this.ptr, val == null ? 0 : val.ptr);
57 if (this != null) { this.ptrs_to.AddLast(val); };
61 * Constructs a new ChannelUpdate given each field
63 public static ChannelUpdate of(byte[] signature_arg, org.ldk.structs.UnsignedChannelUpdate contents_arg) {
64 long ret = bindings.ChannelUpdate_new(InternalUtils.check_arr_len(signature_arg, 64), contents_arg == null ? 0 : contents_arg.ptr);
65 GC.KeepAlive(signature_arg);
66 GC.KeepAlive(contents_arg);
67 if (ret >= 0 && ret <= 4096) { return null; }
68 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
69 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents_arg); };
74 internal long clone_ptr() {
75 long ret = bindings.ChannelUpdate_clone_ptr(this.ptr);
81 * Creates a copy of the ChannelUpdate
83 public ChannelUpdate clone() {
84 long ret = bindings.ChannelUpdate_clone(this.ptr);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
88 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
93 * Checks if two ChannelUpdates contain equal inner contents.
94 * This ignores pointers and is_owned flags and looks at the values in fields.
95 * Two objects with NULL inner values will be considered "equal" here.
97 public bool eq(org.ldk.structs.ChannelUpdate b) {
98 bool ret = bindings.ChannelUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
101 if (this != null) { this.ptrs_to.AddLast(b); };
105 public override bool Equals(object o) {
106 if (!(o is ChannelUpdate)) return false;
107 return this.eq((ChannelUpdate)o);
110 * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
112 public byte[] write() {
113 byte[] ret = bindings.ChannelUpdate_write(this.ptr);
119 * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
121 public static Result_ChannelUpdateDecodeErrorZ read(byte[] ser) {
122 long ret = bindings.ChannelUpdate_read(ser);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);