[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / PendingHTLCRouting.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  * Information about where a received HTLC('s onion) has indicated the HTLC should go.
10  */
11 public class PendingHTLCRouting : CommonBase {
12         protected PendingHTLCRouting(object _dummy, long ptr) : base(ptr) { }
13         ~PendingHTLCRouting() {
14                 if (ptr != 0) { bindings.PendingHTLCRouting_free(ptr); }
15         }
16
17         internal static PendingHTLCRouting constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKPendingHTLCRouting_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new PendingHTLCRouting_Forward(ptr);
21                         case 1: return new PendingHTLCRouting_Receive(ptr);
22                         case 2: return new PendingHTLCRouting_ReceiveKeysend(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A PendingHTLCRouting of type Forward */
29         public class PendingHTLCRouting_Forward : PendingHTLCRouting {
30                 /**
31                  * The onion which should be included in the forwarded HTLC, telling the next hop what to
32                  * do with the HTLC.
33                  */
34                 public OnionPacket onion_packet;
35                 /**
36                  * The short channel ID of the channel which we were instructed to forward this HTLC to.
37                  * 
38                  * This could be a real on-chain SCID, an SCID alias, or some other SCID which has meaning
39                  * to the receiving node, such as one returned from
40                  * [`ChannelManager::get_intercept_scid`] or [`ChannelManager::get_phantom_scid`].
41                  */
42                 public long short_channel_id;
43                 /**
44                  * Set if this HTLC is being forwarded within a blinded path.
45                  * 
46                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
47                  */
48                 public BlindedForward blinded;
49                 internal PendingHTLCRouting_Forward(long ptr) : base(null, ptr) {
50                         long onion_packet = bindings.LDKPendingHTLCRouting_Forward_get_onion_packet(ptr);
51                         org.ldk.structs.OnionPacket onion_packet_hu_conv = null; if (onion_packet < 0 || onion_packet > 4096) { onion_packet_hu_conv = new org.ldk.structs.OnionPacket(null, onion_packet); }
52                         if (onion_packet_hu_conv != null) { onion_packet_hu_conv.ptrs_to.AddLast(this); };
53                         this.onion_packet = onion_packet_hu_conv;
54                         this.short_channel_id = bindings.LDKPendingHTLCRouting_Forward_get_short_channel_id(ptr);
55                         long blinded = bindings.LDKPendingHTLCRouting_Forward_get_blinded(ptr);
56                         org.ldk.structs.BlindedForward blinded_hu_conv = null; if (blinded < 0 || blinded > 4096) { blinded_hu_conv = new org.ldk.structs.BlindedForward(null, blinded); }
57                         if (blinded_hu_conv != null) { blinded_hu_conv.ptrs_to.AddLast(this); };
58                         this.blinded = blinded_hu_conv;
59                 }
60         }
61         /** A PendingHTLCRouting of type Receive */
62         public class PendingHTLCRouting_Receive : PendingHTLCRouting {
63                 /**
64                  * Information about the amount the sender intended to pay and (potential) proof that this
65                  * is a payment for an invoice we generated. This proof of payment is is also used for
66                  * linking MPP parts of a larger payment.
67                  */
68                 public FinalOnionHopData payment_data;
69                 /**
70                  * Additional data which we (allegedly) instructed the sender to include in the onion.
71                  * 
72                  * For HTLCs received by LDK, this will ultimately be exposed in
73                  * [`Event::PaymentClaimable::onion_fields`] as
74                  * [`RecipientOnionFields::payment_metadata`].
75                  */
76                 public Option_CVec_u8ZZ payment_metadata;
77                 /**
78                  * CLTV expiry of the received HTLC.
79                  * 
80                  * Used to track when we should expire pending HTLCs that go unclaimed.
81                  */
82                 public int incoming_cltv_expiry;
83                 /**
84                  * If the onion had forwarding instructions to one of our phantom node SCIDs, this will
85                  * provide the onion shared secret used to decrypt the next level of forwarding
86                  * instructions.
87                  * 
88                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
89                  */
90                 public byte[] phantom_shared_secret;
91                 /**
92                  * Custom TLVs which were set by the sender.
93                  * 
94                  * For HTLCs received by LDK, this will ultimately be exposed in
95                  * [`Event::PaymentClaimable::onion_fields`] as
96                  * [`RecipientOnionFields::custom_tlvs`].
97                  */
98                 public TwoTuple_u64CVec_u8ZZ[] custom_tlvs;
99                 /**
100                  * Set if this HTLC is the final hop in a multi-hop blinded path.
101                  */
102                 public bool requires_blinded_error;
103                 internal PendingHTLCRouting_Receive(long ptr) : base(null, ptr) {
104                         long payment_data = bindings.LDKPendingHTLCRouting_Receive_get_payment_data(ptr);
105                         org.ldk.structs.FinalOnionHopData payment_data_hu_conv = null; if (payment_data < 0 || payment_data > 4096) { payment_data_hu_conv = new org.ldk.structs.FinalOnionHopData(null, payment_data); }
106                         if (payment_data_hu_conv != null) { payment_data_hu_conv.ptrs_to.AddLast(this); };
107                         this.payment_data = payment_data_hu_conv;
108                         long payment_metadata = bindings.LDKPendingHTLCRouting_Receive_get_payment_metadata(ptr);
109                         org.ldk.structs.Option_CVec_u8ZZ payment_metadata_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(payment_metadata);
110                         if (payment_metadata_hu_conv != null) { payment_metadata_hu_conv.ptrs_to.AddLast(this); };
111                         this.payment_metadata = payment_metadata_hu_conv;
112                         this.incoming_cltv_expiry = bindings.LDKPendingHTLCRouting_Receive_get_incoming_cltv_expiry(ptr);
113                         long phantom_shared_secret = bindings.LDKPendingHTLCRouting_Receive_get_phantom_shared_secret(ptr);
114                         byte[] phantom_shared_secret_conv = InternalUtils.decodeUint8Array(phantom_shared_secret);
115                         this.phantom_shared_secret = phantom_shared_secret_conv;
116                         long custom_tlvs = bindings.LDKPendingHTLCRouting_Receive_get_custom_tlvs(ptr);
117                         int custom_tlvs_conv_23_len = InternalUtils.getArrayLength(custom_tlvs);
118                         TwoTuple_u64CVec_u8ZZ[] custom_tlvs_conv_23_arr = new TwoTuple_u64CVec_u8ZZ[custom_tlvs_conv_23_len];
119                         for (int x = 0; x < custom_tlvs_conv_23_len; x++) {
120                                 long custom_tlvs_conv_23 = InternalUtils.getU64ArrayElem(custom_tlvs, x);
121                                 TwoTuple_u64CVec_u8ZZ custom_tlvs_conv_23_hu_conv = new TwoTuple_u64CVec_u8ZZ(null, custom_tlvs_conv_23);
122                                 if (custom_tlvs_conv_23_hu_conv != null) { custom_tlvs_conv_23_hu_conv.ptrs_to.AddLast(this); };
123                                 custom_tlvs_conv_23_arr[x] = custom_tlvs_conv_23_hu_conv;
124                         }
125                         bindings.free_buffer(custom_tlvs);
126                         this.custom_tlvs = custom_tlvs_conv_23_arr;
127                         this.requires_blinded_error = bindings.LDKPendingHTLCRouting_Receive_get_requires_blinded_error(ptr);
128                 }
129         }
130         /** A PendingHTLCRouting of type ReceiveKeysend */
131         public class PendingHTLCRouting_ReceiveKeysend : PendingHTLCRouting {
132                 /**
133                  * Information about the amount the sender intended to pay and possibly a token to
134                  * associate MPP parts of a larger payment.
135                  * 
136                  * This will only be filled in if receiving MPP keysend payments is enabled, and it being
137                  * present will cause deserialization to fail on versions of LDK prior to 0.0.116.
138                  * 
139                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
140                  */
141                 public FinalOnionHopData payment_data;
142                 /**
143                  * Preimage for this onion payment. This preimage is provided by the sender and will be
144                  * used to settle the spontaneous payment.
145                  */
146                 public byte[] payment_preimage;
147                 /**
148                  * Additional data which we (allegedly) instructed the sender to include in the onion.
149                  * 
150                  * For HTLCs received by LDK, this will ultimately bubble back up as
151                  * [`RecipientOnionFields::payment_metadata`].
152                  */
153                 public Option_CVec_u8ZZ payment_metadata;
154                 /**
155                  * CLTV expiry of the received HTLC.
156                  * 
157                  * Used to track when we should expire pending HTLCs that go unclaimed.
158                  */
159                 public int incoming_cltv_expiry;
160                 /**
161                  * Custom TLVs which were set by the sender.
162                  * 
163                  * For HTLCs received by LDK, these will ultimately bubble back up as
164                  * [`RecipientOnionFields::custom_tlvs`].
165                  */
166                 public TwoTuple_u64CVec_u8ZZ[] custom_tlvs;
167                 internal PendingHTLCRouting_ReceiveKeysend(long ptr) : base(null, ptr) {
168                         long payment_data = bindings.LDKPendingHTLCRouting_ReceiveKeysend_get_payment_data(ptr);
169                         org.ldk.structs.FinalOnionHopData payment_data_hu_conv = null; if (payment_data < 0 || payment_data > 4096) { payment_data_hu_conv = new org.ldk.structs.FinalOnionHopData(null, payment_data); }
170                         if (payment_data_hu_conv != null) { payment_data_hu_conv.ptrs_to.AddLast(this); };
171                         this.payment_data = payment_data_hu_conv;
172                         long payment_preimage = bindings.LDKPendingHTLCRouting_ReceiveKeysend_get_payment_preimage(ptr);
173                         byte[] payment_preimage_conv = InternalUtils.decodeUint8Array(payment_preimage);
174                         this.payment_preimage = payment_preimage_conv;
175                         long payment_metadata = bindings.LDKPendingHTLCRouting_ReceiveKeysend_get_payment_metadata(ptr);
176                         org.ldk.structs.Option_CVec_u8ZZ payment_metadata_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(payment_metadata);
177                         if (payment_metadata_hu_conv != null) { payment_metadata_hu_conv.ptrs_to.AddLast(this); };
178                         this.payment_metadata = payment_metadata_hu_conv;
179                         this.incoming_cltv_expiry = bindings.LDKPendingHTLCRouting_ReceiveKeysend_get_incoming_cltv_expiry(ptr);
180                         long custom_tlvs = bindings.LDKPendingHTLCRouting_ReceiveKeysend_get_custom_tlvs(ptr);
181                         int custom_tlvs_conv_23_len = InternalUtils.getArrayLength(custom_tlvs);
182                         TwoTuple_u64CVec_u8ZZ[] custom_tlvs_conv_23_arr = new TwoTuple_u64CVec_u8ZZ[custom_tlvs_conv_23_len];
183                         for (int x = 0; x < custom_tlvs_conv_23_len; x++) {
184                                 long custom_tlvs_conv_23 = InternalUtils.getU64ArrayElem(custom_tlvs, x);
185                                 TwoTuple_u64CVec_u8ZZ custom_tlvs_conv_23_hu_conv = new TwoTuple_u64CVec_u8ZZ(null, custom_tlvs_conv_23);
186                                 if (custom_tlvs_conv_23_hu_conv != null) { custom_tlvs_conv_23_hu_conv.ptrs_to.AddLast(this); };
187                                 custom_tlvs_conv_23_arr[x] = custom_tlvs_conv_23_hu_conv;
188                         }
189                         bindings.free_buffer(custom_tlvs);
190                         this.custom_tlvs = custom_tlvs_conv_23_arr;
191                 }
192         }
193         internal long clone_ptr() {
194                 long ret = bindings.PendingHTLCRouting_clone_ptr(this.ptr);
195                 GC.KeepAlive(this);
196                 return ret;
197         }
198
199         /**
200          * Creates a copy of the PendingHTLCRouting
201          */
202         public PendingHTLCRouting clone() {
203                 long ret = bindings.PendingHTLCRouting_clone(this.ptr);
204                 GC.KeepAlive(this);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
207                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
208                 return ret_hu_conv;
209         }
210
211         /**
212          * Utility method to constructs a new Forward-variant PendingHTLCRouting
213          */
214         public static PendingHTLCRouting forward(org.ldk.structs.OnionPacket onion_packet, long short_channel_id, org.ldk.structs.BlindedForward blinded) {
215                 long ret = bindings.PendingHTLCRouting_forward(onion_packet == null ? 0 : onion_packet.ptr, short_channel_id, blinded == null ? 0 : blinded.ptr);
216                 GC.KeepAlive(onion_packet);
217                 GC.KeepAlive(short_channel_id);
218                 GC.KeepAlive(blinded);
219                 if (ret >= 0 && ret <= 4096) { return null; }
220                 org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
221                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
222                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(onion_packet); };
223                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(blinded); };
224                 return ret_hu_conv;
225         }
226
227         /**
228          * Utility method to constructs a new Receive-variant PendingHTLCRouting
229          */
230         public static PendingHTLCRouting receive(org.ldk.structs.FinalOnionHopData payment_data, org.ldk.structs.Option_CVec_u8ZZ payment_metadata, int incoming_cltv_expiry, byte[] phantom_shared_secret, TwoTuple_u64CVec_u8ZZ[] custom_tlvs, bool requires_blinded_error) {
231                 long ret = bindings.PendingHTLCRouting_receive(payment_data == null ? 0 : payment_data.ptr, payment_metadata.ptr, incoming_cltv_expiry, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(phantom_shared_secret, 32)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(custom_tlvs, custom_tlvs_conv_23 => custom_tlvs_conv_23 != null ? custom_tlvs_conv_23.ptr : 0)), requires_blinded_error);
232                 GC.KeepAlive(payment_data);
233                 GC.KeepAlive(payment_metadata);
234                 GC.KeepAlive(incoming_cltv_expiry);
235                 GC.KeepAlive(phantom_shared_secret);
236                 GC.KeepAlive(custom_tlvs);
237                 GC.KeepAlive(requires_blinded_error);
238                 if (ret >= 0 && ret <= 4096) { return null; }
239                 org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
240                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
241                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_data); };
242                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_metadata); };
243                 return ret_hu_conv;
244         }
245
246         /**
247          * Utility method to constructs a new ReceiveKeysend-variant PendingHTLCRouting
248          */
249         public static PendingHTLCRouting receive_keysend(org.ldk.structs.FinalOnionHopData payment_data, byte[] payment_preimage, org.ldk.structs.Option_CVec_u8ZZ payment_metadata, int incoming_cltv_expiry, TwoTuple_u64CVec_u8ZZ[] custom_tlvs) {
250                 long ret = bindings.PendingHTLCRouting_receive_keysend(payment_data == null ? 0 : payment_data.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32)), payment_metadata.ptr, incoming_cltv_expiry, InternalUtils.encodeUint64Array(InternalUtils.mapArray(custom_tlvs, custom_tlvs_conv_23 => custom_tlvs_conv_23 != null ? custom_tlvs_conv_23.ptr : 0)));
251                 GC.KeepAlive(payment_data);
252                 GC.KeepAlive(payment_preimage);
253                 GC.KeepAlive(payment_metadata);
254                 GC.KeepAlive(incoming_cltv_expiry);
255                 GC.KeepAlive(custom_tlvs);
256                 if (ret >= 0 && ret <= 4096) { return null; }
257                 org.ldk.structs.PendingHTLCRouting ret_hu_conv = org.ldk.structs.PendingHTLCRouting.constr_from_ptr(ret);
258                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
259                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_data); };
260                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(payment_metadata); };
261                 return ret_hu_conv;
262         }
263
264         /**
265          * Serialize the PendingHTLCRouting object into a byte array which can be read by PendingHTLCRouting_read
266          */
267         public byte[] write() {
268                 long ret = bindings.PendingHTLCRouting_write(this.ptr);
269                 GC.KeepAlive(this);
270                 if (ret >= 0 && ret <= 4096) { return null; }
271                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
272                 return ret_conv;
273         }
274
275         /**
276          * Read a PendingHTLCRouting from a byte array, created by PendingHTLCRouting_write
277          */
278         public static Result_PendingHTLCRoutingDecodeErrorZ read(byte[] ser) {
279                 long ret = bindings.PendingHTLCRouting_read(InternalUtils.encodeUint8Array(ser));
280                 GC.KeepAlive(ser);
281                 if (ret >= 0 && ret <= 4096) { return null; }
282                 Result_PendingHTLCRoutingDecodeErrorZ ret_hu_conv = Result_PendingHTLCRoutingDecodeErrorZ.constr_from_ptr(ret);
283                 return ret_hu_conv;
284         }
285
286 }
287 } } }