Update auto-generated bindings to latest upstream
[ldk-java] / src / main / java / org / ldk / structs / ChannelUpdate.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * A channel_update message to be sent or received from a peer
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class ChannelUpdate extends CommonBase {
15         ChannelUpdate(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.ChannelUpdate_free(ptr); }
20         }
21
22         /**
23          * A signature of the channel update
24          */
25         public byte[] get_signature() {
26                 byte[] ret = bindings.ChannelUpdate_get_signature(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * A signature of the channel update
32          */
33         public void set_signature(byte[] val) {
34                 bindings.ChannelUpdate_set_signature(this.ptr, val);
35         }
36
37         /**
38          * The actual channel update
39          */
40         public UnsignedChannelUpdate get_contents() {
41                 long ret = bindings.ChannelUpdate_get_contents(this.ptr);
42                 if (ret < 1024) { return null; }
43                 UnsignedChannelUpdate ret_hu_conv = new UnsignedChannelUpdate(null, ret);
44                 ret_hu_conv.ptrs_to.add(this);
45                 return ret_hu_conv;
46         }
47
48         /**
49          * The actual channel update
50          */
51         public void set_contents(UnsignedChannelUpdate val) {
52                 bindings.ChannelUpdate_set_contents(this.ptr, val == null ? 0 : val.ptr & ~1);
53                 this.ptrs_to.add(val);
54         }
55
56         /**
57          * Constructs a new ChannelUpdate given each field
58          */
59         public static ChannelUpdate of(byte[] signature_arg, UnsignedChannelUpdate contents_arg) {
60                 long ret = bindings.ChannelUpdate_new(signature_arg, contents_arg == null ? 0 : contents_arg.ptr & ~1);
61                 if (ret < 1024) { return null; }
62                 ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret);
63                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
64                 ret_hu_conv.ptrs_to.add(contents_arg);
65                 return ret_hu_conv;
66         }
67
68         /**
69          * Creates a copy of the ChannelUpdate
70          */
71         public ChannelUpdate clone() {
72                 long ret = bindings.ChannelUpdate_clone(this.ptr);
73                 if (ret < 1024) { return null; }
74                 ChannelUpdate ret_hu_conv = new ChannelUpdate(null, ret);
75                 ret_hu_conv.ptrs_to.add(this);
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
81          */
82         public byte[] write() {
83                 byte[] ret = bindings.ChannelUpdate_write(this.ptr);
84                 return ret;
85         }
86
87         /**
88          * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
89          */
90         public static Result_ChannelUpdateDecodeErrorZ read(byte[] ser) {
91                 long ret = bindings.ChannelUpdate_read(ser);
92                 if (ret < 1024) { return null; }
93                 Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
94                 return ret_hu_conv;
95         }
96
97 }