X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FErrorAction.java;h=c13b9e519198f5066b68ddef4b855057f135b571;hb=c6bac88847b7c09560af81f00ba8dd3c2ebe3a19;hp=3eb5e9c3f740b94fa66171901c93f25220a62244;hpb=348009c7987109e810e7e31db6110fb71879fbc3;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ErrorAction.java b/src/main/java/org/ldk/structs/ErrorAction.java index 3eb5e9c3..c13b9e51 100644 --- a/src/main/java/org/ldk/structs/ErrorAction.java +++ b/src/main/java/org/ldk/structs/ErrorAction.java @@ -4,6 +4,7 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import javax.annotation.Nullable; /** @@ -35,11 +36,16 @@ public class ErrorAction extends CommonBase { } public final static class DisconnectPeer extends ErrorAction { - public final ErrorMessage msg; + /** + * An error message which we should make an effort to send before we disconnect. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable public final ErrorMessage msg; private DisconnectPeer(long ptr, bindings.LDKErrorAction.DisconnectPeer obj) { super(null, ptr); long msg = obj.msg; - ErrorMessage msg_hu_conv = new ErrorMessage(null, msg); + ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); } msg_hu_conv.ptrs_to.add(this); this.msg = msg_hu_conv; } @@ -57,11 +63,14 @@ public class ErrorAction extends CommonBase { } } public final static class SendErrorMessage extends ErrorAction { + /** + * The message to send. + */ public final ErrorMessage msg; private SendErrorMessage(long ptr, bindings.LDKErrorAction.SendErrorMessage obj) { super(null, ptr); long msg = obj.msg; - ErrorMessage msg_hu_conv = new ErrorMessage(null, msg); + ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ErrorMessage(null, msg); } msg_hu_conv.ptrs_to.add(this); this.msg = msg_hu_conv; } @@ -71,9 +80,54 @@ public class ErrorAction extends CommonBase { */ public ErrorAction clone() { long ret = bindings.ErrorAction_clone(this.ptr); + if (ret >= 0 && ret <= 4096) { return null; } ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); 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) { + long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr & ~1); + if (ret >= 0 && ret <= 4096) { return null; } + ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new IgnoreError-variant ErrorAction + */ + public static ErrorAction ignore_error() { + long ret = bindings.ErrorAction_ignore_error(); + if (ret >= 0 && ret <= 4096) { return null; } + ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + + /** + * Utility method to constructs a new IgnoreAndLog-variant ErrorAction + */ + public static ErrorAction ignore_and_log(org.ldk.enums.Level a) { + long ret = bindings.ErrorAction_ignore_and_log(a); + if (ret >= 0 && ret <= 4096) { return null; } + ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + 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) { + long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr & ~1); + if (ret >= 0 && ret <= 4096) { return null; } + ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); + return ret_hu_conv; + } + }