[Java] Update auto-generated Java bindings for 0.0.116
[ldk-java] / src / main / java / org / ldk / structs / RecentPaymentDetails.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments.
13  * These include payments that have yet to find a successful path, or have unresolved HTLCs.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class RecentPaymentDetails extends CommonBase {
17         private RecentPaymentDetails(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.RecentPaymentDetails_free(ptr); }
22         }
23         static RecentPaymentDetails constr_from_ptr(long ptr) {
24                 bindings.LDKRecentPaymentDetails raw_val = bindings.LDKRecentPaymentDetails_ref_from_ptr(ptr);
25                 if (raw_val.getClass() == bindings.LDKRecentPaymentDetails.Pending.class) {
26                         return new Pending(ptr, (bindings.LDKRecentPaymentDetails.Pending)raw_val);
27                 }
28                 if (raw_val.getClass() == bindings.LDKRecentPaymentDetails.Fulfilled.class) {
29                         return new Fulfilled(ptr, (bindings.LDKRecentPaymentDetails.Fulfilled)raw_val);
30                 }
31                 if (raw_val.getClass() == bindings.LDKRecentPaymentDetails.Abandoned.class) {
32                         return new Abandoned(ptr, (bindings.LDKRecentPaymentDetails.Abandoned)raw_val);
33                 }
34                 assert false; return null; // Unreachable without extending the (internal) bindings interface
35         }
36
37         /**
38          * When a payment is still being sent and awaiting successful delivery.
39          */
40         public final static class Pending extends RecentPaymentDetails {
41                 /**
42                  * Hash of the payment that is currently being sent but has yet to be fulfilled or
43                  * abandoned.
44                 */
45                 public final byte[] payment_hash;
46                 /**
47                  * Total amount (in msat, excluding fees) across all paths for this payment,
48                  * not just the amount currently inflight.
49                 */
50                 public final long total_msat;
51                 private Pending(long ptr, bindings.LDKRecentPaymentDetails.Pending obj) {
52                         super(null, ptr);
53                         this.payment_hash = obj.payment_hash;
54                         this.total_msat = obj.total_msat;
55                 }
56         }
57         /**
58          * When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have
59          * been resolved. Upon receiving [`Event::PaymentSent`], we delay for a few minutes before the
60          * payment is removed from tracking.
61          */
62         public final static class Fulfilled extends RecentPaymentDetails {
63                 /**
64                  * Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`]
65                  * made before LDK version 0.0.104.
66                 */
67                 public final org.ldk.structs.Option_PaymentHashZ payment_hash;
68                 private Fulfilled(long ptr, bindings.LDKRecentPaymentDetails.Fulfilled obj) {
69                         super(null, ptr);
70                         long payment_hash = obj.payment_hash;
71                         org.ldk.structs.Option_PaymentHashZ payment_hash_hu_conv = org.ldk.structs.Option_PaymentHashZ.constr_from_ptr(payment_hash);
72                         if (payment_hash_hu_conv != null) { payment_hash_hu_conv.ptrs_to.add(this); };
73                         this.payment_hash = payment_hash_hu_conv;
74                 }
75         }
76         /**
77          * After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly
78          * abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all
79          * pending HTLCs for this payment resolve and an [`Event::PaymentFailed`] is generated.
80          */
81         public final static class Abandoned extends RecentPaymentDetails {
82                 /**
83                  * Hash of the payment that we have given up trying to send.
84                 */
85                 public final byte[] payment_hash;
86                 private Abandoned(long ptr, bindings.LDKRecentPaymentDetails.Abandoned obj) {
87                         super(null, ptr);
88                         this.payment_hash = obj.payment_hash;
89                 }
90         }
91         long clone_ptr() {
92                 long ret = bindings.RecentPaymentDetails_clone_ptr(this.ptr);
93                 Reference.reachabilityFence(this);
94                 return ret;
95         }
96
97         /**
98          * Creates a copy of the RecentPaymentDetails
99          */
100         public RecentPaymentDetails clone() {
101                 long ret = bindings.RecentPaymentDetails_clone(this.ptr);
102                 Reference.reachabilityFence(this);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
105                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Utility method to constructs a new Pending-variant RecentPaymentDetails
111          */
112         public static RecentPaymentDetails pending(byte[] payment_hash, long total_msat) {
113                 long ret = bindings.RecentPaymentDetails_pending(InternalUtils.check_arr_len(payment_hash, 32), total_msat);
114                 Reference.reachabilityFence(payment_hash);
115                 Reference.reachabilityFence(total_msat);
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
118                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Utility method to constructs a new Fulfilled-variant RecentPaymentDetails
124          */
125         public static RecentPaymentDetails fulfilled(org.ldk.structs.Option_PaymentHashZ payment_hash) {
126                 long ret = bindings.RecentPaymentDetails_fulfilled(payment_hash.ptr);
127                 Reference.reachabilityFence(payment_hash);
128                 if (ret >= 0 && ret <= 4096) { return null; }
129                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
130                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
131                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
132                 return ret_hu_conv;
133         }
134
135         /**
136          * Utility method to constructs a new Abandoned-variant RecentPaymentDetails
137          */
138         public static RecentPaymentDetails abandoned(byte[] payment_hash) {
139                 long ret = bindings.RecentPaymentDetails_abandoned(InternalUtils.check_arr_len(payment_hash, 32));
140                 Reference.reachabilityFence(payment_hash);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
143                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
144                 return ret_hu_conv;
145         }
146
147 }