[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / PendingHTLCInfo.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  * Information about an incoming HTLC, including the [`PendingHTLCRouting`] describing where it
11  * should go next.
12  */
13 public class PendingHTLCInfo : CommonBase {
14         internal PendingHTLCInfo(object _dummy, long ptr) : base(ptr) { }
15         ~PendingHTLCInfo() {
16                 if (ptr != 0) { bindings.PendingHTLCInfo_free(ptr); }
17         }
18
19         /**
20          * Further routing details based on whether the HTLC is being forwarded or received.
21          */
22         public PendingHTLCRouting get_routing() {
23                 long ret = bindings.PendingHTLCInfo_get_routing(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
27                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
28                 return ret_hu_conv;
29         }
30
31         /**
32          * Further routing details based on whether the HTLC is being forwarded or received.
33          */
34         public void set_routing(org.ldk.structs.PendingHTLCRouting val) {
35                 bindings.PendingHTLCInfo_set_routing(this.ptr, val.ptr);
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38                 if (this != null) { this.ptrs_to.AddLast(val); };
39         }
40
41         /**
42          * The onion shared secret we build with the sender used to decrypt the onion.
43          * 
44          * This is later used to encrypt failure packets in the event that the HTLC is failed.
45          */
46         public byte[] get_incoming_shared_secret() {
47                 long ret = bindings.PendingHTLCInfo_get_incoming_shared_secret(this.ptr);
48                 GC.KeepAlive(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
51                 return ret_conv;
52         }
53
54         /**
55          * The onion shared secret we build with the sender used to decrypt the onion.
56          * 
57          * This is later used to encrypt failure packets in the event that the HTLC is failed.
58          */
59         public void set_incoming_shared_secret(byte[] val) {
60                 bindings.PendingHTLCInfo_set_incoming_shared_secret(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
61                 GC.KeepAlive(this);
62                 GC.KeepAlive(val);
63         }
64
65         /**
66          * Hash of the payment preimage, to lock the payment until the receiver releases the preimage.
67          */
68         public byte[] get_payment_hash() {
69                 long ret = bindings.PendingHTLCInfo_get_payment_hash(this.ptr);
70                 GC.KeepAlive(this);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
73                 return ret_conv;
74         }
75
76         /**
77          * Hash of the payment preimage, to lock the payment until the receiver releases the preimage.
78          */
79         public void set_payment_hash(byte[] val) {
80                 bindings.PendingHTLCInfo_set_payment_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
81                 GC.KeepAlive(this);
82                 GC.KeepAlive(val);
83         }
84
85         /**
86          * Amount received in the incoming HTLC.
87          * 
88          * This field was added in LDK 0.0.113 and will be `None` for objects written by prior
89          * versions.
90          */
91         public Option_u64Z get_incoming_amt_msat() {
92                 long ret = bindings.PendingHTLCInfo_get_incoming_amt_msat(this.ptr);
93                 GC.KeepAlive(this);
94                 if (ret >= 0 && ret <= 4096) { return null; }
95                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
96                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
97                 return ret_hu_conv;
98         }
99
100         /**
101          * Amount received in the incoming HTLC.
102          * 
103          * This field was added in LDK 0.0.113 and will be `None` for objects written by prior
104          * versions.
105          */
106         public void set_incoming_amt_msat(org.ldk.structs.Option_u64Z val) {
107                 bindings.PendingHTLCInfo_set_incoming_amt_msat(this.ptr, val.ptr);
108                 GC.KeepAlive(this);
109                 GC.KeepAlive(val);
110                 if (this != null) { this.ptrs_to.AddLast(val); };
111         }
112
113         /**
114          * The amount the sender indicated should be forwarded on to the next hop or amount the sender
115          * intended for us to receive for received payments.
116          * 
117          * If the received amount is less than this for received payments, an intermediary hop has
118          * attempted to steal some of our funds and we should fail the HTLC (the sender should retry
119          * it along another path).
120          * 
121          * Because nodes can take less than their required fees, and because senders may wish to
122          * improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for
123          * received payments. In such cases, recipients must handle this HTLC as if it had received
124          * [`Self::outgoing_amt_msat`].
125          */
126         public long get_outgoing_amt_msat() {
127                 long ret = bindings.PendingHTLCInfo_get_outgoing_amt_msat(this.ptr);
128                 GC.KeepAlive(this);
129                 return ret;
130         }
131
132         /**
133          * The amount the sender indicated should be forwarded on to the next hop or amount the sender
134          * intended for us to receive for received payments.
135          * 
136          * If the received amount is less than this for received payments, an intermediary hop has
137          * attempted to steal some of our funds and we should fail the HTLC (the sender should retry
138          * it along another path).
139          * 
140          * Because nodes can take less than their required fees, and because senders may wish to
141          * improve their own privacy, this amount may be less than [`Self::incoming_amt_msat`] for
142          * received payments. In such cases, recipients must handle this HTLC as if it had received
143          * [`Self::outgoing_amt_msat`].
144          */
145         public void set_outgoing_amt_msat(long val) {
146                 bindings.PendingHTLCInfo_set_outgoing_amt_msat(this.ptr, val);
147                 GC.KeepAlive(this);
148                 GC.KeepAlive(val);
149         }
150
151         /**
152          * The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated
153          * should have been set on the received HTLC for received payments).
154          */
155         public int get_outgoing_cltv_value() {
156                 int ret = bindings.PendingHTLCInfo_get_outgoing_cltv_value(this.ptr);
157                 GC.KeepAlive(this);
158                 return ret;
159         }
160
161         /**
162          * The CLTV the sender has indicated we should set on the forwarded HTLC (or has indicated
163          * should have been set on the received HTLC for received payments).
164          */
165         public void set_outgoing_cltv_value(int val) {
166                 bindings.PendingHTLCInfo_set_outgoing_cltv_value(this.ptr, val);
167                 GC.KeepAlive(this);
168                 GC.KeepAlive(val);
169         }
170
171         /**
172          * The fee taken for this HTLC in addition to the standard protocol HTLC fees.
173          * 
174          * If this is a payment for forwarding, this is the fee we are taking before forwarding the
175          * HTLC.
176          * 
177          * If this is a received payment, this is the fee that our counterparty took.
178          * 
179          * This is used to allow LSPs to take fees as a part of payments, without the sender having to
180          * shoulder them.
181          */
182         public Option_u64Z get_skimmed_fee_msat() {
183                 long ret = bindings.PendingHTLCInfo_get_skimmed_fee_msat(this.ptr);
184                 GC.KeepAlive(this);
185                 if (ret >= 0 && ret <= 4096) { return null; }
186                 org.ldk.structs.Option_u64Z ret_hu_conv = org.ldk.structs.Option_u64Z.constr_from_ptr(ret);
187                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
188                 return ret_hu_conv;
189         }
190
191         /**
192          * The fee taken for this HTLC in addition to the standard protocol HTLC fees.
193          * 
194          * If this is a payment for forwarding, this is the fee we are taking before forwarding the
195          * HTLC.
196          * 
197          * If this is a received payment, this is the fee that our counterparty took.
198          * 
199          * This is used to allow LSPs to take fees as a part of payments, without the sender having to
200          * shoulder them.
201          */
202         public void set_skimmed_fee_msat(org.ldk.structs.Option_u64Z val) {
203                 bindings.PendingHTLCInfo_set_skimmed_fee_msat(this.ptr, val.ptr);
204                 GC.KeepAlive(this);
205                 GC.KeepAlive(val);
206                 if (this != null) { this.ptrs_to.AddLast(val); };
207         }
208
209         /**
210          * Constructs a new PendingHTLCInfo given each field
211          */
212         public static PendingHTLCInfo of(org.ldk.structs.PendingHTLCRouting routing_arg, byte[] incoming_shared_secret_arg, byte[] payment_hash_arg, org.ldk.structs.Option_u64Z incoming_amt_msat_arg, long outgoing_amt_msat_arg, int outgoing_cltv_value_arg, org.ldk.structs.Option_u64Z skimmed_fee_msat_arg) {
213                 long ret = bindings.PendingHTLCInfo_new(routing_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(incoming_shared_secret_arg, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash_arg, 32)), incoming_amt_msat_arg.ptr, outgoing_amt_msat_arg, outgoing_cltv_value_arg, skimmed_fee_msat_arg.ptr);
214                 GC.KeepAlive(routing_arg);
215                 GC.KeepAlive(incoming_shared_secret_arg);
216                 GC.KeepAlive(payment_hash_arg);
217                 GC.KeepAlive(incoming_amt_msat_arg);
218                 GC.KeepAlive(outgoing_amt_msat_arg);
219                 GC.KeepAlive(outgoing_cltv_value_arg);
220                 GC.KeepAlive(skimmed_fee_msat_arg);
221                 if (ret >= 0 && ret <= 4096) { return null; }
222                 org.ldk.structs.PendingHTLCInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PendingHTLCInfo(null, ret); }
223                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
224                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(routing_arg); };
225                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(incoming_amt_msat_arg); };
226                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(skimmed_fee_msat_arg); };
227                 return ret_hu_conv;
228         }
229
230         internal long clone_ptr() {
231                 long ret = bindings.PendingHTLCInfo_clone_ptr(this.ptr);
232                 GC.KeepAlive(this);
233                 return ret;
234         }
235
236         /**
237          * Creates a copy of the PendingHTLCInfo
238          */
239         public PendingHTLCInfo clone() {
240                 long ret = bindings.PendingHTLCInfo_clone(this.ptr);
241                 GC.KeepAlive(this);
242                 if (ret >= 0 && ret <= 4096) { return null; }
243                 org.ldk.structs.PendingHTLCInfo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PendingHTLCInfo(null, ret); }
244                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
245                 return ret_hu_conv;
246         }
247
248         /**
249          * Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read
250          */
251         public byte[] write() {
252                 long ret = bindings.PendingHTLCInfo_write(this.ptr);
253                 GC.KeepAlive(this);
254                 if (ret >= 0 && ret <= 4096) { return null; }
255                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
256                 return ret_conv;
257         }
258
259         /**
260          * Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write
261          */
262         public static Result_PendingHTLCInfoDecodeErrorZ read(byte[] ser) {
263                 long ret = bindings.PendingHTLCInfo_read(InternalUtils.encodeUint8Array(ser));
264                 GC.KeepAlive(ser);
265                 if (ret >= 0 && ret <= 4096) { return null; }
266                 Result_PendingHTLCInfoDecodeErrorZ ret_hu_conv = Result_PendingHTLCInfoDecodeErrorZ.constr_from_ptr(ret);
267                 return ret_hu_conv;
268         }
269
270 }
271 } } }