[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / HTLCDestination.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  * Intended destination of a failed HTLC as indicated in [`Event::HTLCHandlingFailed`].
10  */
11 public class HTLCDestination : CommonBase {
12         protected HTLCDestination(object _dummy, long ptr) : base(ptr) { }
13         ~HTLCDestination() {
14                 if (ptr != 0) { bindings.HTLCDestination_free(ptr); }
15         }
16
17         internal static HTLCDestination constr_from_ptr(long ptr) {
18                 long raw_ty = bindings.LDKHTLCDestination_ty_from_ptr(ptr);
19                 switch (raw_ty) {
20                         case 0: return new HTLCDestination_NextHopChannel(ptr);
21                         case 1: return new HTLCDestination_UnknownNextHop(ptr);
22                         case 2: return new HTLCDestination_InvalidForward(ptr);
23                         case 3: return new HTLCDestination_FailedPayment(ptr);
24                         default:
25                                 throw new ArgumentException("Impossible enum variant");
26                 }
27         }
28
29         /** A HTLCDestination of type NextHopChannel */
30         public class HTLCDestination_NextHopChannel : HTLCDestination {
31                 /**
32                  * The `node_id` of the next node. For backwards compatibility, this field is
33                  * marked as optional, versions prior to 0.0.110 may not always be able to provide
34                  * counterparty node information.
35                  * 
36                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
37                  */
38                 public byte[] node_id;
39                 /**
40                  * The outgoing `channel_id` between us and the next node.
41                  */
42                 public byte[] channel_id;
43                 internal HTLCDestination_NextHopChannel(long ptr) : base(null, ptr) {
44                         long node_id = bindings.LDKHTLCDestination_NextHopChannel_get_node_id(ptr);
45                         byte[] node_id_conv = InternalUtils.decodeUint8Array(node_id);
46                         this.node_id = node_id_conv;
47                         long channel_id = bindings.LDKHTLCDestination_NextHopChannel_get_channel_id(ptr);
48                         byte[] channel_id_conv = InternalUtils.decodeUint8Array(channel_id);
49                         this.channel_id = channel_id_conv;
50                 }
51         }
52         /** A HTLCDestination of type UnknownNextHop */
53         public class HTLCDestination_UnknownNextHop : HTLCDestination {
54                 /**
55                  * Short channel id we are requesting to forward an HTLC to.
56                  */
57                 public long requested_forward_scid;
58                 internal HTLCDestination_UnknownNextHop(long ptr) : base(null, ptr) {
59                         this.requested_forward_scid = bindings.LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid(ptr);
60                 }
61         }
62         /** A HTLCDestination of type InvalidForward */
63         public class HTLCDestination_InvalidForward : HTLCDestination {
64                 /**
65                  * Short channel id we are requesting to forward an HTLC to.
66                  */
67                 public long requested_forward_scid;
68                 internal HTLCDestination_InvalidForward(long ptr) : base(null, ptr) {
69                         this.requested_forward_scid = bindings.LDKHTLCDestination_InvalidForward_get_requested_forward_scid(ptr);
70                 }
71         }
72         /** A HTLCDestination of type FailedPayment */
73         public class HTLCDestination_FailedPayment : HTLCDestination {
74                 /**
75                  * The payment hash of the payment we attempted to process.
76                  */
77                 public byte[] payment_hash;
78                 internal HTLCDestination_FailedPayment(long ptr) : base(null, ptr) {
79                         long payment_hash = bindings.LDKHTLCDestination_FailedPayment_get_payment_hash(ptr);
80                         byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash);
81                         this.payment_hash = payment_hash_conv;
82                 }
83         }
84         internal long clone_ptr() {
85                 long ret = bindings.HTLCDestination_clone_ptr(this.ptr);
86                 GC.KeepAlive(this);
87                 return ret;
88         }
89
90         /**
91          * Creates a copy of the HTLCDestination
92          */
93         public HTLCDestination clone() {
94                 long ret = bindings.HTLCDestination_clone(this.ptr);
95                 GC.KeepAlive(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.HTLCDestination ret_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(ret);
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Utility method to constructs a new NextHopChannel-variant HTLCDestination
104          */
105         public static HTLCDestination next_hop_channel(byte[] node_id, byte[] channel_id) {
106                 long ret = bindings.HTLCDestination_next_hop_channel(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_id, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id, 32)));
107                 GC.KeepAlive(node_id);
108                 GC.KeepAlive(channel_id);
109                 if (ret >= 0 && ret <= 4096) { return null; }
110                 org.ldk.structs.HTLCDestination ret_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(ret);
111                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
112                 return ret_hu_conv;
113         }
114
115         /**
116          * Utility method to constructs a new UnknownNextHop-variant HTLCDestination
117          */
118         public static HTLCDestination unknown_next_hop(long requested_forward_scid) {
119                 long ret = bindings.HTLCDestination_unknown_next_hop(requested_forward_scid);
120                 GC.KeepAlive(requested_forward_scid);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 org.ldk.structs.HTLCDestination ret_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(ret);
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Utility method to constructs a new InvalidForward-variant HTLCDestination
129          */
130         public static HTLCDestination invalid_forward(long requested_forward_scid) {
131                 long ret = bindings.HTLCDestination_invalid_forward(requested_forward_scid);
132                 GC.KeepAlive(requested_forward_scid);
133                 if (ret >= 0 && ret <= 4096) { return null; }
134                 org.ldk.structs.HTLCDestination ret_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(ret);
135                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
136                 return ret_hu_conv;
137         }
138
139         /**
140          * Utility method to constructs a new FailedPayment-variant HTLCDestination
141          */
142         public static HTLCDestination failed_payment(byte[] payment_hash) {
143                 long ret = bindings.HTLCDestination_failed_payment(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)));
144                 GC.KeepAlive(payment_hash);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 org.ldk.structs.HTLCDestination ret_hu_conv = org.ldk.structs.HTLCDestination.constr_from_ptr(ret);
147                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
148                 return ret_hu_conv;
149         }
150
151         /**
152          * Checks if two HTLCDestinations contain equal inner contents.
153          * This ignores pointers and is_owned flags and looks at the values in fields.
154          */
155         public bool eq(org.ldk.structs.HTLCDestination b) {
156                 bool ret = bindings.HTLCDestination_eq(this.ptr, b == null ? 0 : b.ptr);
157                 GC.KeepAlive(this);
158                 GC.KeepAlive(b);
159                 return ret;
160         }
161
162         public override bool Equals(object o) {
163                 if (!(o is HTLCDestination)) return false;
164                 return this.eq((HTLCDestination)o);
165         }
166         /**
167          * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read
168          */
169         public byte[] write() {
170                 long ret = bindings.HTLCDestination_write(this.ptr);
171                 GC.KeepAlive(this);
172                 if (ret >= 0 && ret <= 4096) { return null; }
173                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
174                 return ret_conv;
175         }
176
177 }
178 } } }