[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / APIError.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  * Indicates an error on the client's part (usually some variant of attempting to use too-low or
10  * too-high values)
11  */
12 public class APIError : CommonBase {
13         protected APIError(object _dummy, long ptr) : base(ptr) { }
14         ~APIError() {
15                 if (ptr != 0) { bindings.APIError_free(ptr); }
16         }
17
18         internal static APIError constr_from_ptr(long ptr) {
19                 long raw_ty = bindings.LDKAPIError_ty_from_ptr(ptr);
20                 switch (raw_ty) {
21                         case 0: return new APIError_APIMisuseError(ptr);
22                         case 1: return new APIError_FeeRateTooHigh(ptr);
23                         case 2: return new APIError_InvalidRoute(ptr);
24                         case 3: return new APIError_ChannelUnavailable(ptr);
25                         case 4: return new APIError_MonitorUpdateInProgress(ptr);
26                         case 5: return new APIError_IncompatibleShutdownScript(ptr);
27                         default:
28                                 throw new ArgumentException("Impossible enum variant");
29                 }
30         }
31
32         /** A APIError of type APIMisuseError */
33         public class APIError_APIMisuseError : APIError {
34                 /**
35                  * A human-readable error message
36                  */
37                 public string err;
38                 internal APIError_APIMisuseError(long ptr) : base(null, ptr) {
39                         long err = bindings.LDKAPIError_APIMisuseError_get_err(ptr);
40                         string err_conv = InternalUtils.decodeString(err);
41                         this.err = err_conv;
42                 }
43         }
44         /** A APIError of type FeeRateTooHigh */
45         public class APIError_FeeRateTooHigh : APIError {
46                 /**
47                  * A human-readable error message
48                  */
49                 public string err;
50                 /**
51                  * The feerate which was too high.
52                  */
53                 public int feerate;
54                 internal APIError_FeeRateTooHigh(long ptr) : base(null, ptr) {
55                         long err = bindings.LDKAPIError_FeeRateTooHigh_get_err(ptr);
56                         string err_conv = InternalUtils.decodeString(err);
57                         this.err = err_conv;
58                         this.feerate = bindings.LDKAPIError_FeeRateTooHigh_get_feerate(ptr);
59                 }
60         }
61         /** A APIError of type InvalidRoute */
62         public class APIError_InvalidRoute : APIError {
63                 /**
64                  * A human-readable error message
65                  */
66                 public string err;
67                 internal APIError_InvalidRoute(long ptr) : base(null, ptr) {
68                         long err = bindings.LDKAPIError_InvalidRoute_get_err(ptr);
69                         string err_conv = InternalUtils.decodeString(err);
70                         this.err = err_conv;
71                 }
72         }
73         /** A APIError of type ChannelUnavailable */
74         public class APIError_ChannelUnavailable : APIError {
75                 /**
76                  * A human-readable error message
77                  */
78                 public string err;
79                 internal APIError_ChannelUnavailable(long ptr) : base(null, ptr) {
80                         long err = bindings.LDKAPIError_ChannelUnavailable_get_err(ptr);
81                         string err_conv = InternalUtils.decodeString(err);
82                         this.err = err_conv;
83                 }
84         }
85         /** A APIError of type MonitorUpdateInProgress */
86         public class APIError_MonitorUpdateInProgress : APIError {
87                 internal APIError_MonitorUpdateInProgress(long ptr) : base(null, ptr) {
88                 }
89         }
90         /** A APIError of type IncompatibleShutdownScript */
91         public class APIError_IncompatibleShutdownScript : APIError {
92                 /**
93                  * The incompatible shutdown script.
94                  */
95                 public ShutdownScript script;
96                 internal APIError_IncompatibleShutdownScript(long ptr) : base(null, ptr) {
97                         long script = bindings.LDKAPIError_IncompatibleShutdownScript_get_script(ptr);
98                         org.ldk.structs.ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new org.ldk.structs.ShutdownScript(null, script); }
99                         if (script_hu_conv != null) { script_hu_conv.ptrs_to.AddLast(this); };
100                         this.script = script_hu_conv;
101                 }
102         }
103         internal long clone_ptr() {
104                 long ret = bindings.APIError_clone_ptr(this.ptr);
105                 GC.KeepAlive(this);
106                 return ret;
107         }
108
109         /**
110          * Creates a copy of the APIError
111          */
112         public APIError clone() {
113                 long ret = bindings.APIError_clone(this.ptr);
114                 GC.KeepAlive(this);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
117                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Utility method to constructs a new APIMisuseError-variant APIError
123          */
124         public static APIError apimisuse_error(string err) {
125                 long ret = bindings.APIError_apimisuse_error(InternalUtils.encodeString(err));
126                 GC.KeepAlive(err);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
130                 return ret_hu_conv;
131         }
132
133         /**
134          * Utility method to constructs a new FeeRateTooHigh-variant APIError
135          */
136         public static APIError fee_rate_too_high(string err, int feerate) {
137                 long ret = bindings.APIError_fee_rate_too_high(InternalUtils.encodeString(err), feerate);
138                 GC.KeepAlive(err);
139                 GC.KeepAlive(feerate);
140                 if (ret >= 0 && ret <= 4096) { return null; }
141                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
142                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
143                 return ret_hu_conv;
144         }
145
146         /**
147          * Utility method to constructs a new InvalidRoute-variant APIError
148          */
149         public static APIError invalid_route(string err) {
150                 long ret = bindings.APIError_invalid_route(InternalUtils.encodeString(err));
151                 GC.KeepAlive(err);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
155                 return ret_hu_conv;
156         }
157
158         /**
159          * Utility method to constructs a new ChannelUnavailable-variant APIError
160          */
161         public static APIError channel_unavailable(string err) {
162                 long ret = bindings.APIError_channel_unavailable(InternalUtils.encodeString(err));
163                 GC.KeepAlive(err);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.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 MonitorUpdateInProgress-variant APIError
172          */
173         public static APIError monitor_update_in_progress() {
174                 long ret = bindings.APIError_monitor_update_in_progress();
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.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 IncompatibleShutdownScript-variant APIError
183          */
184         public static APIError incompatible_shutdown_script(org.ldk.structs.ShutdownScript script) {
185                 long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr);
186                 GC.KeepAlive(script);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
189                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
190                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(script); };
191                 return ret_hu_conv;
192         }
193
194         /**
195          * Checks if two APIErrors contain equal inner contents.
196          * This ignores pointers and is_owned flags and looks at the values in fields.
197          */
198         public bool eq(org.ldk.structs.APIError b) {
199                 bool ret = bindings.APIError_eq(this.ptr, b == null ? 0 : b.ptr);
200                 GC.KeepAlive(this);
201                 GC.KeepAlive(b);
202                 return ret;
203         }
204
205         public override bool Equals(object o) {
206                 if (!(o is APIError)) return false;
207                 return this.eq((APIError)o);
208         }
209         /**
210          * Serialize the APIError object into a byte array which can be read by APIError_read
211          */
212         public byte[] write() {
213                 long ret = bindings.APIError_write(this.ptr);
214                 GC.KeepAlive(this);
215                 if (ret >= 0 && ret <= 4096) { return null; }
216                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
217                 return ret_conv;
218         }
219
220 }
221 } } }