X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FErrorAction.java;h=4c0822126b74b4a5ed5406d005366cb8202c95ec;hb=7b75443b8305c6a24d3c08520e1785e9d39960e4;hp=f2073e6e4835c228237cba8fcaa6d6e470077fa8;hpb=9760d533f7ecac9bb7a8249f9b557e3f995c276d;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ErrorAction.java b/src/main/java/org/ldk/structs/ErrorAction.java index f2073e6e..4c082212 100644 --- a/src/main/java/org/ldk/structs/ErrorAction.java +++ b/src/main/java/org/ldk/structs/ErrorAction.java @@ -9,7 +9,7 @@ import javax.annotation.Nullable; /** - * Used to put an error message in a LightningError + * Used to put an error message in a [`LightningError`]. */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class ErrorAction extends CommonBase { @@ -24,6 +24,9 @@ public class ErrorAction extends CommonBase { if (raw_val.getClass() == bindings.LDKErrorAction.DisconnectPeer.class) { return new DisconnectPeer(ptr, (bindings.LDKErrorAction.DisconnectPeer)raw_val); } + if (raw_val.getClass() == bindings.LDKErrorAction.DisconnectPeerWithWarning.class) { + return new DisconnectPeerWithWarning(ptr, (bindings.LDKErrorAction.DisconnectPeerWithWarning)raw_val); + } if (raw_val.getClass() == bindings.LDKErrorAction.IgnoreError.class) { return new IgnoreError(ptr, (bindings.LDKErrorAction.IgnoreError)raw_val); } @@ -56,7 +59,23 @@ public class ErrorAction extends CommonBase { super(null, ptr); long msg = obj.msg; org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); } - msg_hu_conv.ptrs_to.add(this); + if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.add(this); }; + this.msg = msg_hu_conv; + } + } + /** + * The peer did something incorrect. Tell them without closing any channels and disconnect them. + */ + public final static class DisconnectPeerWithWarning extends ErrorAction { + /** + * A warning message which we should make an effort to send before we disconnect. + */ + public final org.ldk.structs.WarningMessage msg; + private DisconnectPeerWithWarning(long ptr, bindings.LDKErrorAction.DisconnectPeerWithWarning obj) { + super(null, ptr); + long msg = obj.msg; + org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); } + if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.add(this); }; this.msg = msg_hu_conv; } } @@ -101,7 +120,7 @@ public class ErrorAction extends CommonBase { super(null, ptr); long msg = obj.msg; org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); } - msg_hu_conv.ptrs_to.add(this); + if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.add(this); }; this.msg = msg_hu_conv; } } @@ -123,7 +142,7 @@ public class ErrorAction extends CommonBase { super(null, ptr); long msg = obj.msg; org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); } - msg_hu_conv.ptrs_to.add(this); + if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.add(this); }; this.msg = msg_hu_conv; this.log_level = obj.log_level; } @@ -142,20 +161,33 @@ public class ErrorAction extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.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; } /** * Utility method to constructs a new DisconnectPeer-variant ErrorAction */ - public static ErrorAction disconnect_peer(ErrorMessage msg) { + public static ErrorAction disconnect_peer(org.ldk.structs.ErrorMessage msg) { long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr); Reference.reachabilityFence(msg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(msg); + 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(msg); }; + return ret_hu_conv; + } + + /** + * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction + */ + public static ErrorAction disconnect_peer_with_warning(org.ldk.structs.WarningMessage msg) { + long ret = bindings.ErrorAction_disconnect_peer_with_warning(msg == null ? 0 : msg.ptr); + Reference.reachabilityFence(msg); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); + 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(msg); }; return ret_hu_conv; } @@ -166,7 +198,7 @@ public class ErrorAction extends CommonBase { long ret = bindings.ErrorAction_ignore_error(); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.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; } @@ -178,7 +210,7 @@ public class ErrorAction extends CommonBase { Reference.reachabilityFence(a); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.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; } @@ -189,35 +221,47 @@ public class ErrorAction extends CommonBase { long ret = bindings.ErrorAction_ignore_duplicate_gossip(); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.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 SendErrorMessage-variant ErrorAction */ - public static ErrorAction send_error_message(ErrorMessage msg) { + public static ErrorAction send_error_message(org.ldk.structs.ErrorMessage msg) { long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr); Reference.reachabilityFence(msg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(msg); + 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(msg); }; return ret_hu_conv; } /** * Utility method to constructs a new SendWarningMessage-variant ErrorAction */ - public static ErrorAction send_warning_message(WarningMessage msg, org.ldk.enums.Level log_level) { + public static ErrorAction send_warning_message(org.ldk.structs.WarningMessage msg, org.ldk.enums.Level log_level) { long ret = bindings.ErrorAction_send_warning_message(msg == null ? 0 : msg.ptr, log_level); Reference.reachabilityFence(msg); Reference.reachabilityFence(log_level); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); - ret_hu_conv.ptrs_to.add(msg); + 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(msg); }; return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the ErrorAction. + */ + public long hash() { + long ret = bindings.ErrorAction_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + @Override public int hashCode() { + return (int)this.hash(); + } }