6 namespace org { namespace ldk { namespace structs {
9 * Used to put an error message in a [`LightningError`].
11 public class ErrorAction : CommonBase {
12 protected ErrorAction(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.ErrorAction_free(ptr); }
17 internal static ErrorAction constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKErrorAction_ty_from_ptr(ptr);
20 case 0: return new ErrorAction_DisconnectPeer(ptr);
21 case 1: return new ErrorAction_DisconnectPeerWithWarning(ptr);
22 case 2: return new ErrorAction_IgnoreError(ptr);
23 case 3: return new ErrorAction_IgnoreAndLog(ptr);
24 case 4: return new ErrorAction_IgnoreDuplicateGossip(ptr);
25 case 5: return new ErrorAction_SendErrorMessage(ptr);
26 case 6: return new ErrorAction_SendWarningMessage(ptr);
28 throw new ArgumentException("Impossible enum variant");
32 /** A ErrorAction of type DisconnectPeer */
33 public class ErrorAction_DisconnectPeer : ErrorAction {
35 * An error message which we should make an effort to send before we disconnect.
37 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
39 public ErrorMessage msg;
40 internal ErrorAction_DisconnectPeer(long ptr) : base(null, ptr) {
41 long msg = bindings.LDKErrorAction_DisconnectPeer_get_msg(ptr);
42 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
43 if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
44 this.msg = msg_hu_conv;
47 /** A ErrorAction of type DisconnectPeerWithWarning */
48 public class ErrorAction_DisconnectPeerWithWarning : ErrorAction {
50 * A warning message which we should make an effort to send before we disconnect.
52 public WarningMessage msg;
53 internal ErrorAction_DisconnectPeerWithWarning(long ptr) : base(null, ptr) {
54 long msg = bindings.LDKErrorAction_DisconnectPeerWithWarning_get_msg(ptr);
55 org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); }
56 if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
57 this.msg = msg_hu_conv;
60 /** A ErrorAction of type IgnoreError */
61 public class ErrorAction_IgnoreError : ErrorAction {
62 internal ErrorAction_IgnoreError(long ptr) : base(null, ptr) {
65 /** A ErrorAction of type IgnoreAndLog */
66 public class ErrorAction_IgnoreAndLog : ErrorAction {
67 public Level ignore_and_log;
68 internal ErrorAction_IgnoreAndLog(long ptr) : base(null, ptr) {
69 this.ignore_and_log = bindings.LDKErrorAction_IgnoreAndLog_get_ignore_and_log(ptr);
72 /** A ErrorAction of type IgnoreDuplicateGossip */
73 public class ErrorAction_IgnoreDuplicateGossip : ErrorAction {
74 internal ErrorAction_IgnoreDuplicateGossip(long ptr) : base(null, ptr) {
77 /** A ErrorAction of type SendErrorMessage */
78 public class ErrorAction_SendErrorMessage : ErrorAction {
80 * The message to send.
82 public ErrorMessage msg;
83 internal ErrorAction_SendErrorMessage(long ptr) : base(null, ptr) {
84 long msg = bindings.LDKErrorAction_SendErrorMessage_get_msg(ptr);
85 org.ldk.structs.ErrorMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ErrorMessage(null, msg); }
86 if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
87 this.msg = msg_hu_conv;
90 /** A ErrorAction of type SendWarningMessage */
91 public class ErrorAction_SendWarningMessage : ErrorAction {
93 * The message to send.
95 public WarningMessage msg;
97 * The peer may have done something harmless that we weren't able to meaningfully process,
98 * though we should still tell them about it.
99 * If this event is logged, log it at the given level.
101 public Level log_level;
102 internal ErrorAction_SendWarningMessage(long ptr) : base(null, ptr) {
103 long msg = bindings.LDKErrorAction_SendWarningMessage_get_msg(ptr);
104 org.ldk.structs.WarningMessage msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.WarningMessage(null, msg); }
105 if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.AddLast(this); };
106 this.msg = msg_hu_conv;
107 this.log_level = bindings.LDKErrorAction_SendWarningMessage_get_log_level(ptr);
110 internal long clone_ptr() {
111 long ret = bindings.ErrorAction_clone_ptr(this.ptr);
117 * Creates a copy of the ErrorAction
119 public ErrorAction clone() {
120 long ret = bindings.ErrorAction_clone(this.ptr);
122 if (ret >= 0 && ret <= 4096) { return null; }
123 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
124 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
129 * Utility method to constructs a new DisconnectPeer-variant ErrorAction
131 public static ErrorAction disconnect_peer(org.ldk.structs.ErrorMessage msg) {
132 long ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr);
134 if (ret >= 0 && ret <= 4096) { return null; }
135 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
136 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
137 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
142 * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction
144 public static ErrorAction disconnect_peer_with_warning(org.ldk.structs.WarningMessage msg) {
145 long ret = bindings.ErrorAction_disconnect_peer_with_warning(msg == null ? 0 : msg.ptr);
147 if (ret >= 0 && ret <= 4096) { return null; }
148 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
149 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
150 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
155 * Utility method to constructs a new IgnoreError-variant ErrorAction
157 public static ErrorAction ignore_error() {
158 long ret = bindings.ErrorAction_ignore_error();
159 if (ret >= 0 && ret <= 4096) { return null; }
160 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
161 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
166 * Utility method to constructs a new IgnoreAndLog-variant ErrorAction
168 public static ErrorAction ignore_and_log(Level a) {
169 long ret = bindings.ErrorAction_ignore_and_log(a);
171 if (ret >= 0 && ret <= 4096) { return null; }
172 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
173 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
178 * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction
180 public static ErrorAction ignore_duplicate_gossip() {
181 long ret = bindings.ErrorAction_ignore_duplicate_gossip();
182 if (ret >= 0 && ret <= 4096) { return null; }
183 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
184 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
189 * Utility method to constructs a new SendErrorMessage-variant ErrorAction
191 public static ErrorAction send_error_message(org.ldk.structs.ErrorMessage msg) {
192 long ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr);
194 if (ret >= 0 && ret <= 4096) { return null; }
195 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
196 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
197 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };
202 * Utility method to constructs a new SendWarningMessage-variant ErrorAction
204 public static ErrorAction send_warning_message(org.ldk.structs.WarningMessage msg, Level log_level) {
205 long ret = bindings.ErrorAction_send_warning_message(msg == null ? 0 : msg.ptr, log_level);
207 GC.KeepAlive(log_level);
208 if (ret >= 0 && ret <= 4096) { return null; }
209 org.ldk.structs.ErrorAction ret_hu_conv = org.ldk.structs.ErrorAction.constr_from_ptr(ret);
210 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
211 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(msg); };