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_UnresolvedIntroductionNode(ptr);
31 case 9: return new SendError_BlindedPathAdvanceFailed(ptr);
33 throw new ArgumentException("Impossible enum variant");
37 /** A SendError of type Secp256k1 */
38 public class SendError_Secp256k1 : SendError {
39 public Secp256k1Error secp256k1;
40 internal SendError_Secp256k1(long ptr) : base(null, ptr) {
41 this.secp256k1 = bindings.LDKSendError_Secp256k1_get_secp256k1(ptr);
44 /** A SendError of type TooBigPacket */
45 public class SendError_TooBigPacket : SendError {
46 internal SendError_TooBigPacket(long ptr) : base(null, ptr) {
49 /** A SendError of type TooFewBlindedHops */
50 public class SendError_TooFewBlindedHops : SendError {
51 internal SendError_TooFewBlindedHops(long ptr) : base(null, ptr) {
54 /** A SendError of type InvalidFirstHop */
55 public class SendError_InvalidFirstHop : SendError {
56 public byte[] invalid_first_hop;
57 internal SendError_InvalidFirstHop(long ptr) : base(null, ptr) {
58 long invalid_first_hop = bindings.LDKSendError_InvalidFirstHop_get_invalid_first_hop(ptr);
59 byte[] invalid_first_hop_conv = InternalUtils.decodeUint8Array(invalid_first_hop);
60 this.invalid_first_hop = invalid_first_hop_conv;
63 /** A SendError of type PathNotFound */
64 public class SendError_PathNotFound : SendError {
65 internal SendError_PathNotFound(long ptr) : base(null, ptr) {
68 /** A SendError of type InvalidMessage */
69 public class SendError_InvalidMessage : SendError {
70 internal SendError_InvalidMessage(long ptr) : base(null, ptr) {
73 /** A SendError of type BufferFull */
74 public class SendError_BufferFull : SendError {
75 internal SendError_BufferFull(long ptr) : base(null, ptr) {
78 /** A SendError of type GetNodeIdFailed */
79 public class SendError_GetNodeIdFailed : SendError {
80 internal SendError_GetNodeIdFailed(long ptr) : base(null, ptr) {
83 /** A SendError of type UnresolvedIntroductionNode */
84 public class SendError_UnresolvedIntroductionNode : SendError {
85 internal SendError_UnresolvedIntroductionNode(long ptr) : base(null, ptr) {
88 /** A SendError of type BlindedPathAdvanceFailed */
89 public class SendError_BlindedPathAdvanceFailed : SendError {
90 internal SendError_BlindedPathAdvanceFailed(long ptr) : base(null, ptr) {
93 internal long clone_ptr() {
94 long ret = bindings.SendError_clone_ptr(this.ptr);
100 * Creates a copy of the SendError
102 public SendError clone() {
103 long ret = bindings.SendError_clone(this.ptr);
105 if (ret >= 0 && ret <= 4096) { return null; }
106 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
107 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
112 * Utility method to constructs a new Secp256k1-variant SendError
114 public static SendError secp256k1(Secp256k1Error a) {
115 long ret = bindings.SendError_secp256k1(a);
117 if (ret >= 0 && ret <= 4096) { return null; }
118 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
124 * Utility method to constructs a new TooBigPacket-variant SendError
126 public static SendError too_big_packet() {
127 long ret = bindings.SendError_too_big_packet();
128 if (ret >= 0 && ret <= 4096) { return null; }
129 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
130 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
135 * Utility method to constructs a new TooFewBlindedHops-variant SendError
137 public static SendError too_few_blinded_hops() {
138 long ret = bindings.SendError_too_few_blinded_hops();
139 if (ret >= 0 && ret <= 4096) { return null; }
140 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
141 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
146 * Utility method to constructs a new InvalidFirstHop-variant SendError
148 public static SendError invalid_first_hop(byte[] a) {
149 long ret = bindings.SendError_invalid_first_hop(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(a, 33)));
151 if (ret >= 0 && ret <= 4096) { return null; }
152 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
153 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
158 * Utility method to constructs a new PathNotFound-variant SendError
160 public static SendError path_not_found() {
161 long ret = bindings.SendError_path_not_found();
162 if (ret >= 0 && ret <= 4096) { return null; }
163 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
164 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
169 * Utility method to constructs a new InvalidMessage-variant SendError
171 public static SendError invalid_message() {
172 long ret = bindings.SendError_invalid_message();
173 if (ret >= 0 && ret <= 4096) { return null; }
174 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
175 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
180 * Utility method to constructs a new BufferFull-variant SendError
182 public static SendError buffer_full() {
183 long ret = bindings.SendError_buffer_full();
184 if (ret >= 0 && ret <= 4096) { return null; }
185 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
186 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
191 * Utility method to constructs a new GetNodeIdFailed-variant SendError
193 public static SendError get_node_id_failed() {
194 long ret = bindings.SendError_get_node_id_failed();
195 if (ret >= 0 && ret <= 4096) { return null; }
196 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
197 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
202 * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError
204 public static SendError unresolved_introduction_node() {
205 long ret = bindings.SendError_unresolved_introduction_node();
206 if (ret >= 0 && ret <= 4096) { return null; }
207 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
213 * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError
215 public static SendError blinded_path_advance_failed() {
216 long ret = bindings.SendError_blinded_path_advance_failed();
217 if (ret >= 0 && ret <= 4096) { return null; }
218 org.ldk.structs.SendError ret_hu_conv = org.ldk.structs.SendError.constr_from_ptr(ret);
219 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
224 * Generates a non-cryptographic 64-bit hash of the SendError.
227 long ret = bindings.SendError_hash(this.ptr);
232 public override int GetHashCode() {
233 return (int)this.hash();
236 * Checks if two SendErrors contain equal inner contents.
237 * This ignores pointers and is_owned flags and looks at the values in fields.
239 public bool eq(org.ldk.structs.SendError b) {
240 bool ret = bindings.SendError_eq(this.ptr, b.ptr);
246 public override bool Equals(object o) {
247 if (!(o is SendError)) return false;
248 return this.eq((SendError)o);