[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / RecentPaymentDetails.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8 /**
9  * Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
10  * These include payments that have yet to find a successful path, or have unresolved HTLCs.
11  */
12 public class RecentPaymentDetails : CommonBase {
13         protected RecentPaymentDetails(object _dummy, long ptr) : base(ptr) { }
14         ~RecentPaymentDetails() {
15                 if (ptr != 0) { bindings.RecentPaymentDetails_free(ptr); }
16         }
17
18         internal static RecentPaymentDetails constr_from_ptr(long ptr) {
19                 long raw_ty = bindings.LDKRecentPaymentDetails_ty_from_ptr(ptr);
20                 switch (raw_ty) {
21                         case 0: return new RecentPaymentDetails_Pending(ptr);
22                         case 1: return new RecentPaymentDetails_Fulfilled(ptr);
23                         case 2: return new RecentPaymentDetails_Abandoned(ptr);
24                         default:
25                                 throw new ArgumentException("Impossible enum variant");
26                 }
27         }
28
29         /** A RecentPaymentDetails of type Pending */
30         public class RecentPaymentDetails_Pending : RecentPaymentDetails {
31                 /**
32                  * Hash of the payment that is currently being sent but has yet to be fulfilled or
33                  * abandoned.
34                  */
35                 public byte[] payment_hash;
36                 /**
37                  * Total amount (in msat, excluding fees) across all paths for this payment,
38                  * not just the amount currently inflight.
39                  */
40                 public long total_msat;
41                 internal RecentPaymentDetails_Pending(long ptr) : base(null, ptr) {
42                         this.payment_hash = bindings.LDKRecentPaymentDetails_Pending_get_payment_hash(ptr);
43                         this.total_msat = bindings.LDKRecentPaymentDetails_Pending_get_total_msat(ptr);
44                 }
45         }
46         /** A RecentPaymentDetails of type Fulfilled */
47         public class RecentPaymentDetails_Fulfilled : RecentPaymentDetails {
48                 /**
49                  * Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`]
50                  * made before LDK version 0.0.104.
51                  */
52                 public Option_PaymentHashZ payment_hash;
53                 internal RecentPaymentDetails_Fulfilled(long ptr) : base(null, ptr) {
54                         long payment_hash = bindings.LDKRecentPaymentDetails_Fulfilled_get_payment_hash(ptr);
55                         org.ldk.structs.Option_PaymentHashZ payment_hash_hu_conv = org.ldk.structs.Option_PaymentHashZ.constr_from_ptr(payment_hash);
56                         if (payment_hash_hu_conv != null) { payment_hash_hu_conv.ptrs_to.AddLast(this); };
57                         this.payment_hash = payment_hash_hu_conv;
58                 }
59         }
60         /** A RecentPaymentDetails of type Abandoned */
61         public class RecentPaymentDetails_Abandoned : RecentPaymentDetails {
62                 /**
63                  * Hash of the payment that we have given up trying to send.
64                  */
65                 public byte[] payment_hash;
66                 internal RecentPaymentDetails_Abandoned(long ptr) : base(null, ptr) {
67                         this.payment_hash = bindings.LDKRecentPaymentDetails_Abandoned_get_payment_hash(ptr);
68                 }
69         }
70         internal long clone_ptr() {
71                 long ret = bindings.RecentPaymentDetails_clone_ptr(this.ptr);
72                 GC.KeepAlive(this);
73                 return ret;
74         }
75
76         /**
77          * Creates a copy of the RecentPaymentDetails
78          */
79         public RecentPaymentDetails clone() {
80                 long ret = bindings.RecentPaymentDetails_clone(this.ptr);
81                 GC.KeepAlive(this);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
84                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
85                 return ret_hu_conv;
86         }
87
88         /**
89          * Utility method to constructs a new Pending-variant RecentPaymentDetails
90          */
91         public static RecentPaymentDetails pending(byte[] payment_hash, long total_msat) {
92                 long ret = bindings.RecentPaymentDetails_pending(InternalUtils.check_arr_len(payment_hash, 32), total_msat);
93                 GC.KeepAlive(payment_hash);
94                 GC.KeepAlive(total_msat);
95                 if (ret >= 0 && ret <= 4096) { return null; }
96                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
97                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Utility method to constructs a new Fulfilled-variant RecentPaymentDetails
103          */
104         public static RecentPaymentDetails fulfilled(org.ldk.structs.Option_PaymentHashZ payment_hash) {
105                 long ret = bindings.RecentPaymentDetails_fulfilled(payment_hash.ptr);
106                 GC.KeepAlive(payment_hash);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_hash); };
111                 return ret_hu_conv;
112         }
113
114         /**
115          * Utility method to constructs a new Abandoned-variant RecentPaymentDetails
116          */
117         public static RecentPaymentDetails abandoned(byte[] payment_hash) {
118                 long ret = bindings.RecentPaymentDetails_abandoned(InternalUtils.check_arr_len(payment_hash, 32));
119                 GC.KeepAlive(payment_hash);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
123                 return ret_hu_conv;
124         }
125
126 }
127 } } }