[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / Refund.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  * A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`].
13  * 
14  * Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to
15  * recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a
16  * bitcoin ATM.
17  * 
18  * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
19  * [`Offer`]: crate::offers::offer::Offer
20  */
21 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
22 public class Refund extends CommonBase {
23         Refund(Object _dummy, long ptr) { super(ptr); }
24         @Override @SuppressWarnings("deprecation")
25         protected void finalize() throws Throwable {
26                 super.finalize();
27                 if (ptr != 0) { bindings.Refund_free(ptr); }
28         }
29
30         long clone_ptr() {
31                 long ret = bindings.Refund_clone_ptr(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * Creates a copy of the Refund
38          */
39         public Refund clone() {
40                 long ret = bindings.Refund_clone(this.ptr);
41                 Reference.reachabilityFence(this);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 org.ldk.structs.Refund ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Refund(null, ret); }
44                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
45                 return ret_hu_conv;
46         }
47
48         /**
49          * A complete description of the purpose of the refund. Intended to be displayed to the user
50          * but with the caveat that it has not been verified in any way.
51          */
52         public PrintableString description() {
53                 long ret = bindings.Refund_description(this.ptr);
54                 Reference.reachabilityFence(this);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
57                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Duration since the Unix epoch when an invoice should no longer be sent.
63          * 
64          * If `None`, the refund does not expire.
65          */
66         public Option_u64Z absolute_expiry() {
67                 long ret = bindings.Refund_absolute_expiry(this.ptr);
68                 Reference.reachabilityFence(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
71                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
72                 return ret_hu_conv;
73         }
74
75         /**
76          * Whether the refund has expired.
77          */
78         public boolean is_expired() {
79                 boolean ret = bindings.Refund_is_expired(this.ptr);
80                 Reference.reachabilityFence(this);
81                 return ret;
82         }
83
84         /**
85          * Whether the refund has expired given the duration since the Unix epoch.
86          */
87         public boolean is_expired_no_std(long duration_since_epoch) {
88                 boolean ret = bindings.Refund_is_expired_no_std(this.ptr, duration_since_epoch);
89                 Reference.reachabilityFence(this);
90                 Reference.reachabilityFence(duration_since_epoch);
91                 return ret;
92         }
93
94         /**
95          * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be
96          * displayed to the user but with the caveat that it has not been verified in any way.
97          * 
98          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
99          */
100         @Nullable
101         public PrintableString issuer() {
102                 long ret = bindings.Refund_issuer(this.ptr);
103                 Reference.reachabilityFence(this);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
107                 return ret_hu_conv;
108         }
109
110         /**
111          * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender
112          * privacy by obfuscating its node id.
113          */
114         public BlindedPath[] paths() {
115                 long[] ret = bindings.Refund_paths(this.ptr);
116                 Reference.reachabilityFence(this);
117                 int ret_conv_13_len = ret.length;
118                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
119                 for (int n = 0; n < ret_conv_13_len; n++) {
120                         long ret_conv_13 = ret[n];
121                         org.ldk.structs.BlindedPath ret_conv_13_hu_conv = null; if (ret_conv_13 < 0 || ret_conv_13 > 4096) { ret_conv_13_hu_conv = new org.ldk.structs.BlindedPath(null, ret_conv_13); }
122                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
123                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
124                 }
125                 return ret_conv_13_arr;
126         }
127
128         /**
129          * An unpredictable series of bytes, typically containing information about the derivation of
130          * [`payer_id`].
131          * 
132          * [`payer_id`]: Self::payer_id
133          */
134         public byte[] payer_metadata() {
135                 byte[] ret = bindings.Refund_payer_metadata(this.ptr);
136                 Reference.reachabilityFence(this);
137                 return ret;
138         }
139
140         /**
141          * A chain that the refund is valid for.
142          */
143         public byte[] chain() {
144                 byte[] ret = bindings.Refund_chain(this.ptr);
145                 Reference.reachabilityFence(this);
146                 return ret;
147         }
148
149         /**
150          * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]).
151          * 
152          * [`chain`]: Self::chain
153          */
154         public long amount_msats() {
155                 long ret = bindings.Refund_amount_msats(this.ptr);
156                 Reference.reachabilityFence(this);
157                 return ret;
158         }
159
160         /**
161          * Features pertaining to requesting an invoice.
162          */
163         public InvoiceRequestFeatures features() {
164                 long ret = bindings.Refund_features(this.ptr);
165                 Reference.reachabilityFence(this);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
168                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
169                 return ret_hu_conv;
170         }
171
172         /**
173          * The quantity of an item that refund is for.
174          */
175         public Option_u64Z quantity() {
176                 long ret = bindings.Refund_quantity(this.ptr);
177                 Reference.reachabilityFence(this);
178                 if (ret >= 0 && ret <= 4096) { return null; }
179                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
181                 return ret_hu_conv;
182         }
183
184         /**
185          * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly
186          * transient pubkey.
187          * 
188          * [`paths`]: Self::paths
189          */
190         public byte[] payer_id() {
191                 byte[] ret = bindings.Refund_payer_id(this.ptr);
192                 Reference.reachabilityFence(this);
193                 return ret;
194         }
195
196         /**
197          * Payer provided note to include in the invoice.
198          * 
199          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
200          */
201         @Nullable
202         public PrintableString payer_note() {
203                 long ret = bindings.Refund_payer_note(this.ptr);
204                 Reference.reachabilityFence(this);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
207                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
208                 return ret_hu_conv;
209         }
210
211         /**
212          * Serialize the Refund object into a byte array which can be read by Refund_read
213          */
214         public byte[] write() {
215                 byte[] ret = bindings.Refund_write(this.ptr);
216                 Reference.reachabilityFence(this);
217                 return ret;
218         }
219
220         /**
221          * Read a Refund object from a string
222          */
223         public static Result_RefundBolt12ParseErrorZ from_str(java.lang.String s) {
224                 long ret = bindings.Refund_from_str(s);
225                 Reference.reachabilityFence(s);
226                 if (ret >= 0 && ret <= 4096) { return null; }
227                 Result_RefundBolt12ParseErrorZ ret_hu_conv = Result_RefundBolt12ParseErrorZ.constr_from_ptr(ret);
228                 return ret_hu_conv;
229         }
230
231 }