X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FAPIError.java;h=1410b0e51d6954c751f9b7528ab0bb9956d0636b;hb=f3e670e9341decac613d33fc52febf19cea32f20;hp=48152a61b9312c492ca6a168f29ad893ebb55436;hpb=d92b9f26eda1f6c1fbb970db797a03fac62c5606;p=ldk-java diff --git a/src/main/java/org/ldk/structs/APIError.java b/src/main/java/org/ldk/structs/APIError.java index 48152a61..1410b0e5 100644 --- a/src/main/java/org/ldk/structs/APIError.java +++ b/src/main/java/org/ldk/structs/APIError.java @@ -42,6 +42,10 @@ public class APIError extends CommonBase { assert false; return null; // Unreachable without extending the (internal) bindings interface } + /** + * Indicates the API was wholly misused (see err for more). Cases where these can be returned + * are documented, but generally indicates some precondition of a function was violated. + */ public final static class APIMisuseError extends APIError { /** * A human-readable error message @@ -52,6 +56,11 @@ public class APIError extends CommonBase { this.err = obj.err; } } + /** + * Due to a high feerate, we were unable to complete the request. + * For example, this may be returned if the feerate implies we cannot open a channel at the + * requested value, but opening a larger channel would succeed. + */ public final static class FeeRateTooHigh extends APIError { /** * A human-readable error message @@ -67,6 +76,10 @@ public class APIError extends CommonBase { this.feerate = obj.feerate; } } + /** + * A malformed Route was provided (eg overflowed value, node id mismatch, overly-looped route, + * too-many-hops, etc). + */ public final static class RouteError extends APIError { /** * A human-readable error message @@ -77,6 +90,11 @@ public class APIError extends CommonBase { this.err = obj.err; } } + /** + * We were unable to complete the request as the Channel required to do so is unable to + * complete the request (or was not found). This can take many forms, including disconnected + * peer, channel at capacity, channel shutting down, etc. + */ public final static class ChannelUnavailable extends APIError { /** * A human-readable error message @@ -87,11 +105,25 @@ public class APIError extends CommonBase { this.err = obj.err; } } + /** + * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the + * attempted action to fail. + */ public final static class MonitorUpdateFailed extends APIError { private MonitorUpdateFailed(long ptr, bindings.LDKAPIError.MonitorUpdateFailed obj) { super(null, ptr); } } + /** + * [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible + * with the channel counterparty as negotiated in [`InitFeatures`]. + * + * Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open + * a channel or cooperatively close one with this peer (and will have to force-close instead). + * + * [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey + * [`InitFeatures`]: crate::ln::features::InitFeatures + */ public final static class IncompatibleShutdownScript extends APIError { /** * The incompatible shutdown script. @@ -100,17 +132,22 @@ public class APIError extends CommonBase { private IncompatibleShutdownScript(long ptr, bindings.LDKAPIError.IncompatibleShutdownScript obj) { super(null, ptr); long script = obj.script; - ShutdownScript script_hu_conv = new ShutdownScript(null, script); + ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new ShutdownScript(null, script); } script_hu_conv.ptrs_to.add(this); this.script = script_hu_conv; } } + long clone_ptr() { + long ret = bindings.APIError_clone_ptr(this.ptr); + return ret; + } + /** * Creates a copy of the APIError */ public APIError clone() { long ret = bindings.APIError_clone(this.ptr); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } APIError ret_hu_conv = APIError.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; @@ -121,7 +158,7 @@ public class APIError extends CommonBase { */ public static APIError apimisuse_error(java.lang.String err) { long ret = bindings.APIError_apimisuse_error(err); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } APIError ret_hu_conv = APIError.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; @@ -132,7 +169,7 @@ public class APIError extends CommonBase { */ public static APIError fee_rate_too_high(java.lang.String err, int feerate) { long ret = bindings.APIError_fee_rate_too_high(err, feerate); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } APIError ret_hu_conv = APIError.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; @@ -143,7 +180,7 @@ public class APIError extends CommonBase { */ public static APIError route_error(java.lang.String err) { long ret = bindings.APIError_route_error(err); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } APIError ret_hu_conv = APIError.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; @@ -154,7 +191,7 @@ public class APIError extends CommonBase { */ public static APIError channel_unavailable(java.lang.String err) { long ret = bindings.APIError_channel_unavailable(err); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } APIError ret_hu_conv = APIError.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; @@ -165,7 +202,7 @@ public class APIError extends CommonBase { */ public static APIError monitor_update_failed() { long ret = bindings.APIError_monitor_update_failed(); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } APIError ret_hu_conv = APIError.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; @@ -176,10 +213,9 @@ public class APIError extends CommonBase { */ public static APIError incompatible_shutdown_script(ShutdownScript script) { long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr & ~1); - if (ret < 1024) { return null; } + if (ret >= 0 && ret <= 4096) { return null; } APIError ret_hu_conv = APIError.constr_from_ptr(ret); ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(script); return ret_hu_conv; }