1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`].
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
18 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
19 * [`Offer`]: crate::offers::offer::Offer
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 {
27 if (ptr != 0) { bindings.Refund_free(ptr); }
31 long ret = bindings.Refund_clone_ptr(this.ptr);
32 Reference.reachabilityFence(this);
37 * Creates a copy of the Refund
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); };
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.
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); };
62 * Duration since the Unix epoch when an invoice should no longer be sent.
64 * If `None`, the refund does not expire.
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); };
76 * Whether the refund has expired.
78 public boolean is_expired() {
79 boolean ret = bindings.Refund_is_expired(this.ptr);
80 Reference.reachabilityFence(this);
85 * Whether the refund has expired given the duration since the Unix epoch.
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);
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.
98 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
111 * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender
112 * privacy by obfuscating its node id.
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;
125 return ret_conv_13_arr;
129 * An unpredictable series of bytes, typically containing information about the derivation of
132 * [`payer_id`]: Self::payer_id
134 public byte[] payer_metadata() {
135 byte[] ret = bindings.Refund_payer_metadata(this.ptr);
136 Reference.reachabilityFence(this);
141 * A chain that the refund is valid for.
143 public byte[] chain() {
144 byte[] ret = bindings.Refund_chain(this.ptr);
145 Reference.reachabilityFence(this);
150 * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]).
152 * [`chain`]: Self::chain
154 public long amount_msats() {
155 long ret = bindings.Refund_amount_msats(this.ptr);
156 Reference.reachabilityFence(this);
161 * Features pertaining to requesting an invoice.
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); };
173 * The quantity of an item that refund is for.
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); };
185 * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly
188 * [`paths`]: Self::paths
190 public byte[] payer_id() {
191 byte[] ret = bindings.Refund_payer_id(this.ptr);
192 Reference.reachabilityFence(this);
197 * Payer provided note to include in the invoice.
199 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
212 * Generates a non-cryptographic 64-bit hash of the Refund.
215 long ret = bindings.Refund_hash(this.ptr);
216 Reference.reachabilityFence(this);
220 @Override public int hashCode() {
221 return (int)this.hash();
224 * Serialize the Refund object into a byte array which can be read by Refund_read
226 public byte[] write() {
227 byte[] ret = bindings.Refund_write(this.ptr);
228 Reference.reachabilityFence(this);
233 * Read a Refund object from a string
235 public static Result_RefundBolt12ParseErrorZ from_str(java.lang.String s) {
236 long ret = bindings.Refund_from_str(s);
237 Reference.reachabilityFence(s);
238 if (ret >= 0 && ret <= 4096) { return null; }
239 Result_RefundBolt12ParseErrorZ ret_hu_conv = Result_RefundBolt12ParseErrorZ.constr_from_ptr(ret);