1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A channel_update message to be sent or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelUpdate extends CommonBase {
16 ChannelUpdate(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ChannelUpdate_free(ptr); }
24 * A signature of the channel update
26 public byte[] get_signature() {
27 byte[] ret = bindings.ChannelUpdate_get_signature(this.ptr);
28 Reference.reachabilityFence(this);
33 * A signature of the channel update
35 public void set_signature(byte[] val) {
36 bindings.ChannelUpdate_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The actual channel update
44 public UnsignedChannelUpdate get_contents() {
45 long ret = bindings.ChannelUpdate_get_contents(this.ptr);
46 Reference.reachabilityFence(this);
47 if (ret >= 0 && ret <= 4096) { return null; }
48 org.ldk.structs.UnsignedChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UnsignedChannelUpdate(null, ret); }
49 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
54 * The actual channel update
56 public void set_contents(UnsignedChannelUpdate val) {
57 bindings.ChannelUpdate_set_contents(this.ptr, val == null ? 0 : val.ptr);
58 Reference.reachabilityFence(this);
59 Reference.reachabilityFence(val);
60 if (this != null) { this.ptrs_to.add(val); };
64 * Constructs a new ChannelUpdate given each field
66 public static ChannelUpdate of(byte[] signature_arg, UnsignedChannelUpdate contents_arg) {
67 long ret = bindings.ChannelUpdate_new(InternalUtils.check_arr_len(signature_arg, 64), contents_arg == null ? 0 : contents_arg.ptr);
68 Reference.reachabilityFence(signature_arg);
69 Reference.reachabilityFence(contents_arg);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
73 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(contents_arg); };
78 long ret = bindings.ChannelUpdate_clone_ptr(this.ptr);
79 Reference.reachabilityFence(this);
84 * Creates a copy of the ChannelUpdate
86 public ChannelUpdate clone() {
87 long ret = bindings.ChannelUpdate_clone(this.ptr);
88 Reference.reachabilityFence(this);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.ChannelUpdate ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelUpdate(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96 * Checks if two ChannelUpdates contain equal inner contents.
97 * This ignores pointers and is_owned flags and looks at the values in fields.
98 * Two objects with NULL inner values will be considered "equal" here.
100 public boolean eq(ChannelUpdate b) {
101 boolean ret = bindings.ChannelUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
102 Reference.reachabilityFence(this);
103 Reference.reachabilityFence(b);
104 if (this != null) { this.ptrs_to.add(b); };
108 @Override public boolean equals(Object o) {
109 if (!(o instanceof ChannelUpdate)) return false;
110 return this.eq((ChannelUpdate)o);
113 * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
115 public byte[] write() {
116 byte[] ret = bindings.ChannelUpdate_write(this.ptr);
117 Reference.reachabilityFence(this);
122 * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
124 public static Result_ChannelUpdateDecodeErrorZ read(byte[] ser) {
125 long ret = bindings.ChannelUpdate_read(ser);
126 Reference.reachabilityFence(ser);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);