[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / InvoiceRequestFields.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 java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`].
13  * 
14  * [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class InvoiceRequestFields extends CommonBase {
18         InvoiceRequestFields(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.InvoiceRequestFields_free(ptr); }
23         }
24
25         /**
26          * A possibly transient pubkey used to sign the invoice request.
27          */
28         public byte[] get_payer_id() {
29                 byte[] ret = bindings.InvoiceRequestFields_get_payer_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * A possibly transient pubkey used to sign the invoice request.
36          */
37         public void set_payer_id(byte[] val) {
38                 bindings.InvoiceRequestFields_set_payer_id(this.ptr, InternalUtils.check_arr_len(val, 33));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
45          */
46         public Option_u64Z get_quantity() {
47                 long ret = bindings.InvoiceRequestFields_get_quantity(this.ptr);
48                 Reference.reachabilityFence(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
57          */
58         public void set_quantity(org.ldk.structs.Option_u64Z val) {
59                 bindings.InvoiceRequestFields_set_quantity(this.ptr, val.ptr);
60                 Reference.reachabilityFence(this);
61                 Reference.reachabilityFence(val);
62                 if (this != null) { this.ptrs_to.add(val); };
63         }
64
65         /**
66          * A payer-provided note which will be seen by the recipient and reflected back in the invoice
67          * response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
68          * 
69          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
70          */
71         @Nullable
72         public UntrustedString get_payer_note_truncated() {
73                 long ret = bindings.InvoiceRequestFields_get_payer_note_truncated(this.ptr);
74                 Reference.reachabilityFence(this);
75                 if (ret >= 0 && ret <= 4096) { return null; }
76                 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
77                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
78                 return ret_hu_conv;
79         }
80
81         /**
82          * A payer-provided note which will be seen by the recipient and reflected back in the invoice
83          * response. Truncated to [`PAYER_NOTE_LIMIT`] characters.
84          * 
85          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
86          */
87         public void set_payer_note_truncated(@Nullable org.ldk.structs.UntrustedString val) {
88                 bindings.InvoiceRequestFields_set_payer_note_truncated(this.ptr, val == null ? 0 : val.ptr);
89                 Reference.reachabilityFence(this);
90                 Reference.reachabilityFence(val);
91                 if (this != null) { this.ptrs_to.add(val); };
92         }
93
94         /**
95          * Constructs a new InvoiceRequestFields given each field
96          * 
97          * Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
98          */
99         public static InvoiceRequestFields of(byte[] payer_id_arg, org.ldk.structs.Option_u64Z quantity_arg, @Nullable org.ldk.structs.UntrustedString payer_note_truncated_arg) {
100                 long ret = bindings.InvoiceRequestFields_new(InternalUtils.check_arr_len(payer_id_arg, 33), quantity_arg.ptr, payer_note_truncated_arg == null ? 0 : payer_note_truncated_arg.ptr);
101                 Reference.reachabilityFence(payer_id_arg);
102                 Reference.reachabilityFence(quantity_arg);
103                 Reference.reachabilityFence(payer_note_truncated_arg);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 org.ldk.structs.InvoiceRequestFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFields(null, ret); }
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(quantity_arg); };
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(payer_note_truncated_arg); };
109                 return ret_hu_conv;
110         }
111
112         long clone_ptr() {
113                 long ret = bindings.InvoiceRequestFields_clone_ptr(this.ptr);
114                 Reference.reachabilityFence(this);
115                 return ret;
116         }
117
118         /**
119          * Creates a copy of the InvoiceRequestFields
120          */
121         public InvoiceRequestFields clone() {
122                 long ret = bindings.InvoiceRequestFields_clone(this.ptr);
123                 Reference.reachabilityFence(this);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 org.ldk.structs.InvoiceRequestFields ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.InvoiceRequestFields(null, ret); }
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * Checks if two InvoiceRequestFieldss contain equal inner contents.
132          * This ignores pointers and is_owned flags and looks at the values in fields.
133          * Two objects with NULL inner values will be considered "equal" here.
134          */
135         public boolean eq(org.ldk.structs.InvoiceRequestFields b) {
136                 boolean ret = bindings.InvoiceRequestFields_eq(this.ptr, b.ptr);
137                 Reference.reachabilityFence(this);
138                 Reference.reachabilityFence(b);
139                 if (this != null) { this.ptrs_to.add(b); };
140                 return ret;
141         }
142
143         @Override public boolean equals(Object o) {
144                 if (!(o instanceof InvoiceRequestFields)) return false;
145                 return this.eq((InvoiceRequestFields)o);
146         }
147         /**
148          * Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read
149          */
150         public byte[] write() {
151                 byte[] ret = bindings.InvoiceRequestFields_write(this.ptr);
152                 Reference.reachabilityFence(this);
153                 return ret;
154         }
155
156         /**
157          * Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write
158          */
159         public static Result_InvoiceRequestFieldsDecodeErrorZ read(byte[] ser) {
160                 long ret = bindings.InvoiceRequestFields_read(ser);
161                 Reference.reachabilityFence(ser);
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 Result_InvoiceRequestFieldsDecodeErrorZ ret_hu_conv = Result_InvoiceRequestFieldsDecodeErrorZ.constr_from_ptr(ret);
164                 return ret_hu_conv;
165         }
166
167 }