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_Sending(ptr);
23 throw new ArgumentException("Impossible enum variant");
27 /** A PaymentError of type Invoice */
28 public class PaymentError_Invoice : PaymentError {
29 public string invoice;
30 internal PaymentError_Invoice(long ptr) : base(null, ptr) {
31 this.invoice = bindings.LDKPaymentError_Invoice_get_invoice(ptr);
34 /** A PaymentError of type Sending */
35 public class PaymentError_Sending : PaymentError {
36 public RetryableSendFailure sending;
37 internal PaymentError_Sending(long ptr) : base(null, ptr) {
38 this.sending = bindings.LDKPaymentError_Sending_get_sending(ptr);
41 internal long clone_ptr() {
42 long ret = bindings.PaymentError_clone_ptr(this.ptr);
48 * Creates a copy of the PaymentError
50 public PaymentError clone() {
51 long ret = bindings.PaymentError_clone(this.ptr);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
55 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
60 * Utility method to constructs a new Invoice-variant PaymentError
62 public static PaymentError invoice(string a) {
63 long ret = bindings.PaymentError_invoice(a);
65 if (ret >= 0 && ret <= 4096) { return null; }
66 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
67 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
72 * Utility method to constructs a new Sending-variant PaymentError
74 public static PaymentError sending(RetryableSendFailure a) {
75 long ret = bindings.PaymentError_sending(a);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
84 * Checks if two PaymentErrors contain equal inner contents.
85 * This ignores pointers and is_owned flags and looks at the values in fields.
87 public bool eq(org.ldk.structs.PaymentError b) {
88 bool ret = bindings.PaymentError_eq(this.ptr, b == null ? 0 : b.ptr);
94 public override bool Equals(object o) {
95 if (!(o is PaymentError)) return false;
96 return this.eq((PaymentError)o);