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