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 long ret = bindings.ChannelUpdate_get_signature(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
32 * A signature of the channel update
34 public void set_signature(byte[] val) {
35 bindings.ChannelUpdate_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
41 * The actual channel update
43 public UnsignedChannelUpdate get_contents() {
44 long ret = bindings.ChannelUpdate_get_contents(this.ptr);
46 if (ret >= 0 && ret <= 4096) { return null; }
47 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
48 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53 * The actual channel update
55 public void set_contents(org.ldk.structs.UnsignedChannelUpdate val) {
56 bindings.ChannelUpdate_set_contents(this.ptr, val.ptr);
59 if (this != null) { this.ptrs_to.AddLast(val); };
63 * Constructs a new ChannelUpdate given each field
65 public static ChannelUpdate of(byte[] signature_arg, org.ldk.structs.UnsignedChannelUpdate contents_arg) {
66 long ret = bindings.ChannelUpdate_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)), contents_arg.ptr);
67 GC.KeepAlive(signature_arg);
68 GC.KeepAlive(contents_arg);
69 if (ret >= 0 && ret <= 4096) { return null; }
70 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
71 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(contents_arg); };
76 internal long clone_ptr() {
77 long ret = bindings.ChannelUpdate_clone_ptr(this.ptr);
83 * Creates a copy of the ChannelUpdate
85 public ChannelUpdate clone() {
86 long ret = bindings.ChannelUpdate_clone(this.ptr);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
95 * Generates a non-cryptographic 64-bit hash of the ChannelUpdate.
98 long ret = bindings.ChannelUpdate_hash(this.ptr);
103 public override int GetHashCode() {
104 return (int)this.hash();
107 * Checks if two ChannelUpdates contain equal inner contents.
108 * This ignores pointers and is_owned flags and looks at the values in fields.
109 * Two objects with NULL inner values will be considered "equal" here.
111 public bool eq(org.ldk.structs.ChannelUpdate b) {
112 bool ret = bindings.ChannelUpdate_eq(this.ptr, b.ptr);
115 if (this != null) { this.ptrs_to.AddLast(b); };
119 public override bool Equals(object o) {
120 if (!(o is ChannelUpdate)) return false;
121 return this.eq((ChannelUpdate)o);
124 * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
126 public byte[] write() {
127 long ret = bindings.ChannelUpdate_write(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
135 * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
137 public static Result_ChannelUpdateDecodeErrorZ read(byte[] ser) {
138 long ret = bindings.ChannelUpdate_read(InternalUtils.encodeUint8Array(ser));
140 if (ret >= 0 && ret <= 4096) { return null; }
141 Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);