[Java] Update auto-generated bindings to 0.0.117
[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          * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be
86          * displayed to the user but with the caveat that it has not been verified in any way.
87          * 
88          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
89          */
90         @Nullable
91         public PrintableString issuer() {
92                 long ret = bindings.Refund_issuer(this.ptr);
93                 Reference.reachabilityFence(this);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
97                 return ret_hu_conv;
98         }
99
100         /**
101          * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender
102          * privacy by obfuscating its node id.
103          */
104         public BlindedPath[] paths() {
105                 long[] ret = bindings.Refund_paths(this.ptr);
106                 Reference.reachabilityFence(this);
107                 int ret_conv_13_len = ret.length;
108                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
109                 for (int n = 0; n < ret_conv_13_len; n++) {
110                         long ret_conv_13 = ret[n];
111                         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); }
112                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.add(this); };
113                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
114                 }
115                 return ret_conv_13_arr;
116         }
117
118         /**
119          * An unpredictable series of bytes, typically containing information about the derivation of
120          * [`payer_id`].
121          * 
122          * [`payer_id`]: Self::payer_id
123          */
124         public byte[] payer_metadata() {
125                 byte[] ret = bindings.Refund_payer_metadata(this.ptr);
126                 Reference.reachabilityFence(this);
127                 return ret;
128         }
129
130         /**
131          * A chain that the refund is valid for.
132          */
133         public byte[] chain() {
134                 byte[] ret = bindings.Refund_chain(this.ptr);
135                 Reference.reachabilityFence(this);
136                 return ret;
137         }
138
139         /**
140          * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]).
141          * 
142          * [`chain`]: Self::chain
143          */
144         public long amount_msats() {
145                 long ret = bindings.Refund_amount_msats(this.ptr);
146                 Reference.reachabilityFence(this);
147                 return ret;
148         }
149
150         /**
151          * Features pertaining to requesting an invoice.
152          */
153         public InvoiceRequestFeatures features() {
154                 long ret = bindings.Refund_features(this.ptr);
155                 Reference.reachabilityFence(this);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
159                 return ret_hu_conv;
160         }
161
162         /**
163          * The quantity of an item that refund is for.
164          */
165         public Option_u64Z quantity() {
166                 long ret = bindings.Refund_quantity(this.ptr);
167                 Reference.reachabilityFence(this);
168                 if (ret >= 0 && ret <= 4096) { return null; }
169                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
170                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
171                 return ret_hu_conv;
172         }
173
174         /**
175          * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly
176          * transient pubkey.
177          * 
178          * [`paths`]: Self::paths
179          */
180         public byte[] payer_id() {
181                 byte[] ret = bindings.Refund_payer_id(this.ptr);
182                 Reference.reachabilityFence(this);
183                 return ret;
184         }
185
186         /**
187          * Payer provided note to include in the invoice.
188          * 
189          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
190          */
191         @Nullable
192         public PrintableString payer_note() {
193                 long ret = bindings.Refund_payer_note(this.ptr);
194                 Reference.reachabilityFence(this);
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
197                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
198                 return ret_hu_conv;
199         }
200
201         /**
202          * Serialize the Refund object into a byte array which can be read by Refund_read
203          */
204         public byte[] write() {
205                 byte[] ret = bindings.Refund_write(this.ptr);
206                 Reference.reachabilityFence(this);
207                 return ret;
208         }
209
210         /**
211          * Read a Refund object from a string
212          */
213         public static Result_RefundBolt12ParseErrorZ from_str(java.lang.String s) {
214                 long ret = bindings.Refund_from_str(s);
215                 Reference.reachabilityFence(s);
216                 if (ret >= 0 && ret <= 4096) { return null; }
217                 Result_RefundBolt12ParseErrorZ ret_hu_conv = Result_RefundBolt12ParseErrorZ.constr_from_ptr(ret);
218                 return ret_hu_conv;
219         }
220
221 }