[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Refund.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`].
11  * 
12  * Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to
13  * recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a
14  * bitcoin ATM.
15  * 
16  * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
17  * [`Offer`]: crate::offers::offer::Offer
18  */
19 public class Refund : CommonBase {
20         internal Refund(object _dummy, long ptr) : base(ptr) { }
21         ~Refund() {
22                 if (ptr != 0) { bindings.Refund_free(ptr); }
23         }
24
25         internal long clone_ptr() {
26                 long ret = bindings.Refund_clone_ptr(this.ptr);
27                 GC.KeepAlive(this);
28                 return ret;
29         }
30
31         /**
32          * Creates a copy of the Refund
33          */
34         public Refund clone() {
35                 long ret = bindings.Refund_clone(this.ptr);
36                 GC.KeepAlive(this);
37                 if (ret >= 0 && ret <= 4096) { return null; }
38                 org.ldk.structs.Refund ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Refund(null, ret); }
39                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
40                 return ret_hu_conv;
41         }
42
43         /**
44          * A complete description of the purpose of the refund. Intended to be displayed to the user
45          * but with the caveat that it has not been verified in any way.
46          */
47         public PrintableString description() {
48                 long ret = bindings.Refund_description(this.ptr);
49                 GC.KeepAlive(this);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
52                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Duration since the Unix epoch when an invoice should no longer be sent.
58          * 
59          * If `None`, the refund does not expire.
60          */
61         public Option_u64Z absolute_expiry() {
62                 long ret = bindings.Refund_absolute_expiry(this.ptr);
63                 GC.KeepAlive(this);
64                 if (ret >= 0 && ret <= 4096) { return null; }
65                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
66                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
67                 return ret_hu_conv;
68         }
69
70         /**
71          * Whether the refund has expired.
72          */
73         public bool is_expired() {
74                 bool ret = bindings.Refund_is_expired(this.ptr);
75                 GC.KeepAlive(this);
76                 return ret;
77         }
78
79         /**
80          * Whether the refund has expired given the duration since the Unix epoch.
81          */
82         public bool is_expired_no_std(long duration_since_epoch) {
83                 bool ret = bindings.Refund_is_expired_no_std(this.ptr, duration_since_epoch);
84                 GC.KeepAlive(this);
85                 GC.KeepAlive(duration_since_epoch);
86                 return ret;
87         }
88
89         /**
90          * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be
91          * displayed to the user but with the caveat that it has not been verified in any way.
92          * 
93          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
94          */
95         public PrintableString issuer() {
96                 long ret = bindings.Refund_issuer(this.ptr);
97                 GC.KeepAlive(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender
106          * privacy by obfuscating its node id.
107          */
108         public BlindedPath[] paths() {
109                 long ret = bindings.Refund_paths(this.ptr);
110                 GC.KeepAlive(this);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 int ret_conv_13_len = InternalUtils.getArrayLength(ret);
113                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
114                 for (int n = 0; n < ret_conv_13_len; n++) {
115                         long ret_conv_13 = InternalUtils.getU64ArrayElem(ret, n);
116                         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); }
117                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
118                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
119                 }
120                 bindings.free_buffer(ret);
121                 return ret_conv_13_arr;
122         }
123
124         /**
125          * An unpredictable series of bytes, typically containing information about the derivation of
126          * [`payer_id`].
127          * 
128          * [`payer_id`]: Self::payer_id
129          */
130         public byte[] payer_metadata() {
131                 long ret = bindings.Refund_payer_metadata(this.ptr);
132                 GC.KeepAlive(this);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
135                 return ret_conv;
136         }
137
138         /**
139          * A chain that the refund is valid for.
140          */
141         public byte[] chain() {
142                 long ret = bindings.Refund_chain(this.ptr);
143                 GC.KeepAlive(this);
144                 if (ret >= 0 && ret <= 4096) { return null; }
145                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
146                 return ret_conv;
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                 GC.KeepAlive(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                 GC.KeepAlive(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.AddLast(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                 GC.KeepAlive(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.AddLast(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                 long ret = bindings.Refund_payer_id(this.ptr);
192                 GC.KeepAlive(this);
193                 if (ret >= 0 && ret <= 4096) { return null; }
194                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
195                 return ret_conv;
196         }
197
198         /**
199          * Payer provided note to include in the invoice.
200          * 
201          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
202          */
203         public PrintableString payer_note() {
204                 long ret = bindings.Refund_payer_note(this.ptr);
205                 GC.KeepAlive(this);
206                 if (ret >= 0 && ret <= 4096) { return null; }
207                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
208                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
209                 return ret_hu_conv;
210         }
211
212         /**
213          * Serialize the Refund object into a byte array which can be read by Refund_read
214          */
215         public byte[] write() {
216                 long ret = bindings.Refund_write(this.ptr);
217                 GC.KeepAlive(this);
218                 if (ret >= 0 && ret <= 4096) { return null; }
219                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
220                 return ret_conv;
221         }
222
223         /**
224          * Read a Refund object from a string
225          */
226         public static Result_RefundBolt12ParseErrorZ from_str(string s) {
227                 long ret = bindings.Refund_from_str(InternalUtils.encodeString(s));
228                 GC.KeepAlive(s);
229                 if (ret >= 0 && ret <= 4096) { return null; }
230                 Result_RefundBolt12ParseErrorZ ret_hu_conv = Result_RefundBolt12ParseErrorZ.constr_from_ptr(ret);
231                 return ret_hu_conv;
232         }
233
234 }
235 } } }