X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FAPIError.java;h=1d5bc19f0412c591bac5e3da7378e0dba219d5fd;hb=3e33cfde4213dafe90eb976eb67224e2451da855;hp=76a48e2321aad6b1d4501e331feea38249ac7db8;hpb=13cdf8bde340072288b39a5e29f0946d3e095ad4;p=ldk-java diff --git a/src/main/java/org/ldk/structs/APIError.java b/src/main/java/org/ldk/structs/APIError.java index 76a48e23..1d5bc19f 100644 --- a/src/main/java/org/ldk/structs/APIError.java +++ b/src/main/java/org/ldk/structs/APIError.java @@ -28,14 +28,14 @@ public class APIError extends CommonBase { if (raw_val.getClass() == bindings.LDKAPIError.FeeRateTooHigh.class) { return new FeeRateTooHigh(ptr, (bindings.LDKAPIError.FeeRateTooHigh)raw_val); } - if (raw_val.getClass() == bindings.LDKAPIError.RouteError.class) { - return new RouteError(ptr, (bindings.LDKAPIError.RouteError)raw_val); + if (raw_val.getClass() == bindings.LDKAPIError.InvalidRoute.class) { + return new InvalidRoute(ptr, (bindings.LDKAPIError.InvalidRoute)raw_val); } if (raw_val.getClass() == bindings.LDKAPIError.ChannelUnavailable.class) { return new ChannelUnavailable(ptr, (bindings.LDKAPIError.ChannelUnavailable)raw_val); } - if (raw_val.getClass() == bindings.LDKAPIError.MonitorUpdateFailed.class) { - return new MonitorUpdateFailed(ptr, (bindings.LDKAPIError.MonitorUpdateFailed)raw_val); + if (raw_val.getClass() == bindings.LDKAPIError.MonitorUpdateInProgress.class) { + return new MonitorUpdateInProgress(ptr, (bindings.LDKAPIError.MonitorUpdateInProgress)raw_val); } if (raw_val.getClass() == bindings.LDKAPIError.IncompatibleShutdownScript.class) { return new IncompatibleShutdownScript(ptr, (bindings.LDKAPIError.IncompatibleShutdownScript)raw_val); @@ -81,12 +81,12 @@ public class APIError extends CommonBase { * 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 { + public final static class InvalidRoute extends APIError { /** * A human-readable error message */ public final java.lang.String err; - private RouteError(long ptr, bindings.LDKAPIError.RouteError obj) { + private InvalidRoute(long ptr, bindings.LDKAPIError.InvalidRoute obj) { super(null, ptr); this.err = obj.err; } @@ -107,22 +107,28 @@ public class APIError extends CommonBase { } } /** - * An attempt to call watch/update_channel returned an Err (ie you did this!), causing the - * attempted action to fail. + * An attempt to call [`chain::Watch::watch_channel`]/[`chain::Watch::update_channel`] + * returned a [`ChannelMonitorUpdateStatus::InProgress`] indicating the persistence of a + * monitor update is awaiting async resolution. Once it resolves the attempted action should + * complete automatically. + * + * [`chain::Watch::watch_channel`]: crate::chain::Watch::watch_channel + * [`chain::Watch::update_channel`]: crate::chain::Watch::update_channel + * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress */ - public final static class MonitorUpdateFailed extends APIError { - private MonitorUpdateFailed(long ptr, bindings.LDKAPIError.MonitorUpdateFailed obj) { + public final static class MonitorUpdateInProgress extends APIError { + private MonitorUpdateInProgress(long ptr, bindings.LDKAPIError.MonitorUpdateInProgress obj) { super(null, ptr); } } /** - * [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible + * [`SignerProvider::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 + * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey * [`InitFeatures`]: crate::ln::features::InitFeatures */ public final static class IncompatibleShutdownScript extends APIError { @@ -134,7 +140,7 @@ public class APIError extends CommonBase { super(null, ptr); long script = obj.script; org.ldk.structs.ShutdownScript script_hu_conv = null; if (script < 0 || script > 4096) { script_hu_conv = new org.ldk.structs.ShutdownScript(null, script); } - script_hu_conv.ptrs_to.add(this); + if (script_hu_conv != null) { script_hu_conv.ptrs_to.add(this); }; this.script = script_hu_conv; } } @@ -152,7 +158,7 @@ public class APIError extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -164,7 +170,7 @@ public class APIError extends CommonBase { Reference.reachabilityFence(err); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } @@ -177,19 +183,19 @@ public class APIError extends CommonBase { Reference.reachabilityFence(feerate); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } /** - * Utility method to constructs a new RouteError-variant APIError + * Utility method to constructs a new InvalidRoute-variant APIError */ - public static APIError route_error(java.lang.String err) { - long ret = bindings.APIError_route_error(err); + public static APIError invalid_route(java.lang.String err) { + long ret = bindings.APIError_invalid_route(err); Reference.reachabilityFence(err); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } @@ -201,32 +207,56 @@ public class APIError extends CommonBase { Reference.reachabilityFence(err); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } /** - * Utility method to constructs a new MonitorUpdateFailed-variant APIError + * Utility method to constructs a new MonitorUpdateInProgress-variant APIError */ - public static APIError monitor_update_failed() { - long ret = bindings.APIError_monitor_update_failed(); + public static APIError monitor_update_in_progress() { + long ret = bindings.APIError_monitor_update_in_progress(); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } /** * Utility method to constructs a new IncompatibleShutdownScript-variant APIError */ - public static APIError incompatible_shutdown_script(ShutdownScript script) { + public static APIError incompatible_shutdown_script(org.ldk.structs.ShutdownScript script) { long ret = bindings.APIError_incompatible_shutdown_script(script == null ? 0 : script.ptr); Reference.reachabilityFence(script); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.APIError ret_hu_conv = org.ldk.structs.APIError.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(script); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(script); }; return ret_hu_conv; } + /** + * Checks if two APIErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ + public boolean eq(org.ldk.structs.APIError b) { + boolean ret = bindings.APIError_eq(this.ptr, b == null ? 0 : b.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(b); + return ret; + } + + @Override public boolean equals(Object o) { + if (!(o instanceof APIError)) return false; + return this.eq((APIError)o); + } + /** + * Serialize the APIError object into a byte array which can be read by APIError_read + */ + public byte[] write() { + byte[] ret = bindings.APIError_write(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + }