[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / UpdateAddHTLC.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  * An [`update_add_htlc`] message to be sent to or received from a peer.
11  * 
12  * [`update_add_htlc`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#adding-an-htlc-update_add_htlc
13  */
14 public class UpdateAddHTLC : CommonBase {
15         internal UpdateAddHTLC(object _dummy, long ptr) : base(ptr) { }
16         ~UpdateAddHTLC() {
17                 if (ptr != 0) { bindings.UpdateAddHTLC_free(ptr); }
18         }
19
20         /**
21          * The channel ID
22          */
23         public byte[] get_channel_id() {
24                 long ret = bindings.UpdateAddHTLC_get_channel_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          * The channel ID
33          */
34         public void set_channel_id(byte[] val) {
35                 bindings.UpdateAddHTLC_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * The HTLC ID
42          */
43         public long get_htlc_id() {
44                 long ret = bindings.UpdateAddHTLC_get_htlc_id(this.ptr);
45                 GC.KeepAlive(this);
46                 return ret;
47         }
48
49         /**
50          * The HTLC ID
51          */
52         public void set_htlc_id(long val) {
53                 bindings.UpdateAddHTLC_set_htlc_id(this.ptr, val);
54                 GC.KeepAlive(this);
55                 GC.KeepAlive(val);
56         }
57
58         /**
59          * The HTLC value in milli-satoshi
60          */
61         public long get_amount_msat() {
62                 long ret = bindings.UpdateAddHTLC_get_amount_msat(this.ptr);
63                 GC.KeepAlive(this);
64                 return ret;
65         }
66
67         /**
68          * The HTLC value in milli-satoshi
69          */
70         public void set_amount_msat(long val) {
71                 bindings.UpdateAddHTLC_set_amount_msat(this.ptr, val);
72                 GC.KeepAlive(this);
73                 GC.KeepAlive(val);
74         }
75
76         /**
77          * The payment hash, the pre-image of which controls HTLC redemption
78          */
79         public byte[] get_payment_hash() {
80                 long ret = bindings.UpdateAddHTLC_get_payment_hash(this.ptr);
81                 GC.KeepAlive(this);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
84                 return ret_conv;
85         }
86
87         /**
88          * The payment hash, the pre-image of which controls HTLC redemption
89          */
90         public void set_payment_hash(byte[] val) {
91                 bindings.UpdateAddHTLC_set_payment_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
92                 GC.KeepAlive(this);
93                 GC.KeepAlive(val);
94         }
95
96         /**
97          * The expiry height of the HTLC
98          */
99         public int get_cltv_expiry() {
100                 int ret = bindings.UpdateAddHTLC_get_cltv_expiry(this.ptr);
101                 GC.KeepAlive(this);
102                 return ret;
103         }
104
105         /**
106          * The expiry height of the HTLC
107          */
108         public void set_cltv_expiry(int val) {
109                 bindings.UpdateAddHTLC_set_cltv_expiry(this.ptr, val);
110                 GC.KeepAlive(this);
111                 GC.KeepAlive(val);
112         }
113
114         /**
115          * The extra fee skimmed by the sender of this message. See
116          * [`ChannelConfig::accept_underpaying_htlcs`].
117          * 
118          * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
119          */
120         public Option_u64Z get_skimmed_fee_msat() {
121                 long ret = bindings.UpdateAddHTLC_get_skimmed_fee_msat(this.ptr);
122                 GC.KeepAlive(this);
123                 if (ret >= 0 && ret <= 4096) { return null; }
124                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
126                 return ret_hu_conv;
127         }
128
129         /**
130          * The extra fee skimmed by the sender of this message. See
131          * [`ChannelConfig::accept_underpaying_htlcs`].
132          * 
133          * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs
134          */
135         public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
136                 bindings.UpdateAddHTLC_set_skimmed_fee_msat(this.ptr, val.ptr);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(val);
139                 if (this != null) { this.ptrs_to.AddLast(val); };
140         }
141
142         /**
143          * The onion routing packet with encrypted data for the next hop.
144          */
145         public OnionPacket get_onion_routing_packet() {
146                 long ret = bindings.UpdateAddHTLC_get_onion_routing_packet(this.ptr);
147                 GC.KeepAlive(this);
148                 if (ret >= 0 && ret <= 4096) { return null; }
149                 org.ldk.structs.OnionPacket ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionPacket(null, ret); }
150                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
151                 return ret_hu_conv;
152         }
153
154         /**
155          * The onion routing packet with encrypted data for the next hop.
156          */
157         public void set_onion_routing_packet(org.ldk.structs.OnionPacket val) {
158                 bindings.UpdateAddHTLC_set_onion_routing_packet(this.ptr, val == null ? 0 : val.ptr);
159                 GC.KeepAlive(this);
160                 GC.KeepAlive(val);
161                 if (this != null) { this.ptrs_to.AddLast(val); };
162         }
163
164         /**
165          * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
166          * routing packet and the recipient-provided encrypted payload within.
167          * 
168          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
169          */
170         public byte[] get_blinding_point() {
171                 long ret = bindings.UpdateAddHTLC_get_blinding_point(this.ptr);
172                 GC.KeepAlive(this);
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
175                 return ret_conv;
176         }
177
178         /**
179          * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion
180          * routing packet and the recipient-provided encrypted payload within.
181          * 
182          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
183          */
184         public void set_blinding_point(byte[] val) {
185                 bindings.UpdateAddHTLC_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
186                 GC.KeepAlive(this);
187                 GC.KeepAlive(val);
188         }
189
190         /**
191          * Constructs a new UpdateAddHTLC given each field
192          * 
193          * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
194          */
195         public static UpdateAddHTLC of(byte[] channel_id_arg, long htlc_id_arg, long amount_msat_arg, byte[] payment_hash_arg, int cltv_expiry_arg, org.ldk.structs.Option_u64Z skimmed_fee_msat_arg, org.ldk.structs.OnionPacket onion_routing_packet_arg, byte[] blinding_point_arg) {
196                 long ret = bindings.UpdateAddHTLC_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), htlc_id_arg, amount_msat_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash_arg, 32)), cltv_expiry_arg, skimmed_fee_msat_arg.ptr, onion_routing_packet_arg == null ? 0 : onion_routing_packet_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(blinding_point_arg, 33)));
197                 GC.KeepAlive(channel_id_arg);
198                 GC.KeepAlive(htlc_id_arg);
199                 GC.KeepAlive(amount_msat_arg);
200                 GC.KeepAlive(payment_hash_arg);
201                 GC.KeepAlive(cltv_expiry_arg);
202                 GC.KeepAlive(skimmed_fee_msat_arg);
203                 GC.KeepAlive(onion_routing_packet_arg);
204                 GC.KeepAlive(blinding_point_arg);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
207                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
208                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(skimmed_fee_msat_arg); };
209                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(onion_routing_packet_arg); };
210                 return ret_hu_conv;
211         }
212
213         internal long clone_ptr() {
214                 long ret = bindings.UpdateAddHTLC_clone_ptr(this.ptr);
215                 GC.KeepAlive(this);
216                 return ret;
217         }
218
219         /**
220          * Creates a copy of the UpdateAddHTLC
221          */
222         public UpdateAddHTLC clone() {
223                 long ret = bindings.UpdateAddHTLC_clone(this.ptr);
224                 GC.KeepAlive(this);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 org.ldk.structs.UpdateAddHTLC ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UpdateAddHTLC(null, ret); }
227                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
228                 return ret_hu_conv;
229         }
230
231         /**
232          * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC.
233          */
234         public long hash() {
235                 long ret = bindings.UpdateAddHTLC_hash(this.ptr);
236                 GC.KeepAlive(this);
237                 return ret;
238         }
239
240         public override int GetHashCode() {
241                 return (int)this.hash();
242         }
243         /**
244          * Checks if two UpdateAddHTLCs contain equal inner contents.
245          * This ignores pointers and is_owned flags and looks at the values in fields.
246          * Two objects with NULL inner values will be considered "equal" here.
247          */
248         public bool eq(org.ldk.structs.UpdateAddHTLC b) {
249                 bool ret = bindings.UpdateAddHTLC_eq(this.ptr, b == null ? 0 : b.ptr);
250                 GC.KeepAlive(this);
251                 GC.KeepAlive(b);
252                 if (this != null) { this.ptrs_to.AddLast(b); };
253                 return ret;
254         }
255
256         public override bool Equals(object o) {
257                 if (!(o is UpdateAddHTLC)) return false;
258                 return this.eq((UpdateAddHTLC)o);
259         }
260         /**
261          * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read
262          */
263         public byte[] write() {
264                 long ret = bindings.UpdateAddHTLC_write(this.ptr);
265                 GC.KeepAlive(this);
266                 if (ret >= 0 && ret <= 4096) { return null; }
267                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
268                 return ret_conv;
269         }
270
271         /**
272          * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write
273          */
274         public static Result_UpdateAddHTLCDecodeErrorZ read(byte[] ser) {
275                 long ret = bindings.UpdateAddHTLC_read(InternalUtils.encodeUint8Array(ser));
276                 GC.KeepAlive(ser);
277                 if (ret >= 0 && ret <= 4096) { return null; }
278                 Result_UpdateAddHTLCDecodeErrorZ ret_hu_conv = Result_UpdateAddHTLCDecodeErrorZ.constr_from_ptr(ret);
279                 return ret_hu_conv;
280         }
281
282 }
283 } } }