6 namespace org { namespace ldk { namespace structs {
9 * Indicates an error on the client's part (usually some variant of attempting to use too-low or
12 public class APIError : CommonBase {
13 protected APIError(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.APIError_free(ptr); }
18 internal static APIError constr_from_ptr(long ptr) {
19 long raw_ty = bindings.LDKAPIError_ty_from_ptr(ptr);
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);
28 throw new ArgumentException("Impossible enum variant");
32 /** A APIError of type APIMisuseError */
33 public class APIError_APIMisuseError : APIError {
35 * A human-readable error message
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);
44 /** A APIError of type FeeRateTooHigh */
45 public class APIError_FeeRateTooHigh : APIError {
47 * A human-readable error message
51 * The feerate which was too high.
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);
58 this.feerate = bindings.LDKAPIError_FeeRateTooHigh_get_feerate(ptr);
61 /** A APIError of type InvalidRoute */
62 public class APIError_InvalidRoute : APIError {
64 * A human-readable error message
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);
73 /** A APIError of type ChannelUnavailable */
74 public class APIError_ChannelUnavailable : APIError {
76 * A human-readable error message
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);
85 /** A APIError of type MonitorUpdateInProgress */
86 public class APIError_MonitorUpdateInProgress : APIError {
87 internal APIError_MonitorUpdateInProgress(long ptr) : base(null, ptr) {
90 /** A APIError of type IncompatibleShutdownScript */
91 public class APIError_IncompatibleShutdownScript : APIError {
93 * The incompatible shutdown script.
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;
103 internal long clone_ptr() {
104 long ret = bindings.APIError_clone_ptr(this.ptr);
110 * Creates a copy of the APIError
112 public APIError clone() {
113 long ret = bindings.APIError_clone(this.ptr);
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); };
122 * Utility method to constructs a new APIMisuseError-variant APIError
124 public static APIError apimisuse_error(string err) {
125 long ret = bindings.APIError_apimisuse_error(InternalUtils.encodeString(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); };
134 * Utility method to constructs a new FeeRateTooHigh-variant APIError
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);
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); };
147 * Utility method to constructs a new InvalidRoute-variant APIError
149 public static APIError invalid_route(string err) {
150 long ret = bindings.APIError_invalid_route(InternalUtils.encodeString(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); };
159 * Utility method to constructs a new ChannelUnavailable-variant APIError
161 public static APIError channel_unavailable(string err) {
162 long ret = bindings.APIError_channel_unavailable(InternalUtils.encodeString(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); };
171 * Utility method to constructs a new MonitorUpdateInProgress-variant APIError
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); };
182 * Utility method to constructs a new IncompatibleShutdownScript-variant APIError
184 public static APIError incompatible_shutdown_script(org.ldk.structs.ShutdownScript script) {
185 long ret = bindings.APIError_incompatible_shutdown_script(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); };
195 * Checks if two APIErrors contain equal inner contents.
196 * This ignores pointers and is_owned flags and looks at the values in fields.
198 public bool eq(org.ldk.structs.APIError b) {
199 bool ret = bindings.APIError_eq(this.ptr, b.ptr);
205 public override bool Equals(object o) {
206 if (!(o is APIError)) return false;
207 return this.eq((APIError)o);
210 * Serialize the APIError object into a byte array which can be read by APIError_read
212 public byte[] write() {
213 long ret = bindings.APIError_write(this.ptr);
215 if (ret >= 0 && ret <= 4096) { return null; }
216 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);