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