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 long invoice = bindings.LDKPaymentError_Invoice_get_invoice(ptr);
32 string invoice_conv = InternalUtils.decodeString(invoice);
33 this.invoice = invoice_conv;
36 /** A PaymentError of type Sending */
37 public class PaymentError_Sending : PaymentError {
38 public RetryableSendFailure sending;
39 internal PaymentError_Sending(long ptr) : base(null, ptr) {
40 this.sending = bindings.LDKPaymentError_Sending_get_sending(ptr);
43 internal long clone_ptr() {
44 long ret = bindings.PaymentError_clone_ptr(this.ptr);
50 * Creates a copy of the PaymentError
52 public PaymentError clone() {
53 long ret = bindings.PaymentError_clone(this.ptr);
55 if (ret >= 0 && ret <= 4096) { return null; }
56 org.ldk.structs.PaymentError ret_hu_conv = org.ldk.structs.PaymentError.constr_from_ptr(ret);
57 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
62 * Utility method to constructs a new Invoice-variant PaymentError
64 public static PaymentError invoice(string a) {
65 long ret = bindings.PaymentError_invoice(InternalUtils.encodeString(a));
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(ret_hu_conv); };
74 * Utility method to constructs a new Sending-variant PaymentError
76 public static PaymentError sending(RetryableSendFailure a) {
77 long ret = bindings.PaymentError_sending(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 * Checks if two PaymentErrors contain equal inner contents.
87 * This ignores pointers and is_owned flags and looks at the values in fields.
89 public bool eq(org.ldk.structs.PaymentError b) {
90 bool ret = bindings.PaymentError_eq(this.ptr, b == null ? 0 : b.ptr);
96 public override bool Equals(object o) {
97 if (!(o is PaymentError)) return false;
98 return this.eq((PaymentError)o);