[C#] Update auto-generated files
[ldk-java] / c_sharp / src / org / ldk / structs / InvoiceRequest.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` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`].
11  * 
12  * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request
13  * specifies these such that its recipient can send an invoice for payment.
14  * 
15  * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
16  * [`Offer`]: crate::offers::offer::Offer
17  */
18 public class InvoiceRequest : CommonBase {
19         internal InvoiceRequest(object _dummy, long ptr) : base(ptr) { }
20         ~InvoiceRequest() {
21                 if (ptr != 0) { bindings.InvoiceRequest_free(ptr); }
22         }
23
24         internal long clone_ptr() {
25                 long ret = bindings.InvoiceRequest_clone_ptr(this.ptr);
26                 GC.KeepAlive(this);
27                 return ret;
28         }
29
30         /**
31          * Creates a copy of the InvoiceRequest
32          */
33         public InvoiceRequest clone() {
34                 long ret = bindings.InvoiceRequest_clone(this.ptr);
35                 GC.KeepAlive(this);
36                 if (ret >= 0 && ret <= 4096) { return null; }
37                 org.ldk.structs.InvoiceRequest ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequest(null, ret); }
38                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
39                 return ret_hu_conv;
40         }
41
42         /**
43          * An unpredictable series of bytes, typically containing information about the derivation of
44          * [`payer_id`].
45          * 
46          * [`payer_id`]: Self::payer_id
47          */
48         public byte[] metadata() {
49                 byte[] ret = bindings.InvoiceRequest_metadata(this.ptr);
50                 GC.KeepAlive(this);
51                 return ret;
52         }
53
54         /**
55          * A chain from [`Offer::chains`] that the offer is valid for.
56          */
57         public byte[] chain() {
58                 byte[] ret = bindings.InvoiceRequest_chain(this.ptr);
59                 GC.KeepAlive(this);
60                 return ret;
61         }
62
63         /**
64          * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which
65          * must be greater than or equal to [`Offer::amount`], converted if necessary.
66          * 
67          * [`chain`]: Self::chain
68          */
69         public Option_u64Z amount_msats() {
70                 long ret = bindings.InvoiceRequest_amount_msats(this.ptr);
71                 GC.KeepAlive(this);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Features pertaining to requesting an invoice.
80          */
81         public InvoiceRequestFeatures features() {
82                 long ret = bindings.InvoiceRequest_features(this.ptr);
83                 GC.KeepAlive(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.InvoiceRequestFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFeatures(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
92          */
93         public Option_u64Z quantity() {
94                 long ret = bindings.InvoiceRequest_quantity(this.ptr);
95                 GC.KeepAlive(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * A possibly transient pubkey used to sign the invoice request.
104          */
105         public byte[] payer_id() {
106                 byte[] ret = bindings.InvoiceRequest_payer_id(this.ptr);
107                 GC.KeepAlive(this);
108                 return ret;
109         }
110
111         /**
112          * A payer-provided note which will be seen by the recipient and reflected back in the invoice
113          * response.
114          * 
115          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
116          */
117         public PrintableString payer_note() {
118                 long ret = bindings.InvoiceRequest_payer_note(this.ptr);
119                 GC.KeepAlive(this);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.PrintableString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PrintableString(null, ret); }
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
123                 return ret_hu_conv;
124         }
125
126         /**
127          * Verifies that the request was for an offer created using the given key. Returns the derived
128          * keys need to sign an [`Bolt12Invoice`] for the request if they could be extracted from the
129          * metadata.
130          * 
131          * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
132          */
133         public Result_COption_KeyPairZNoneZ verify(org.ldk.structs.ExpandedKey key) {
134                 long ret = bindings.InvoiceRequest_verify(this.ptr, key == null ? 0 : key.ptr);
135                 GC.KeepAlive(this);
136                 GC.KeepAlive(key);
137                 if (ret >= 0 && ret <= 4096) { return null; }
138                 Result_COption_KeyPairZNoneZ ret_hu_conv = Result_COption_KeyPairZNoneZ.constr_from_ptr(ret);
139                 if (this != null) { this.ptrs_to.AddLast(key); };
140                 return ret_hu_conv;
141         }
142
143         /**
144          * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read
145          */
146         public byte[] write() {
147                 byte[] ret = bindings.InvoiceRequest_write(this.ptr);
148                 GC.KeepAlive(this);
149                 return ret;
150         }
151
152 }
153 } } }