[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / OpenChannel.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  * An [`open_channel`] message to be sent to or received from a peer.
11  * 
12  * Used in V1 channel establishment
13  * 
14  * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message
15  */
16 public class OpenChannel : CommonBase {
17         internal OpenChannel(object _dummy, long ptr) : base(ptr) { }
18         ~OpenChannel() {
19                 if (ptr != 0) { bindings.OpenChannel_free(ptr); }
20         }
21
22         /**
23          * Common fields of `open_channel(2)`-like messages
24          */
25         public CommonOpenChannelFields get_common_fields() {
26                 long ret = bindings.OpenChannel_get_common_fields(this.ptr);
27                 GC.KeepAlive(this);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 org.ldk.structs.CommonOpenChannelFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommonOpenChannelFields(null, ret); }
30                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
31                 return ret_hu_conv;
32         }
33
34         /**
35          * Common fields of `open_channel(2)`-like messages
36          */
37         public void set_common_fields(org.ldk.structs.CommonOpenChannelFields val) {
38                 bindings.OpenChannel_set_common_fields(this.ptr, val.ptr);
39                 GC.KeepAlive(this);
40                 GC.KeepAlive(val);
41                 if (this != null) { this.ptrs_to.AddLast(val); };
42         }
43
44         /**
45          * The amount to push to the counterparty as part of the open, in milli-satoshi
46          */
47         public long get_push_msat() {
48                 long ret = bindings.OpenChannel_get_push_msat(this.ptr);
49                 GC.KeepAlive(this);
50                 return ret;
51         }
52
53         /**
54          * The amount to push to the counterparty as part of the open, in milli-satoshi
55          */
56         public void set_push_msat(long val) {
57                 bindings.OpenChannel_set_push_msat(this.ptr, val);
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
64          */
65         public long get_channel_reserve_satoshis() {
66                 long ret = bindings.OpenChannel_get_channel_reserve_satoshis(this.ptr);
67                 GC.KeepAlive(this);
68                 return ret;
69         }
70
71         /**
72          * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel
73          */
74         public void set_channel_reserve_satoshis(long val) {
75                 bindings.OpenChannel_set_channel_reserve_satoshis(this.ptr, val);
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * Constructs a new OpenChannel given each field
82          */
83         public static OpenChannel of(org.ldk.structs.CommonOpenChannelFields common_fields_arg, long push_msat_arg, long channel_reserve_satoshis_arg) {
84                 long ret = bindings.OpenChannel_new(common_fields_arg.ptr, push_msat_arg, channel_reserve_satoshis_arg);
85                 GC.KeepAlive(common_fields_arg);
86                 GC.KeepAlive(push_msat_arg);
87                 GC.KeepAlive(channel_reserve_satoshis_arg);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(common_fields_arg); };
92                 return ret_hu_conv;
93         }
94
95         internal long clone_ptr() {
96                 long ret = bindings.OpenChannel_clone_ptr(this.ptr);
97                 GC.KeepAlive(this);
98                 return ret;
99         }
100
101         /**
102          * Creates a copy of the OpenChannel
103          */
104         public OpenChannel clone() {
105                 long ret = bindings.OpenChannel_clone(this.ptr);
106                 GC.KeepAlive(this);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.OpenChannel ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OpenChannel(null, ret); }
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Generates a non-cryptographic 64-bit hash of the OpenChannel.
115          */
116         public long hash() {
117                 long ret = bindings.OpenChannel_hash(this.ptr);
118                 GC.KeepAlive(this);
119                 return ret;
120         }
121
122         public override int GetHashCode() {
123                 return (int)this.hash();
124         }
125         /**
126          * Checks if two OpenChannels contain equal inner contents.
127          * This ignores pointers and is_owned flags and looks at the values in fields.
128          * Two objects with NULL inner values will be considered "equal" here.
129          */
130         public bool eq(org.ldk.structs.OpenChannel b) {
131                 bool ret = bindings.OpenChannel_eq(this.ptr, b.ptr);
132                 GC.KeepAlive(this);
133                 GC.KeepAlive(b);
134                 if (this != null) { this.ptrs_to.AddLast(b); };
135                 return ret;
136         }
137
138         public override bool Equals(object o) {
139                 if (!(o is OpenChannel)) return false;
140                 return this.eq((OpenChannel)o);
141         }
142         /**
143          * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read
144          */
145         public byte[] write() {
146                 long ret = bindings.OpenChannel_write(this.ptr);
147                 GC.KeepAlive(this);
148                 if (ret >= 0 && ret <= 4096) { return null; }
149                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
150                 return ret_conv;
151         }
152
153         /**
154          * Read a OpenChannel from a byte array, created by OpenChannel_write
155          */
156         public static Result_OpenChannelDecodeErrorZ read(byte[] ser) {
157                 long ret = bindings.OpenChannel_read(InternalUtils.encodeUint8Array(ser));
158                 GC.KeepAlive(ser);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 Result_OpenChannelDecodeErrorZ ret_hu_conv = Result_OpenChannelDecodeErrorZ.constr_from_ptr(ret);
161                 return ret_hu_conv;
162         }
163
164 }
165 } } }