[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelReady.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_ready`] message to be sent to or received from a peer.
11  * 
12  * [`channel_ready`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message
13  */
14 public class ChannelReady : CommonBase {
15         internal ChannelReady(object _dummy, long ptr) : base(ptr) { }
16         ~ChannelReady() {
17                 if (ptr != 0) { bindings.ChannelReady_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public ChannelId get_channel_id() {
24                 long ret = bindings.ChannelReady_get_channel_id(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The channel ID
34          */
35         public void set_channel_id(org.ldk.structs.ChannelId val) {
36                 bindings.ChannelReady_set_channel_id(this.ptr, val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * The per-commitment point of the second commitment transaction
44          */
45         public byte[] get_next_per_commitment_point() {
46                 long ret = bindings.ChannelReady_get_next_per_commitment_point(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
50                 return ret_conv;
51         }
52
53         /**
54          * The per-commitment point of the second commitment transaction
55          */
56         public void set_next_per_commitment_point(byte[] val) {
57                 bindings.ChannelReady_set_next_per_commitment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * If set, provides a `short_channel_id` alias for this channel.
64          * 
65          * The sender will accept payments to be forwarded over this SCID and forward them to this
66          * messages' recipient.
67          */
68         public Option_u64Z get_short_channel_id_alias() {
69                 long ret = bindings.ChannelReady_get_short_channel_id_alias(this.ptr);
70                 GC.KeepAlive(this);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
74                 return ret_hu_conv;
75         }
76
77         /**
78          * If set, provides a `short_channel_id` alias for this channel.
79          * 
80          * The sender will accept payments to be forwarded over this SCID and forward them to this
81          * messages' recipient.
82          */
83         public void set_short_channel_id_alias(org.ldk.structs.Option_u64Z val) {
84                 bindings.ChannelReady_set_short_channel_id_alias(this.ptr, val.ptr);
85                 GC.KeepAlive(this);
86                 GC.KeepAlive(val);
87                 if (this != null) { this.ptrs_to.AddLast(val); };
88         }
89
90         /**
91          * Constructs a new ChannelReady given each field
92          */
93         public static ChannelReady of(org.ldk.structs.ChannelId channel_id_arg, byte[] next_per_commitment_point_arg, org.ldk.structs.Option_u64Z short_channel_id_alias_arg) {
94                 long ret = bindings.ChannelReady_new(channel_id_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(next_per_commitment_point_arg, 33)), short_channel_id_alias_arg.ptr);
95                 GC.KeepAlive(channel_id_arg);
96                 GC.KeepAlive(next_per_commitment_point_arg);
97                 GC.KeepAlive(short_channel_id_alias_arg);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.ChannelReady ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReady(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
101                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(short_channel_id_alias_arg); };
103                 return ret_hu_conv;
104         }
105
106         internal long clone_ptr() {
107                 long ret = bindings.ChannelReady_clone_ptr(this.ptr);
108                 GC.KeepAlive(this);
109                 return ret;
110         }
111
112         /**
113          * Creates a copy of the ChannelReady
114          */
115         public ChannelReady clone() {
116                 long ret = bindings.ChannelReady_clone(this.ptr);
117                 GC.KeepAlive(this);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 org.ldk.structs.ChannelReady ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelReady(null, ret); }
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Generates a non-cryptographic 64-bit hash of the ChannelReady.
126          */
127         public long hash() {
128                 long ret = bindings.ChannelReady_hash(this.ptr);
129                 GC.KeepAlive(this);
130                 return ret;
131         }
132
133         public override int GetHashCode() {
134                 return (int)this.hash();
135         }
136         /**
137          * Checks if two ChannelReadys contain equal inner contents.
138          * This ignores pointers and is_owned flags and looks at the values in fields.
139          * Two objects with NULL inner values will be considered "equal" here.
140          */
141         public bool eq(org.ldk.structs.ChannelReady b) {
142                 bool ret = bindings.ChannelReady_eq(this.ptr, b.ptr);
143                 GC.KeepAlive(this);
144                 GC.KeepAlive(b);
145                 if (this != null) { this.ptrs_to.AddLast(b); };
146                 return ret;
147         }
148
149         public override bool Equals(object o) {
150                 if (!(o is ChannelReady)) return false;
151                 return this.eq((ChannelReady)o);
152         }
153         /**
154          * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read
155          */
156         public byte[] write() {
157                 long ret = bindings.ChannelReady_write(this.ptr);
158                 GC.KeepAlive(this);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
161                 return ret_conv;
162         }
163
164         /**
165          * Read a ChannelReady from a byte array, created by ChannelReady_write
166          */
167         public static Result_ChannelReadyDecodeErrorZ read(byte[] ser) {
168                 long ret = bindings.ChannelReady_read(InternalUtils.encodeUint8Array(ser));
169                 GC.KeepAlive(ser);
170                 if (ret >= 0 && ret <= 4096) { return null; }
171                 Result_ChannelReadyDecodeErrorZ ret_hu_conv = Result_ChannelReadyDecodeErrorZ.constr_from_ptr(ret);
172                 return ret_hu_conv;
173         }
174
175 }
176 } } }