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