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 [`Invoice`] 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 * [`Invoice`]: crate::offers::invoice::Invoice
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_DurationZ 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_DurationZ ret_hu_conv = org.ldk.structs.Option_DurationZ.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 * 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.
88 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
101 * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender
102 * privacy by obfuscating its node id.
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;
115 return ret_conv_13_arr;
119 * An unpredictable series of bytes, typically containing information about the derivation of
122 * [`payer_id`]: Self::payer_id
124 public byte[] metadata() {
125 byte[] ret = bindings.Refund_metadata(this.ptr);
126 Reference.reachabilityFence(this);
131 * A chain that the refund is valid for.
133 public byte[] chain() {
134 byte[] ret = bindings.Refund_chain(this.ptr);
135 Reference.reachabilityFence(this);
140 * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]).
142 * [`chain`]: Self::chain
144 public long amount_msats() {
145 long ret = bindings.Refund_amount_msats(this.ptr);
146 Reference.reachabilityFence(this);
151 * Features pertaining to requesting an invoice.
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); };
163 * The quantity of an item that refund is for.
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); };
175 * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly
178 * [`paths`]: Self::paths
180 public byte[] payer_id() {
181 byte[] ret = bindings.Refund_payer_id(this.ptr);
182 Reference.reachabilityFence(this);
187 * Payer provided note to include in the invoice.
189 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
202 * Serialize the Refund object into a byte array which can be read by Refund_read
204 public byte[] write() {
205 byte[] ret = bindings.Refund_write(this.ptr);
206 Reference.reachabilityFence(this);