6 namespace org { namespace ldk { namespace structs {
9 * An error that may occur when making a payment.
11 public class PaymentError : CommonBase {
12 protected PaymentError(object _dummy, long ptr) : base(ptr) { }
14 if (ptr != 0) { bindings.PaymentError_free(ptr); }
17 internal static PaymentError constr_from_ptr(long ptr) {
18 long raw_ty = bindings.LDKPaymentError_ty_from_ptr(ptr);
20 case 0: return new PaymentError_Invoice(ptr);
21 case 1: return new PaymentError_Routing(ptr);
22 case 2: return new PaymentError_Sending(ptr);
24 throw new ArgumentException("Impossible enum variant");
28 /** A PaymentError of type Invoice */
29 public class PaymentError_Invoice : PaymentError {
30 public string invoice;
31 internal PaymentError_Invoice(long ptr) : base(null, ptr) {
32 this.invoice = bindings.LDKPaymentError_Invoice_get_invoice(ptr);
35 /** A PaymentError of type Routing */
36 public class PaymentError_Routing : PaymentError {
37 public LightningError routing;
38 internal PaymentError_Routing(long ptr) : base(null, ptr) {
39 long routing = bindings.LDKPaymentError_Routing_get_routing(ptr);
40 org.ldk.structs.LightningError routing_hu_conv = null; if (routing < 0 || routing > 4096) { routing_hu_conv = new org.ldk.structs.LightningError(null, routing); }
41 if (routing_hu_conv != null) { routing_hu_conv.ptrs_to.AddLast(this); };
42 this.routing = routing_hu_conv;
45 /** A PaymentError of type Sending */
46 public class PaymentError_Sending : PaymentError {
47 public PaymentSendFailure sending;
48 internal PaymentError_Sending(long ptr) : base(null, ptr) {
49 long sending = bindings.LDKPaymentError_Sending_get_sending(ptr);
50 org.ldk.structs.PaymentSendFailure sending_hu_conv = org.ldk.structs.PaymentSendFailure.constr_from_ptr(sending);
51 if (sending_hu_conv != null) { sending_hu_conv.ptrs_to.AddLast(this); };
52 this.sending = sending_hu_conv;
55 internal long clone_ptr() {
56 long ret = bindings.PaymentError_clone_ptr(this.ptr);
62 * Creates a copy of the PaymentError
64 public PaymentError clone() {
65 long ret = bindings.PaymentError_clone(this.ptr);
67 if (ret >= 0 && ret <= 4096) { return null; }
68 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
69 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
74 * Utility method to constructs a new Invoice-variant PaymentError
76 public static PaymentError invoice(string a) {
77 long ret = bindings.PaymentError_invoice(a);
79 if (ret >= 0 && ret <= 4096) { return null; }
80 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
81 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
86 * Utility method to constructs a new Routing-variant PaymentError
88 public static PaymentError routing(org.ldk.structs.LightningError a) {
89 long ret = bindings.PaymentError_routing(a == null ? 0 : a.ptr);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
94 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(a); };
99 * Utility method to constructs a new Sending-variant PaymentError
101 public static PaymentError sending(org.ldk.structs.PaymentSendFailure a) {
102 long ret = bindings.PaymentError_sending(a.ptr);
104 if (ret >= 0 && ret <= 4096) { return null; }
105 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };