1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`].
14 * [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer
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 {
22 if (ptr != 0) { bindings.InvoiceRequestFields_free(ptr); }
26 * A possibly transient pubkey used to sign the invoice request.
28 public byte[] get_payer_id() {
29 byte[] ret = bindings.InvoiceRequestFields_get_payer_id(this.ptr);
30 Reference.reachabilityFence(this);
35 * A possibly transient pubkey used to sign the invoice request.
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);
44 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
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); };
56 * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`].
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); };
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.
69 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
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.
85 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
95 * Constructs a new InvoiceRequestFields given each field
97 * Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
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); };
113 long ret = bindings.InvoiceRequestFields_clone_ptr(this.ptr);
114 Reference.reachabilityFence(this);
119 * Creates a copy of the InvoiceRequestFields
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); };
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.
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); };
143 @Override public boolean equals(Object o) {
144 if (!(o instanceof InvoiceRequestFields)) return false;
145 return this.eq((InvoiceRequestFields)o);
148 * Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read
150 public byte[] write() {
151 byte[] ret = bindings.InvoiceRequestFields_write(this.ptr);
152 Reference.reachabilityFence(this);
157 * Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write
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);