[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelUpdate.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A [`channel_update`] message to be sent to or received from a peer.
11  * 
12  * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message
13  */
14 public class ChannelUpdate : CommonBase {
15         internal ChannelUpdate(object _dummy, long ptr) : base(ptr) { }
16         ~ChannelUpdate() {
17                 if (ptr != 0) { bindings.ChannelUpdate_free(ptr); }
18         }
19
20         /**
21          * A signature of the channel update
22          */
23         public byte[] get_signature() {
24                 byte[] ret = bindings.ChannelUpdate_get_signature(this.ptr);
25                 GC.KeepAlive(this);
26                 return ret;
27         }
28
29         /**
30          * A signature of the channel update
31          */
32         public void set_signature(byte[] val) {
33                 bindings.ChannelUpdate_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * The actual channel update
40          */
41         public UnsignedChannelUpdate get_contents() {
42                 long ret = bindings.ChannelUpdate_get_contents(this.ptr);
43                 GC.KeepAlive(this);
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); };
47                 return ret_hu_conv;
48         }
49
50         /**
51          * The actual channel update
52          */
53         public void set_contents(org.ldk.structs.UnsignedChannelUpdate val) {
54                 bindings.ChannelUpdate_set_contents(this.ptr, val == null ? 0 : val.ptr);
55                 GC.KeepAlive(this);
56                 GC.KeepAlive(val);
57                 if (this != null) { this.ptrs_to.AddLast(val); };
58         }
59
60         /**
61          * Constructs a new ChannelUpdate given each field
62          */
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); };
71                 return ret_hu_conv;
72         }
73
74         internal long clone_ptr() {
75                 long ret = bindings.ChannelUpdate_clone_ptr(this.ptr);
76                 GC.KeepAlive(this);
77                 return ret;
78         }
79
80         /**
81          * Creates a copy of the ChannelUpdate
82          */
83         public ChannelUpdate clone() {
84                 long ret = bindings.ChannelUpdate_clone(this.ptr);
85                 GC.KeepAlive(this);
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); };
89                 return ret_hu_conv;
90         }
91
92         /**
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.
96          */
97         public bool eq(org.ldk.structs.ChannelUpdate b) {
98                 bool ret = bindings.ChannelUpdate_eq(this.ptr, b == null ? 0 : b.ptr);
99                 GC.KeepAlive(this);
100                 GC.KeepAlive(b);
101                 if (this != null) { this.ptrs_to.AddLast(b); };
102                 return ret;
103         }
104
105         public override bool Equals(object o) {
106                 if (!(o is ChannelUpdate)) return false;
107                 return this.eq((ChannelUpdate)o);
108         }
109         /**
110          * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read
111          */
112         public byte[] write() {
113                 byte[] ret = bindings.ChannelUpdate_write(this.ptr);
114                 GC.KeepAlive(this);
115                 return ret;
116         }
117
118         /**
119          * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write
120          */
121         public static Result_ChannelUpdateDecodeErrorZ read(byte[] ser) {
122                 long ret = bindings.ChannelUpdate_read(ser);
123                 GC.KeepAlive(ser);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 Result_ChannelUpdateDecodeErrorZ ret_hu_conv = Result_ChannelUpdateDecodeErrorZ.constr_from_ptr(ret);
126                 return ret_hu_conv;
127         }
128
129 }
130 } } }