6 namespace org { namespace ldk { namespace structs {
9 * Errors that may occur when [sending an onion message].
11 * [sending an onion message]: OnionMessenger::send_onion_message
13 public class SendError : CommonBase {
14 protected SendError(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.SendError_free(ptr); }
19 internal static SendError constr_from_ptr(long ptr) {
20 long raw_ty = bindings.LDKSendError_ty_from_ptr(ptr);
22 case 0: return new SendError_Secp256k1(ptr);
23 case 1: return new SendError_TooBigPacket(ptr);
24 case 2: return new SendError_TooFewBlindedHops(ptr);
25 case 3: return new SendError_InvalidFirstHop(ptr);
26 case 4: return new SendError_PathNotFound(ptr);
27 case 5: return new SendError_InvalidMessage(ptr);
28 case 6: return new SendError_BufferFull(ptr);
29 case 7: return new SendError_GetNodeIdFailed(ptr);
30 case 8: return new SendError_BlindedPathAdvanceFailed(ptr);
32 throw new ArgumentException("Impossible enum variant");
36 /** A SendError of type Secp256k1 */
37 public class SendError_Secp256k1 : SendError {
38 public Secp256k1Error secp256k1;
39 internal SendError_Secp256k1(long ptr) : base(null, ptr) {
40 this.secp256k1 = bindings.LDKSendError_Secp256k1_get_secp256k1(ptr);
43 /** A SendError of type TooBigPacket */
44 public class SendError_TooBigPacket : SendError {
45 internal SendError_TooBigPacket(long ptr) : base(null, ptr) {
48 /** A SendError of type TooFewBlindedHops */
49 public class SendError_TooFewBlindedHops : SendError {
50 internal SendError_TooFewBlindedHops(long ptr) : base(null, ptr) {
53 /** A SendError of type InvalidFirstHop */
54 public class SendError_InvalidFirstHop : SendError {
55 public byte[] invalid_first_hop;
56 internal SendError_InvalidFirstHop(long ptr) : base(null, ptr) {
57 long invalid_first_hop = bindings.LDKSendError_InvalidFirstHop_get_invalid_first_hop(ptr);
58 byte[] invalid_first_hop_conv = InternalUtils.decodeUint8Array(invalid_first_hop);
59 this.invalid_first_hop = invalid_first_hop_conv;
62 /** A SendError of type PathNotFound */
63 public class SendError_PathNotFound : SendError {
64 internal SendError_PathNotFound(long ptr) : base(null, ptr) {
67 /** A SendError of type InvalidMessage */
68 public class SendError_InvalidMessage : SendError {
69 internal SendError_InvalidMessage(long ptr) : base(null, ptr) {
72 /** A SendError of type BufferFull */
73 public class SendError_BufferFull : SendError {
74 internal SendError_BufferFull(long ptr) : base(null, ptr) {
77 /** A SendError of type GetNodeIdFailed */
78 public class SendError_GetNodeIdFailed : SendError {
79 internal SendError_GetNodeIdFailed(long ptr) : base(null, ptr) {
82 /** A SendError of type BlindedPathAdvanceFailed */
83 public class SendError_BlindedPathAdvanceFailed : SendError {
84 internal SendError_BlindedPathAdvanceFailed(long ptr) : base(null, ptr) {
87 internal long clone_ptr() {
88 long ret = bindings.SendError_clone_ptr(this.ptr);
94 * Creates a copy of the SendError
96 public SendError clone() {
97 long ret = bindings.SendError_clone(this.ptr);
99 if (ret >= 0 && ret <= 4096) { return null; }
100 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
101 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
106 * Utility method to constructs a new Secp256k1-variant SendError
108 public static SendError secp256k1(Secp256k1Error a) {
109 long ret = bindings.SendError_secp256k1(a);
111 if (ret >= 0 && ret <= 4096) { return null; }
112 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
118 * Utility method to constructs a new TooBigPacket-variant SendError
120 public static SendError too_big_packet() {
121 long ret = bindings.SendError_too_big_packet();
122 if (ret >= 0 && ret <= 4096) { return null; }
123 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
124 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
129 * Utility method to constructs a new TooFewBlindedHops-variant SendError
131 public static SendError too_few_blinded_hops() {
132 long ret = bindings.SendError_too_few_blinded_hops();
133 if (ret >= 0 && ret <= 4096) { return null; }
134 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
135 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
140 * Utility method to constructs a new InvalidFirstHop-variant SendError
142 public static SendError invalid_first_hop(byte[] a) {
143 long ret = bindings.SendError_invalid_first_hop(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)));
145 if (ret >= 0 && ret <= 4096) { return null; }
146 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
147 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
152 * Utility method to constructs a new PathNotFound-variant SendError
154 public static SendError path_not_found() {
155 long ret = bindings.SendError_path_not_found();
156 if (ret >= 0 && ret <= 4096) { return null; }
157 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
158 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
163 * Utility method to constructs a new InvalidMessage-variant SendError
165 public static SendError invalid_message() {
166 long ret = bindings.SendError_invalid_message();
167 if (ret >= 0 && ret <= 4096) { return null; }
168 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
174 * Utility method to constructs a new BufferFull-variant SendError
176 public static SendError buffer_full() {
177 long ret = bindings.SendError_buffer_full();
178 if (ret >= 0 && ret <= 4096) { return null; }
179 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
180 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
185 * Utility method to constructs a new GetNodeIdFailed-variant SendError
187 public static SendError get_node_id_failed() {
188 long ret = bindings.SendError_get_node_id_failed();
189 if (ret >= 0 && ret <= 4096) { return null; }
190 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
191 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
196 * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError
198 public static SendError blinded_path_advance_failed() {
199 long ret = bindings.SendError_blinded_path_advance_failed();
200 if (ret >= 0 && ret <= 4096) { return null; }
201 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
202 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
207 * Checks if two SendErrors contain equal inner contents.
208 * This ignores pointers and is_owned flags and looks at the values in fields.
210 public bool eq(org.ldk.structs.SendError b) {
211 bool ret = bindings.SendError_eq(this.ptr, b == null ? 0 : b.ptr);
217 public override bool Equals(object o) {
218 if (!(o is SendError)) return false;
219 return this.eq((SendError)o);