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 this.err = bindings.LDKAPIError_APIMisuseError_get_err(ptr);
42 /** A APIError of type FeeRateTooHigh */
43 public class APIError_FeeRateTooHigh : APIError {
45 * A human-readable error message
49 * The feerate which was too high.
52 internal APIError_FeeRateTooHigh(long ptr) : base(null, ptr) {
53 this.err = bindings.LDKAPIError_FeeRateTooHigh_get_err(ptr);
54 this.feerate = bindings.LDKAPIError_FeeRateTooHigh_get_feerate(ptr);
57 /** A APIError of type InvalidRoute */
58 public class APIError_InvalidRoute : APIError {
60 * A human-readable error message
63 internal APIError_InvalidRoute(long ptr) : base(null, ptr) {
64 this.err = bindings.LDKAPIError_InvalidRoute_get_err(ptr);
67 /** A APIError of type ChannelUnavailable */
68 public class APIError_ChannelUnavailable : APIError {
70 * A human-readable error message
73 internal APIError_ChannelUnavailable(long ptr) : base(null, ptr) {
74 this.err = bindings.LDKAPIError_ChannelUnavailable_get_err(ptr);
77 /** A APIError of type MonitorUpdateInProgress */
78 public class APIError_MonitorUpdateInProgress : APIError {
79 internal APIError_MonitorUpdateInProgress(long ptr) : base(null, ptr) {
82 /** A APIError of type IncompatibleShutdownScript */
83 public class APIError_IncompatibleShutdownScript : APIError {
85 * The incompatible shutdown script.
87 public ShutdownScript script;
88 internal APIError_IncompatibleShutdownScript(long ptr) : base(null, ptr) {
89 long script = bindings.LDKAPIError_IncompatibleShutdownScript_get_script(ptr);
90 org.ldk.structs.ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new org.ldk.structs.ShutdownScript(null, script); }
91 if (script_hu_conv != null) { script_hu_conv.ptrs_to.AddLast(this); };
92 this.script = script_hu_conv;
95 internal long clone_ptr() {
96 long ret = bindings.APIError_clone_ptr(this.ptr);
102 * Creates a copy of the APIError
104 public APIError clone() {
105 long ret = bindings.APIError_clone(this.ptr);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
114 * Utility method to constructs a new APIMisuseError-variant APIError
116 public static APIError apimisuse_error(string err) {
117 long ret = bindings.APIError_apimisuse_error(err);
119 if (ret >= 0 && ret <= 4096) { return null; }
120 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
121 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
126 * Utility method to constructs a new FeeRateTooHigh-variant APIError
128 public static APIError fee_rate_too_high(string err, int feerate) {
129 long ret = bindings.APIError_fee_rate_too_high(err, feerate);
131 GC.KeepAlive(feerate);
132 if (ret >= 0 && ret <= 4096) { return null; }
133 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
134 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
139 * Utility method to constructs a new InvalidRoute-variant APIError
141 public static APIError invalid_route(string err) {
142 long ret = bindings.APIError_invalid_route(err);
144 if (ret >= 0 && ret <= 4096) { return null; }
145 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
146 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
151 * Utility method to constructs a new ChannelUnavailable-variant APIError
153 public static APIError channel_unavailable(string err) {
154 long ret = bindings.APIError_channel_unavailable(err);
156 if (ret >= 0 && ret <= 4096) { return null; }
157 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
158 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
163 * Utility method to constructs a new MonitorUpdateInProgress-variant APIError
165 public static APIError monitor_update_in_progress() {
166 long ret = bindings.APIError_monitor_update_in_progress();
167 if (ret >= 0 && ret <= 4096) { return null; }
168 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
174 * Utility method to constructs a new IncompatibleShutdownScript-variant APIError
176 public static APIError incompatible_shutdown_script(org.ldk.structs.ShutdownScript script) {
177 long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr);
178 GC.KeepAlive(script);
179 if (ret >= 0 && ret <= 4096) { return null; }
180 org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret);
181 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
182 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(script); };
187 * Checks if two APIErrors contain equal inner contents.
188 * This ignores pointers and is_owned flags and looks at the values in fields.
190 public bool eq(org.ldk.structs.APIError b) {
191 bool ret = bindings.APIError_eq(this.ptr, b == null ? 0 : b.ptr);
197 public override bool Equals(object o) {
198 if (!(o is APIError)) return false;
199 return this.eq((APIError)o);
202 * Serialize the APIError object into a byte array which can be read by APIError_read
204 public byte[] write() {
205 byte[] ret = bindings.APIError_write(this.ptr);