[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / VerifiedInvoiceRequest.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  * An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different
11  * ways to respond depending on whether the signing keys were derived.
12  */
13 public class VerifiedInvoiceRequest : CommonBase {
14         internal VerifiedInvoiceRequest(object _dummy, long ptr) : base(ptr) { }
15         ~VerifiedInvoiceRequest() {
16                 if (ptr != 0) { bindings.VerifiedInvoiceRequest_free(ptr); }
17         }
18
19         /**
20          * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
21          */
22         public OfferId get_offer_id() {
23                 long ret = bindings.VerifiedInvoiceRequest_get_offer_id(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 org.ldk.structs.OfferId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferId(null, ret); }
27                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
28                 return ret_hu_conv;
29         }
30
31         /**
32          * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made.
33          */
34         public void set_offer_id(org.ldk.structs.OfferId val) {
35                 bindings.VerifiedInvoiceRequest_set_offer_id(this.ptr, val.ptr);
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38                 if (this != null) { this.ptrs_to.AddLast(val); };
39         }
40
41         /**
42          * Keys used for signing a [`Bolt12Invoice`] if they can be derived.
43          * 
44          * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
45          * [`respond_with`].
46          * 
47          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
48          * [`respond_using_derived_keys`]: Self::respond_using_derived_keys
49          * [`respond_with`]: Self::respond_with
50          */
51         public Option_SecretKeyZ get_keys() {
52                 long ret = bindings.VerifiedInvoiceRequest_get_keys(this.ptr);
53                 GC.KeepAlive(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 org.ldk.structs.Option_SecretKeyZ ret_hu_conv = org.ldk.structs.Option_SecretKeyZ.constr_from_ptr(ret);
56                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
57                 return ret_hu_conv;
58         }
59
60         /**
61          * Keys used for signing a [`Bolt12Invoice`] if they can be derived.
62          * 
63          * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call
64          * [`respond_with`].
65          * 
66          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
67          * [`respond_using_derived_keys`]: Self::respond_using_derived_keys
68          * [`respond_with`]: Self::respond_with
69          */
70         public void set_keys(org.ldk.structs.Option_SecretKeyZ val) {
71                 bindings.VerifiedInvoiceRequest_set_keys(this.ptr, val.ptr);
72                 GC.KeepAlive(this);
73                 GC.KeepAlive(val);
74                 if (this != null) { this.ptrs_to.AddLast(val); };
75         }
76
77         internal long clone_ptr() {
78                 long ret = bindings.VerifiedInvoiceRequest_clone_ptr(this.ptr);
79                 GC.KeepAlive(this);
80                 return ret;
81         }
82
83         /**
84          * Creates a copy of the VerifiedInvoiceRequest
85          */
86         public VerifiedInvoiceRequest clone() {
87                 long ret = bindings.VerifiedInvoiceRequest_clone(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.VerifiedInvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.VerifiedInvoiceRequest(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet).
97          * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats)
98          * for the selected chain.
99          */
100         public byte[][] chains() {
101                 long ret = bindings.VerifiedInvoiceRequest_chains(this.ptr);
102                 GC.KeepAlive(this);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
105                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
106                 for (int i = 0; i < ret_conv_8_len; i++) {
107                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
108                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
109                         ret_conv_8_arr[i] = ret_conv_8_conv;
110                 }
111                 bindings.free_buffer(ret);
112                 return ret_conv_8_arr;
113         }
114
115         /**
116          * Opaque bytes set by the originator. Useful for authentication and validating fields since it
117          * is reflected in `invoice_request` messages along with all the other fields from the `offer`.
118          */
119         public Option_CVec_u8ZZ metadata() {
120                 long ret = bindings.VerifiedInvoiceRequest_metadata(this.ptr);
121                 GC.KeepAlive(this);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
125                 return ret_hu_conv;
126         }
127
128         /**
129          * The minimum amount required for a successful payment of a single item.
130          */
131         public Option_AmountZ amount() {
132                 long ret = bindings.VerifiedInvoiceRequest_amount(this.ptr);
133                 GC.KeepAlive(this);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.Option_AmountZ ret_hu_conv = org.ldk.structs.Option_AmountZ.constr_from_ptr(ret);
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
137                 return ret_hu_conv;
138         }
139
140         /**
141          * A complete description of the purpose of the payment. Intended to be displayed to the user
142          * but with the caveat that it has not been verified in any way.
143          * 
144          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
145          */
146         public PrintableString description() {
147                 long ret = bindings.VerifiedInvoiceRequest_description(this.ptr);
148                 GC.KeepAlive(this);
149                 if (ret >= 0 && ret <= 4096) { return null; }
150                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
151                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Features pertaining to the offer.
157          */
158         public OfferFeatures offer_features() {
159                 long ret = bindings.VerifiedInvoiceRequest_offer_features(this.ptr);
160                 GC.KeepAlive(this);
161                 if (ret >= 0 && ret <= 4096) { return null; }
162                 org.ldk.structs.OfferFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferFeatures(null, ret); }
163                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
164                 return ret_hu_conv;
165         }
166
167         /**
168          * Duration since the Unix epoch when an invoice should no longer be requested.
169          * 
170          * If `None`, the offer does not expire.
171          */
172         public Option_u64Z absolute_expiry() {
173                 long ret = bindings.VerifiedInvoiceRequest_absolute_expiry(this.ptr);
174                 GC.KeepAlive(this);
175                 if (ret >= 0 && ret <= 4096) { return null; }
176                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
177                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
178                 return ret_hu_conv;
179         }
180
181         /**
182          * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be
183          * displayed to the user but with the caveat that it has not been verified in any way.
184          * 
185          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
186          */
187         public PrintableString issuer() {
188                 long ret = bindings.VerifiedInvoiceRequest_issuer(this.ptr);
189                 GC.KeepAlive(this);
190                 if (ret >= 0 && ret <= 4096) { return null; }
191                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
192                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
193                 return ret_hu_conv;
194         }
195
196         /**
197          * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide
198          * recipient privacy by obfuscating its node id.
199          */
200         public BlindedPath[] paths() {
201                 long ret = bindings.VerifiedInvoiceRequest_paths(this.ptr);
202                 GC.KeepAlive(this);
203                 if (ret >= 0 && ret <= 4096) { return null; }
204                 int ret_conv_13_len = InternalUtils.getArrayLength(ret);
205                 BlindedPath[] ret_conv_13_arr = new BlindedPath[ret_conv_13_len];
206                 for (int n = 0; n < ret_conv_13_len; n++) {
207                         long ret_conv_13 = InternalUtils.getU64ArrayElem(ret, n);
208                         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); }
209                         if (ret_conv_13_hu_conv != null) { ret_conv_13_hu_conv.ptrs_to.AddLast(this); };
210                         ret_conv_13_arr[n] = ret_conv_13_hu_conv;
211                 }
212                 bindings.free_buffer(ret);
213                 return ret_conv_13_arr;
214         }
215
216         /**
217          * The quantity of items supported.
218          */
219         public Quantity supported_quantity() {
220                 long ret = bindings.VerifiedInvoiceRequest_supported_quantity(this.ptr);
221                 GC.KeepAlive(this);
222                 if (ret >= 0 && ret <= 4096) { return null; }
223                 org.ldk.structs.Quantity ret_hu_conv = org.ldk.structs.Quantity.constr_from_ptr(ret);
224                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
225                 return ret_hu_conv;
226         }
227
228         /**
229          * The public key used by the recipient to sign invoices.
230          * 
231          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
232          */
233         public byte[] signing_pubkey() {
234                 long ret = bindings.VerifiedInvoiceRequest_signing_pubkey(this.ptr);
235                 GC.KeepAlive(this);
236                 if (ret >= 0 && ret <= 4096) { return null; }
237                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
238                 return ret_conv;
239         }
240
241         /**
242          * An unpredictable series of bytes, typically containing information about the derivation of
243          * [`payer_id`].
244          * 
245          * [`payer_id`]: Self::payer_id
246          */
247         public byte[] payer_metadata() {
248                 long ret = bindings.VerifiedInvoiceRequest_payer_metadata(this.ptr);
249                 GC.KeepAlive(this);
250                 if (ret >= 0 && ret <= 4096) { return null; }
251                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
252                 return ret_conv;
253         }
254
255         /**
256          * A chain from [`Offer::chains`] that the offer is valid for.
257          */
258         public byte[] chain() {
259                 long ret = bindings.VerifiedInvoiceRequest_chain(this.ptr);
260                 GC.KeepAlive(this);
261                 if (ret >= 0 && ret <= 4096) { return null; }
262                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
263                 return ret_conv;
264         }
265
266         /**
267          * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
268          * must be greater than or equal to [`Offer::amount`], converted if necessary.
269          * 
270          * [`chain`]: Self::chain
271          */
272         public Option_u64Z amount_msats() {
273                 long ret = bindings.VerifiedInvoiceRequest_amount_msats(this.ptr);
274                 GC.KeepAlive(this);
275                 if (ret >= 0 && ret <= 4096) { return null; }
276                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
277                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
278                 return ret_hu_conv;
279         }
280
281         /**
282          * Features pertaining to requesting an invoice.
283          */
284         public InvoiceRequestFeatures invoice_request_features() {
285                 long ret = bindings.VerifiedInvoiceRequest_invoice_request_features(this.ptr);
286                 GC.KeepAlive(this);
287                 if (ret >= 0 && ret <= 4096) { return null; }
288                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
289                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
290                 return ret_hu_conv;
291         }
292
293         /**
294          * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
295          */
296         public Option_u64Z quantity() {
297                 long ret = bindings.VerifiedInvoiceRequest_quantity(this.ptr);
298                 GC.KeepAlive(this);
299                 if (ret >= 0 && ret <= 4096) { return null; }
300                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
301                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
302                 return ret_hu_conv;
303         }
304
305         /**
306          * A possibly transient pubkey used to sign the invoice request.
307          */
308         public byte[] payer_id() {
309                 long ret = bindings.VerifiedInvoiceRequest_payer_id(this.ptr);
310                 GC.KeepAlive(this);
311                 if (ret >= 0 && ret <= 4096) { return null; }
312                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
313                 return ret_conv;
314         }
315
316         /**
317          * A payer-provided note which will be seen by the recipient and reflected back in the invoice
318          * response.
319          * 
320          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
321          */
322         public PrintableString payer_note() {
323                 long ret = bindings.VerifiedInvoiceRequest_payer_note(this.ptr);
324                 GC.KeepAlive(this);
325                 if (ret >= 0 && ret <= 4096) { return null; }
326                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
327                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
328                 return ret_hu_conv;
329         }
330
331         /**
332          * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the
333          * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time.
334          * 
335          * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned
336          * creation time is used for the `created_at` parameter.
337          * 
338          * [`Duration`]: core::time::Duration
339          */
340         public Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ respond_with(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash) {
341                 long ret = bindings.VerifiedInvoiceRequest_respond_with(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
342                 GC.KeepAlive(this);
343                 GC.KeepAlive(payment_paths);
344                 GC.KeepAlive(payment_hash);
345                 if (ret >= 0 && ret <= 4096) { return null; }
346                 Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
347                 return ret_hu_conv;
348         }
349
350         /**
351          * Creates an [`InvoiceBuilder`] for the request with the given required fields.
352          * 
353          * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after
354          * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds
355          * where [`std::time::SystemTime`] is not available.
356          * 
357          * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment
358          * for the invoice.
359          * 
360          * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It
361          * must contain one or more elements ordered from most-preferred to least-preferred, if there's
362          * a preference. Note, however, that any privacy is lost if a public node id was used for
363          * [`Offer::signing_pubkey`].
364          * 
365          * Errors if the request contains unknown required features.
366          * 
367          * # Note
368          * 
369          * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`],
370          * then use [`InvoiceRequest::verify`] and [`VerifiedInvoiceRequest`] methods instead.
371          * 
372          * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at
373          * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey
374          */
375         public Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ respond_with_no_std(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash, long created_at) {
376                 long ret = bindings.VerifiedInvoiceRequest_respond_with_no_std(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), created_at);
377                 GC.KeepAlive(this);
378                 GC.KeepAlive(payment_paths);
379                 GC.KeepAlive(payment_hash);
380                 GC.KeepAlive(created_at);
381                 if (ret >= 0 && ret <= 4096) { return null; }
382                 Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
383                 return ret_hu_conv;
384         }
385
386         /**
387          * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
388          * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
389          * the same [`ExpandedKey`] as the one used to create the offer.
390          * 
391          * See [`InvoiceRequest::respond_with`] for further details.
392          * 
393          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
394          */
395         public Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ respond_using_derived_keys(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash) {
396                 long ret = bindings.VerifiedInvoiceRequest_respond_using_derived_keys(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
397                 GC.KeepAlive(this);
398                 GC.KeepAlive(payment_paths);
399                 GC.KeepAlive(payment_hash);
400                 if (ret >= 0 && ret <= 4096) { return null; }
401                 Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
402                 return ret_hu_conv;
403         }
404
405         /**
406          * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses
407          * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use
408          * the same [`ExpandedKey`] as the one used to create the offer.
409          * 
410          * See [`InvoiceRequest::respond_with_no_std`] for further details.
411          * 
412          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
413          */
414         public Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ respond_using_derived_keys_no_std(TwoTuple_BlindedPayInfoBlindedPathZ[] payment_paths, byte[] payment_hash, long created_at) {
415                 long ret = bindings.VerifiedInvoiceRequest_respond_using_derived_keys_no_std(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(payment_paths, payment_paths_conv_37 => payment_paths_conv_37.ptr)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), created_at);
416                 GC.KeepAlive(this);
417                 GC.KeepAlive(payment_paths);
418                 GC.KeepAlive(payment_hash);
419                 GC.KeepAlive(created_at);
420                 if (ret >= 0 && ret <= 4096) { return null; }
421                 Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
422                 return ret_hu_conv;
423         }
424
425 }
426 } } }