[Java] Update auto-generated bindings to 0.0.117
[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.AwaitingInvoice.class) {
26                         return new AwaitingInvoice(ptr, (bindings.LDKRecentPaymentDetails.AwaitingInvoice)raw_val);
27                 }
28                 if (raw_val.getClass() == bindings.LDKRecentPaymentDetails.Pending.class) {
29                         return new Pending(ptr, (bindings.LDKRecentPaymentDetails.Pending)raw_val);
30                 }
31                 if (raw_val.getClass() == bindings.LDKRecentPaymentDetails.Fulfilled.class) {
32                         return new Fulfilled(ptr, (bindings.LDKRecentPaymentDetails.Fulfilled)raw_val);
33                 }
34                 if (raw_val.getClass() == bindings.LDKRecentPaymentDetails.Abandoned.class) {
35                         return new Abandoned(ptr, (bindings.LDKRecentPaymentDetails.Abandoned)raw_val);
36                 }
37                 assert false; return null; // Unreachable without extending the (internal) bindings interface
38         }
39
40         /**
41          * When an invoice was requested and thus a payment has not yet been sent.
42          */
43         public final static class AwaitingInvoice extends RecentPaymentDetails {
44                 /**
45                  * A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
46                  * a payment and ensure idempotency in LDK.
47                 */
48                 public final byte[] payment_id;
49                 private AwaitingInvoice(long ptr, bindings.LDKRecentPaymentDetails.AwaitingInvoice obj) {
50                         super(null, ptr);
51                         this.payment_id = obj.payment_id;
52                 }
53         }
54         /**
55          * When a payment is still being sent and awaiting successful delivery.
56          */
57         public final static class Pending extends RecentPaymentDetails {
58                 /**
59                  * A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
60                  * a payment and ensure idempotency in LDK.
61                 */
62                 public final byte[] payment_id;
63                 /**
64                  * Hash of the payment that is currently being sent but has yet to be fulfilled or
65                  * abandoned.
66                 */
67                 public final byte[] payment_hash;
68                 /**
69                  * Total amount (in msat, excluding fees) across all paths for this payment,
70                  * not just the amount currently inflight.
71                 */
72                 public final long total_msat;
73                 private Pending(long ptr, bindings.LDKRecentPaymentDetails.Pending obj) {
74                         super(null, ptr);
75                         this.payment_id = obj.payment_id;
76                         this.payment_hash = obj.payment_hash;
77                         this.total_msat = obj.total_msat;
78                 }
79         }
80         /**
81          * When a pending payment is fulfilled, we continue tracking it until all pending HTLCs have
82          * been resolved. Upon receiving [`Event::PaymentSent`], we delay for a few minutes before the
83          * payment is removed from tracking.
84          */
85         public final static class Fulfilled extends RecentPaymentDetails {
86                 /**
87                  * A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
88                  * a payment and ensure idempotency in LDK.
89                 */
90                 public final byte[] payment_id;
91                 /**
92                  * Hash of the payment that was claimed. `None` for serializations of [`ChannelManager`]
93                  * made before LDK version 0.0.104.
94                 */
95                 public final org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash;
96                 private Fulfilled(long ptr, bindings.LDKRecentPaymentDetails.Fulfilled obj) {
97                         super(null, ptr);
98                         this.payment_id = obj.payment_id;
99                         long payment_hash = obj.payment_hash;
100                         org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash_hu_conv = org.ldk.structs.Option_ThirtyTwoBytesZ.constr_from_ptr(payment_hash);
101                         if (payment_hash_hu_conv != null) { payment_hash_hu_conv.ptrs_to.add(this); };
102                         this.payment_hash = payment_hash_hu_conv;
103                 }
104         }
105         /**
106          * After a payment's retries are exhausted per the provided [`Retry`], or it is explicitly
107          * abandoned via [`ChannelManager::abandon_payment`], it is marked as abandoned until all
108          * pending HTLCs for this payment resolve and an [`Event::PaymentFailed`] is generated.
109          */
110         public final static class Abandoned extends RecentPaymentDetails {
111                 /**
112                  * A user-provided identifier in [`ChannelManager::send_payment`] used to uniquely identify
113                  * a payment and ensure idempotency in LDK.
114                 */
115                 public final byte[] payment_id;
116                 /**
117                  * Hash of the payment that we have given up trying to send.
118                 */
119                 public final byte[] payment_hash;
120                 private Abandoned(long ptr, bindings.LDKRecentPaymentDetails.Abandoned obj) {
121                         super(null, ptr);
122                         this.payment_id = obj.payment_id;
123                         this.payment_hash = obj.payment_hash;
124                 }
125         }
126         long clone_ptr() {
127                 long ret = bindings.RecentPaymentDetails_clone_ptr(this.ptr);
128                 Reference.reachabilityFence(this);
129                 return ret;
130         }
131
132         /**
133          * Creates a copy of the RecentPaymentDetails
134          */
135         public RecentPaymentDetails clone() {
136                 long ret = bindings.RecentPaymentDetails_clone(this.ptr);
137                 Reference.reachabilityFence(this);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
140                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
141                 return ret_hu_conv;
142         }
143
144         /**
145          * Utility method to constructs a new AwaitingInvoice-variant RecentPaymentDetails
146          */
147         public static RecentPaymentDetails awaiting_invoice(byte[] payment_id) {
148                 long ret = bindings.RecentPaymentDetails_awaiting_invoice(InternalUtils.check_arr_len(payment_id, 32));
149                 Reference.reachabilityFence(payment_id);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
152                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
153                 return ret_hu_conv;
154         }
155
156         /**
157          * Utility method to constructs a new Pending-variant RecentPaymentDetails
158          */
159         public static RecentPaymentDetails pending(byte[] payment_id, byte[] payment_hash, long total_msat) {
160                 long ret = bindings.RecentPaymentDetails_pending(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32), total_msat);
161                 Reference.reachabilityFence(payment_id);
162                 Reference.reachabilityFence(payment_hash);
163                 Reference.reachabilityFence(total_msat);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
166                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
167                 return ret_hu_conv;
168         }
169
170         /**
171          * Utility method to constructs a new Fulfilled-variant RecentPaymentDetails
172          */
173         public static RecentPaymentDetails fulfilled(byte[] payment_id, org.ldk.structs.Option_ThirtyTwoBytesZ payment_hash) {
174                 long ret = bindings.RecentPaymentDetails_fulfilled(InternalUtils.check_arr_len(payment_id, 32), payment_hash.ptr);
175                 Reference.reachabilityFence(payment_id);
176                 Reference.reachabilityFence(payment_hash);
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
179                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payment_hash); };
181                 return ret_hu_conv;
182         }
183
184         /**
185          * Utility method to constructs a new Abandoned-variant RecentPaymentDetails
186          */
187         public static RecentPaymentDetails abandoned(byte[] payment_id, byte[] payment_hash) {
188                 long ret = bindings.RecentPaymentDetails_abandoned(InternalUtils.check_arr_len(payment_id, 32), InternalUtils.check_arr_len(payment_hash, 32));
189                 Reference.reachabilityFence(payment_id);
190                 Reference.reachabilityFence(payment_hash);
191                 if (ret >= 0 && ret <= 4096) { return null; }
192                 org.ldk.structs.RecentPaymentDetails ret_hu_conv = org.ldk.structs.RecentPaymentDetails.constr_from_ptr(ret);
193                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
194                 return ret_hu_conv;
195         }
196
197 }