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