[C#] Add marshaling logic for array C# -> C conversion
[ldk-java] / c_sharp / src / org / ldk / structs / RawInvoice.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  * Represents an syntactically correct Invoice for a payment on the lightning network,
11  * but without the signature information.
12  * De- and encoding should not lead to information loss but may lead to different hashes.
13  * 
14  * For methods without docs see the corresponding methods in `Invoice`.
15  */
16 public class RawInvoice : CommonBase {
17         internal RawInvoice(object _dummy, long ptr) : base(ptr) { }
18         ~RawInvoice() {
19                 if (ptr != 0) { bindings.RawInvoice_free(ptr); }
20         }
21
22         /**
23          * data part
24          */
25         public RawDataPart get_data() {
26                 long ret = bindings.RawInvoice_get_data(this.ptr);
27                 GC.KeepAlive(this);
28                 if (ret >= 0 && ret <= 4096) { return null; }
29                 org.ldk.structs.RawDataPart ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawDataPart(null, ret); }
30                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
31                 return ret_hu_conv;
32         }
33
34         /**
35          * data part
36          */
37         public void set_data(org.ldk.structs.RawDataPart val) {
38                 bindings.RawInvoice_set_data(this.ptr, val == null ? 0 : val.ptr);
39                 GC.KeepAlive(this);
40                 GC.KeepAlive(val);
41                 if (this != null) { this.ptrs_to.AddLast(val); };
42         }
43
44         /**
45          * Checks if two RawInvoices contain equal inner contents.
46          * This ignores pointers and is_owned flags and looks at the values in fields.
47          * Two objects with NULL inner values will be considered "equal" here.
48          */
49         public bool eq(org.ldk.structs.RawInvoice b) {
50                 bool ret = bindings.RawInvoice_eq(this.ptr, b == null ? 0 : b.ptr);
51                 GC.KeepAlive(this);
52                 GC.KeepAlive(b);
53                 if (this != null) { this.ptrs_to.AddLast(b); };
54                 return ret;
55         }
56
57         public override bool Equals(object o) {
58                 if (!(o is RawInvoice)) return false;
59                 return this.eq((RawInvoice)o);
60         }
61         internal long clone_ptr() {
62                 long ret = bindings.RawInvoice_clone_ptr(this.ptr);
63                 GC.KeepAlive(this);
64                 return ret;
65         }
66
67         /**
68          * Creates a copy of the RawInvoice
69          */
70         public RawInvoice clone() {
71                 long ret = bindings.RawInvoice_clone(this.ptr);
72                 GC.KeepAlive(this);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 org.ldk.structs.RawInvoice ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RawInvoice(null, ret); }
75                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Checks if two RawInvoices contain equal inner contents.
81          */
82         public long hash() {
83                 long ret = bindings.RawInvoice_hash(this.ptr);
84                 GC.KeepAlive(this);
85                 return ret;
86         }
87
88         public override int GetHashCode() {
89                 return (int)this.hash();
90         }
91         /**
92          * Calculate the hash of the encoded `RawInvoice` which should be signed.
93          */
94         public byte[] signable_hash() {
95                 byte[] ret = bindings.RawInvoice_signable_hash(this.ptr);
96                 GC.KeepAlive(this);
97                 return ret;
98         }
99
100         /**
101          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
102          */
103         public Sha256 payment_hash() {
104                 long ret = bindings.RawInvoice_payment_hash(this.ptr);
105                 GC.KeepAlive(this);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(null, ret); }
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109                 return ret_hu_conv;
110         }
111
112         /**
113          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
114          */
115         public Description description() {
116                 long ret = bindings.RawInvoice_description(this.ptr);
117                 GC.KeepAlive(this);
118                 if (ret >= 0 && ret <= 4096) { return null; }
119                 org.ldk.structs.Description ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Description(null, ret); }
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
121                 return ret_hu_conv;
122         }
123
124         /**
125          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
126          */
127         public PayeePubKey payee_pub_key() {
128                 long ret = bindings.RawInvoice_payee_pub_key(this.ptr);
129                 GC.KeepAlive(this);
130                 if (ret >= 0 && ret <= 4096) { return null; }
131                 org.ldk.structs.PayeePubKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PayeePubKey(null, ret); }
132                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
133                 return ret_hu_conv;
134         }
135
136         /**
137          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
138          */
139         public Sha256 description_hash() {
140                 long ret = bindings.RawInvoice_description_hash(this.ptr);
141                 GC.KeepAlive(this);
142                 if (ret >= 0 && ret <= 4096) { return null; }
143                 org.ldk.structs.Sha256 ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Sha256(null, ret); }
144                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
145                 return ret_hu_conv;
146         }
147
148         /**
149          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
150          */
151         public ExpiryTime expiry_time() {
152                 long ret = bindings.RawInvoice_expiry_time(this.ptr);
153                 GC.KeepAlive(this);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 org.ldk.structs.ExpiryTime ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ExpiryTime(null, ret); }
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
157                 return ret_hu_conv;
158         }
159
160         /**
161          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
162          */
163         public MinFinalCltvExpiry min_final_cltv_expiry() {
164                 long ret = bindings.RawInvoice_min_final_cltv_expiry(this.ptr);
165                 GC.KeepAlive(this);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 org.ldk.structs.MinFinalCltvExpiry ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.MinFinalCltvExpiry(null, ret); }
168                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
169                 return ret_hu_conv;
170         }
171
172         /**
173          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
174          */
175         public byte[] payment_secret() {
176                 byte[] ret = bindings.RawInvoice_payment_secret(this.ptr);
177                 GC.KeepAlive(this);
178                 return ret;
179         }
180
181         /**
182          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
183          */
184         public InvoiceFeatures features() {
185                 long ret = bindings.RawInvoice_features(this.ptr);
186                 GC.KeepAlive(this);
187                 if (ret >= 0 && ret <= 4096) { return null; }
188                 org.ldk.structs.InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceFeatures(null, ret); }
189                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
190                 return ret_hu_conv;
191         }
192
193         public PrivateRoute[] private_routes() {
194                 long[] ret = bindings.RawInvoice_private_routes(this.ptr);
195                 GC.KeepAlive(this);
196                 int ret_conv_14_len = ret.Length;
197                 PrivateRoute[] ret_conv_14_arr = new PrivateRoute[ret_conv_14_len];
198                 for (int o = 0; o < ret_conv_14_len; o++) {
199                         long ret_conv_14 = ret[o];
200                         org.ldk.structs.PrivateRoute ret_conv_14_hu_conv = null; if (ret_conv_14 < 0 || ret_conv_14 > 4096) { ret_conv_14_hu_conv = new org.ldk.structs.PrivateRoute(null, ret_conv_14); }
201                         if (ret_conv_14_hu_conv != null) { ret_conv_14_hu_conv.ptrs_to.AddLast(this); };
202                         ret_conv_14_arr[o] = ret_conv_14_hu_conv;
203                 }
204                 return ret_conv_14_arr;
205         }
206
207         public Option_u64Z amount_pico_btc() {
208                 long ret = bindings.RawInvoice_amount_pico_btc(this.ptr);
209                 GC.KeepAlive(this);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
213                 return ret_hu_conv;
214         }
215
216         public Currency currency() {
217                 Currency ret = bindings.RawInvoice_currency(this.ptr);
218                 GC.KeepAlive(this);
219                 return ret;
220         }
221
222 }
223 } } }