[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / ClosureReason.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  * The reason the channel was closed. See individual variants for more details.
10  */
11 public class ClosureReason : CommonBase {
12         protected ClosureReason(object _dummy, long ptr) : base(ptr) { }
13         ~ClosureReason() {
14                 if (ptr != 0) { bindings.ClosureReason_free(ptr); }
15         }
16
17         internal static ClosureReason constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKClosureReason_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new ClosureReason_CounterpartyForceClosed(ptr);
21                         case 1: return new ClosureReason_HolderForceClosed(ptr);
22                         case 2: return new ClosureReason_CooperativeClosure(ptr);
23                         case 3: return new ClosureReason_CommitmentTxConfirmed(ptr);
24                         case 4: return new ClosureReason_FundingTimedOut(ptr);
25                         case 5: return new ClosureReason_ProcessingError(ptr);
26                         case 6: return new ClosureReason_DisconnectedPeer(ptr);
27                         case 7: return new ClosureReason_OutdatedChannelManager(ptr);
28                         case 8: return new ClosureReason_CounterpartyCoopClosedUnfundedChannel(ptr);
29                         case 9: return new ClosureReason_FundingBatchClosure(ptr);
30                         default:
31                                 throw new ArgumentException("Impossible enum variant");
32                 }
33         }
34
35         /** A ClosureReason of type CounterpartyForceClosed */
36         public class ClosureReason_CounterpartyForceClosed : ClosureReason {
37                 /**
38                  * The error which the peer sent us.
39                  * 
40                  * Be careful about printing the peer_msg, a well-crafted message could exploit
41                  * a security vulnerability in the terminal emulator or the logging subsystem.
42                  * To be safe, use `Display` on `UntrustedString`
43                  * 
44                  * [`UntrustedString`]: crate::util::string::UntrustedString
45                  */
46                 public UntrustedString peer_msg;
47                 internal ClosureReason_CounterpartyForceClosed(long ptr) : base(null, ptr) {
48                         long peer_msg = bindings.LDKClosureReason_CounterpartyForceClosed_get_peer_msg(ptr);
49                         org.ldk.structs.UntrustedString peer_msg_hu_conv = null; if (peer_msg < 0 || peer_msg > 4096) { peer_msg_hu_conv = new org.ldk.structs.UntrustedString(null, peer_msg); }
50                         if (peer_msg_hu_conv != null) { peer_msg_hu_conv.ptrs_to.AddLast(this); };
51                         this.peer_msg = peer_msg_hu_conv;
52                 }
53         }
54         /** A ClosureReason of type HolderForceClosed */
55         public class ClosureReason_HolderForceClosed : ClosureReason {
56                 internal ClosureReason_HolderForceClosed(long ptr) : base(null, ptr) {
57                 }
58         }
59         /** A ClosureReason of type CooperativeClosure */
60         public class ClosureReason_CooperativeClosure : ClosureReason {
61                 internal ClosureReason_CooperativeClosure(long ptr) : base(null, ptr) {
62                 }
63         }
64         /** A ClosureReason of type CommitmentTxConfirmed */
65         public class ClosureReason_CommitmentTxConfirmed : ClosureReason {
66                 internal ClosureReason_CommitmentTxConfirmed(long ptr) : base(null, ptr) {
67                 }
68         }
69         /** A ClosureReason of type FundingTimedOut */
70         public class ClosureReason_FundingTimedOut : ClosureReason {
71                 internal ClosureReason_FundingTimedOut(long ptr) : base(null, ptr) {
72                 }
73         }
74         /** A ClosureReason of type ProcessingError */
75         public class ClosureReason_ProcessingError : ClosureReason {
76                 /**
77                  * A developer-readable error message which we generated.
78                  */
79                 public string err;
80                 internal ClosureReason_ProcessingError(long ptr) : base(null, ptr) {
81                         long err = bindings.LDKClosureReason_ProcessingError_get_err(ptr);
82                         string err_conv = InternalUtils.decodeString(err);
83                         this.err = err_conv;
84                 }
85         }
86         /** A ClosureReason of type DisconnectedPeer */
87         public class ClosureReason_DisconnectedPeer : ClosureReason {
88                 internal ClosureReason_DisconnectedPeer(long ptr) : base(null, ptr) {
89                 }
90         }
91         /** A ClosureReason of type OutdatedChannelManager */
92         public class ClosureReason_OutdatedChannelManager : ClosureReason {
93                 internal ClosureReason_OutdatedChannelManager(long ptr) : base(null, ptr) {
94                 }
95         }
96         /** A ClosureReason of type CounterpartyCoopClosedUnfundedChannel */
97         public class ClosureReason_CounterpartyCoopClosedUnfundedChannel : ClosureReason {
98                 internal ClosureReason_CounterpartyCoopClosedUnfundedChannel(long ptr) : base(null, ptr) {
99                 }
100         }
101         /** A ClosureReason of type FundingBatchClosure */
102         public class ClosureReason_FundingBatchClosure : ClosureReason {
103                 internal ClosureReason_FundingBatchClosure(long ptr) : base(null, ptr) {
104                 }
105         }
106         internal long clone_ptr() {
107                 long ret = bindings.ClosureReason_clone_ptr(this.ptr);
108                 GC.KeepAlive(this);
109                 return ret;
110         }
111
112         /**
113          * Creates a copy of the ClosureReason
114          */
115         public ClosureReason clone() {
116                 long ret = bindings.ClosureReason_clone(this.ptr);
117                 GC.KeepAlive(this);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason
126          */
127         public static ClosureReason counterparty_force_closed(org.ldk.structs.UntrustedString peer_msg) {
128                 long ret = bindings.ClosureReason_counterparty_force_closed(peer_msg == null ? 0 : peer_msg.ptr);
129                 GC.KeepAlive(peer_msg);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
132                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
133                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(peer_msg); };
134                 return ret_hu_conv;
135         }
136
137         /**
138          * Utility method to constructs a new HolderForceClosed-variant ClosureReason
139          */
140         public static ClosureReason holder_force_closed() {
141                 long ret = bindings.ClosureReason_holder_force_closed();
142                 if (ret >= 0 && ret <= 4096) { return null; }
143                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
144                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
145                 return ret_hu_conv;
146         }
147
148         /**
149          * Utility method to constructs a new CooperativeClosure-variant ClosureReason
150          */
151         public static ClosureReason cooperative_closure() {
152                 long ret = bindings.ClosureReason_cooperative_closure();
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
156                 return ret_hu_conv;
157         }
158
159         /**
160          * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason
161          */
162         public static ClosureReason commitment_tx_confirmed() {
163                 long ret = bindings.ClosureReason_commitment_tx_confirmed();
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
166                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
167                 return ret_hu_conv;
168         }
169
170         /**
171          * Utility method to constructs a new FundingTimedOut-variant ClosureReason
172          */
173         public static ClosureReason funding_timed_out() {
174                 long ret = bindings.ClosureReason_funding_timed_out();
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
177                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
178                 return ret_hu_conv;
179         }
180
181         /**
182          * Utility method to constructs a new ProcessingError-variant ClosureReason
183          */
184         public static ClosureReason processing_error(string err) {
185                 long ret = bindings.ClosureReason_processing_error(InternalUtils.encodeString(err));
186                 GC.KeepAlive(err);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
189                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
190                 return ret_hu_conv;
191         }
192
193         /**
194          * Utility method to constructs a new DisconnectedPeer-variant ClosureReason
195          */
196         public static ClosureReason disconnected_peer() {
197                 long ret = bindings.ClosureReason_disconnected_peer();
198                 if (ret >= 0 && ret <= 4096) { return null; }
199                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
200                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
201                 return ret_hu_conv;
202         }
203
204         /**
205          * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason
206          */
207         public static ClosureReason outdated_channel_manager() {
208                 long ret = bindings.ClosureReason_outdated_channel_manager();
209                 if (ret >= 0 && ret <= 4096) { return null; }
210                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
211                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
212                 return ret_hu_conv;
213         }
214
215         /**
216          * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason
217          */
218         public static ClosureReason counterparty_coop_closed_unfunded_channel() {
219                 long ret = bindings.ClosureReason_counterparty_coop_closed_unfunded_channel();
220                 if (ret >= 0 && ret <= 4096) { return null; }
221                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
222                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
223                 return ret_hu_conv;
224         }
225
226         /**
227          * Utility method to constructs a new FundingBatchClosure-variant ClosureReason
228          */
229         public static ClosureReason funding_batch_closure() {
230                 long ret = bindings.ClosureReason_funding_batch_closure();
231                 if (ret >= 0 && ret <= 4096) { return null; }
232                 org.ldk.structs.ClosureReason ret_hu_conv = org.ldk.structs.ClosureReason.constr_from_ptr(ret);
233                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
234                 return ret_hu_conv;
235         }
236
237         /**
238          * Checks if two ClosureReasons contain equal inner contents.
239          * This ignores pointers and is_owned flags and looks at the values in fields.
240          */
241         public bool eq(org.ldk.structs.ClosureReason b) {
242                 bool ret = bindings.ClosureReason_eq(this.ptr, b == null ? 0 : b.ptr);
243                 GC.KeepAlive(this);
244                 GC.KeepAlive(b);
245                 return ret;
246         }
247
248         public override bool Equals(object o) {
249                 if (!(o is ClosureReason)) return false;
250                 return this.eq((ClosureReason)o);
251         }
252         /**
253          * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read
254          */
255         public byte[] write() {
256                 long ret = bindings.ClosureReason_write(this.ptr);
257                 GC.KeepAlive(this);
258                 if (ret >= 0 && ret <= 4096) { return null; }
259                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
260                 return ret_conv;
261         }
262
263 }
264 } } }