Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / Payee.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * The recipient of a payment.
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class Payee extends CommonBase {
15         Payee(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.Payee_free(ptr); }
20         }
21
22         /**
23          * The node id of the payee.
24          */
25         public byte[] get_pubkey() {
26                 byte[] ret = bindings.Payee_get_pubkey(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * The node id of the payee.
32          */
33         public void set_pubkey(byte[] val) {
34                 bindings.Payee_set_pubkey(this.ptr, val);
35         }
36
37         /**
38          * Features supported by the payee.
39          * 
40          * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
41          * does not contain any features.
42          * 
43          * [`for_keysend`]: Self::for_keysend
44          * 
45          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
46          */
47         @Nullable
48         public InvoiceFeatures get_features() {
49                 long ret = bindings.Payee_get_features(this.ptr);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 InvoiceFeatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new InvoiceFeatures(null, ret); }
52                 ret_hu_conv.ptrs_to.add(this);
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Features supported by the payee.
58          * 
59          * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
60          * does not contain any features.
61          * 
62          * [`for_keysend`]: Self::for_keysend
63          * 
64          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
65          */
66         public void set_features(@Nullable InvoiceFeatures val) {
67                 bindings.Payee_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
68         }
69
70         /**
71          * Hints for routing to the payee, containing channels connecting the payee to public nodes.
72          */
73         public RouteHint[] get_route_hints() {
74                 long[] ret = bindings.Payee_get_route_hints(this.ptr);
75                 RouteHint[] ret_conv_11_arr = new RouteHint[ret.length];
76                 for (int l = 0; l < ret.length; l++) {
77                         long ret_conv_11 = ret[l];
78                         RouteHint ret_conv_11_hu_conv = null; if (ret_conv_11 < 0 || ret_conv_11 > 4096) { ret_conv_11_hu_conv = new RouteHint(null, ret_conv_11); }
79                         ret_conv_11_hu_conv.ptrs_to.add(this);
80                         ret_conv_11_arr[l] = ret_conv_11_hu_conv;
81                 }
82                 return ret_conv_11_arr;
83         }
84
85         /**
86          * Hints for routing to the payee, containing channels connecting the payee to public nodes.
87          */
88         public void set_route_hints(RouteHint[] val) {
89                 bindings.Payee_set_route_hints(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_11 -> val_conv_11 == null ? 0 : val_conv_11.ptr & ~1).toArray() : null);
90         }
91
92         /**
93          * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
94          */
95         public Option_u64Z get_expiry_time() {
96                 long ret = bindings.Payee_get_expiry_time(this.ptr);
97                 if (ret >= 0 && ret <= 4096) { return null; }
98                 Option_u64Z ret_hu_conv = Option_u64Z.constr_from_ptr(ret);
99                 ret_hu_conv.ptrs_to.add(this);
100                 return ret_hu_conv;
101         }
102
103         /**
104          * Expiration of a payment to the payee, in seconds relative to the UNIX epoch.
105          */
106         public void set_expiry_time(Option_u64Z val) {
107                 bindings.Payee_set_expiry_time(this.ptr, val.ptr);
108         }
109
110         /**
111          * Constructs a new Payee given each field
112          */
113         public static Payee of(byte[] pubkey_arg, InvoiceFeatures features_arg, RouteHint[] route_hints_arg, Option_u64Z expiry_time_arg) {
114                 long ret = bindings.Payee_new(pubkey_arg, features_arg == null ? 0 : features_arg.ptr & ~1, route_hints_arg != null ? Arrays.stream(route_hints_arg).mapToLong(route_hints_arg_conv_11 -> route_hints_arg_conv_11 == null ? 0 : route_hints_arg_conv_11.ptr & ~1).toArray() : null, expiry_time_arg.ptr);
115                 if (ret >= 0 && ret <= 4096) { return null; }
116                 Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
117                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
118                 return ret_hu_conv;
119         }
120
121         /**
122          * Creates a copy of the Payee
123          */
124         public Payee clone() {
125                 long ret = bindings.Payee_clone(this.ptr);
126                 if (ret >= 0 && ret <= 4096) { return null; }
127                 Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
128                 ret_hu_conv.ptrs_to.add(this);
129                 return ret_hu_conv;
130         }
131
132         /**
133          * Checks if two Payees contain equal inner contents.
134          */
135         public long hash() {
136                 long ret = bindings.Payee_hash(this.ptr);
137                 return ret;
138         }
139
140         /**
141          * Checks if two Payees contain equal inner contents.
142          * This ignores pointers and is_owned flags and looks at the values in fields.
143          * Two objects with NULL inner values will be considered "equal" here.
144          */
145         public boolean eq(Payee b) {
146                 boolean ret = bindings.Payee_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
147                 this.ptrs_to.add(b);
148                 return ret;
149         }
150
151         /**
152          * Serialize the Payee object into a byte array which can be read by Payee_read
153          */
154         public byte[] write() {
155                 byte[] ret = bindings.Payee_write(this.ptr);
156                 return ret;
157         }
158
159         /**
160          * Read a Payee from a byte array, created by Payee_write
161          */
162         public static Result_PayeeDecodeErrorZ read(byte[] ser) {
163                 long ret = bindings.Payee_read(ser);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 Result_PayeeDecodeErrorZ ret_hu_conv = Result_PayeeDecodeErrorZ.constr_from_ptr(ret);
166                 return ret_hu_conv;
167         }
168
169         /**
170          * Creates a payee with the node id of the given `pubkey`.
171          */
172         public static Payee from_node_id(byte[] pubkey) {
173                 long ret = bindings.Payee_from_node_id(pubkey);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
176                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
177                 return ret_hu_conv;
178         }
179
180         /**
181          * Creates a payee with the node id of the given `pubkey` to use for keysend payments.
182          */
183         public static Payee for_keysend(byte[] pubkey) {
184                 long ret = bindings.Payee_for_keysend(pubkey);
185                 if (ret >= 0 && ret <= 4096) { return null; }
186                 Payee ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new Payee(null, ret); }
187                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
188                 return ret_hu_conv;
189         }
190
191 }