[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / ClosingSigned.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 [`closing_signed`] message to be sent to or received from a peer.
11  * 
12  * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
13  */
14 public class ClosingSigned : CommonBase {
15         internal ClosingSigned(object _dummy, long ptr) : base(ptr) { }
16         ~ClosingSigned() {
17                 if (ptr != 0) { bindings.ClosingSigned_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public ChannelId get_channel_id() {
24                 long ret = bindings.ClosingSigned_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.ClosingSigned_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 proposed total fee for the closing transaction
44          */
45         public long get_fee_satoshis() {
46                 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
47                 GC.KeepAlive(this);
48                 return ret;
49         }
50
51         /**
52          * The proposed total fee for the closing transaction
53          */
54         public void set_fee_satoshis(long val) {
55                 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * A signature on the closing transaction
62          */
63         public byte[] get_signature() {
64                 long ret = bindings.ClosingSigned_get_signature(this.ptr);
65                 GC.KeepAlive(this);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
68                 return ret_conv;
69         }
70
71         /**
72          * A signature on the closing transaction
73          */
74         public void set_signature(byte[] val) {
75                 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
76                 GC.KeepAlive(this);
77                 GC.KeepAlive(val);
78         }
79
80         /**
81          * The minimum and maximum fees which the sender is willing to accept, provided only by new
82          * nodes.
83          * 
84          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
85          */
86         public ClosingSignedFeeRange get_fee_range() {
87                 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSignedFeeRange(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * The minimum and maximum fees which the sender is willing to accept, provided only by new
97          * nodes.
98          * 
99          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
100          */
101         public void set_fee_range(org.ldk.structs.ClosingSignedFeeRange val) {
102                 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr);
103                 GC.KeepAlive(this);
104                 GC.KeepAlive(val);
105                 if (this != null) { this.ptrs_to.AddLast(val); };
106         }
107
108         /**
109          * Constructs a new ClosingSigned given each field
110          * 
111          * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
112          */
113         public static ClosingSigned of(org.ldk.structs.ChannelId channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, org.ldk.structs.ClosingSignedFeeRange fee_range_arg) {
114                 long ret = bindings.ClosingSigned_new(channel_id_arg.ptr, fee_satoshis_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(signature_arg, 64)), fee_range_arg == null ? 0 : fee_range_arg.ptr);
115                 GC.KeepAlive(channel_id_arg);
116                 GC.KeepAlive(fee_satoshis_arg);
117                 GC.KeepAlive(signature_arg);
118                 GC.KeepAlive(fee_range_arg);
119                 if (ret >= 0 && ret <= 4096) { return null; }
120                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
121                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(fee_range_arg); };
124                 return ret_hu_conv;
125         }
126
127         internal long clone_ptr() {
128                 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
129                 GC.KeepAlive(this);
130                 return ret;
131         }
132
133         /**
134          * Creates a copy of the ClosingSigned
135          */
136         public ClosingSigned clone() {
137                 long ret = bindings.ClosingSigned_clone(this.ptr);
138                 GC.KeepAlive(this);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
141                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
142                 return ret_hu_conv;
143         }
144
145         /**
146          * Generates a non-cryptographic 64-bit hash of the ClosingSigned.
147          */
148         public long hash() {
149                 long ret = bindings.ClosingSigned_hash(this.ptr);
150                 GC.KeepAlive(this);
151                 return ret;
152         }
153
154         public override int GetHashCode() {
155                 return (int)this.hash();
156         }
157         /**
158          * Checks if two ClosingSigneds contain equal inner contents.
159          * This ignores pointers and is_owned flags and looks at the values in fields.
160          * Two objects with NULL inner values will be considered "equal" here.
161          */
162         public bool eq(org.ldk.structs.ClosingSigned b) {
163                 bool ret = bindings.ClosingSigned_eq(this.ptr, b.ptr);
164                 GC.KeepAlive(this);
165                 GC.KeepAlive(b);
166                 if (this != null) { this.ptrs_to.AddLast(b); };
167                 return ret;
168         }
169
170         public override bool Equals(object o) {
171                 if (!(o is ClosingSigned)) return false;
172                 return this.eq((ClosingSigned)o);
173         }
174         /**
175          * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
176          */
177         public byte[] write() {
178                 long ret = bindings.ClosingSigned_write(this.ptr);
179                 GC.KeepAlive(this);
180                 if (ret >= 0 && ret <= 4096) { return null; }
181                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
182                 return ret_conv;
183         }
184
185         /**
186          * Read a ClosingSigned from a byte array, created by ClosingSigned_write
187          */
188         public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
189                 long ret = bindings.ClosingSigned_read(InternalUtils.encodeUint8Array(ser));
190                 GC.KeepAlive(ser);
191                 if (ret >= 0 && ret <= 4096) { return null; }
192                 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);
193                 return ret_hu_conv;
194         }
195
196 }
197 } } }