[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Payee.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  * The recipient of a payment, differing based on whether they've hidden their identity with route
10  * blinding.
11  */
12 public class Payee : CommonBase {
13         protected Payee(object _dummy, long ptr) : base(ptr) { }
14         ~Payee() {
15                 if (ptr != 0) { bindings.Payee_free(ptr); }
16         }
17
18         internal static Payee constr_from_ptr(long ptr) {
19                 long raw_ty = bindings.LDKPayee_ty_from_ptr(ptr);
20                 switch (raw_ty) {
21                         case 0: return new Payee_Blinded(ptr);
22                         case 1: return new Payee_Clear(ptr);
23                         default:
24                                 throw new ArgumentException("Impossible enum variant");
25                 }
26         }
27
28         /** A Payee of type Blinded */
29         public class Payee_Blinded : Payee {
30                 /**
31                  * Aggregated routing info and blinded paths, for routing to the payee without knowing their
32                  * node id.
33                  */
34                 public TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints;
35                 /**
36                  * Features supported by the payee.
37                  * 
38                  * May be set from the payee's invoice. May be `None` if the invoice does not contain any
39                  * features.
40                  * 
41                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
42                  */
43                 public Bolt12InvoiceFeatures features;
44                 internal Payee_Blinded(long ptr) : base(null, ptr) {
45                         long route_hints = bindings.LDKPayee_Blinded_get_route_hints(ptr);
46                         int route_hints_conv_37_len = InternalUtils.getArrayLength(route_hints);
47                         TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints_conv_37_arr = new TwoTuple_BlindedPayInfoBlindedPathZ[route_hints_conv_37_len];
48                         for (int l = 0; l < route_hints_conv_37_len; l++) {
49                                 long route_hints_conv_37 = InternalUtils.getU64ArrayElem(route_hints, l);
50                                 TwoTuple_BlindedPayInfoBlindedPathZ route_hints_conv_37_hu_conv = new TwoTuple_BlindedPayInfoBlindedPathZ(null, route_hints_conv_37);
51                                 if (route_hints_conv_37_hu_conv != null) { route_hints_conv_37_hu_conv.ptrs_to.AddLast(this); };
52                                 route_hints_conv_37_arr[l] = route_hints_conv_37_hu_conv;
53                         }
54                         bindings.free_buffer(route_hints);
55                         this.route_hints = route_hints_conv_37_arr;
56                         long features = bindings.LDKPayee_Blinded_get_features(ptr);
57                         org.ldk.structs.Bolt12InvoiceFeatures features_hu_conv = null; if (features < 0 || features > 4096) { features_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, features); }
58                         if (features_hu_conv != null) { features_hu_conv.ptrs_to.AddLast(this); };
59                         this.features = features_hu_conv;
60                 }
61         }
62         /** A Payee of type Clear */
63         public class Payee_Clear : Payee {
64                 /**
65                  * The node id of the payee.
66                  */
67                 public byte[] node_id;
68                 /**
69                  * Hints for routing to the payee, containing channels connecting the payee to public nodes.
70                  */
71                 public RouteHint[] route_hints;
72                 /**
73                  * Features supported by the payee.
74                  * 
75                  * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
76                  * does not contain any features.
77                  * 
78                  * [`for_keysend`]: PaymentParameters::for_keysend
79                  * 
80                  * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
81                  */
82                 public Bolt11InvoiceFeatures features;
83                 /**
84                  * The minimum CLTV delta at the end of the route. This value must not be zero.
85                  */
86                 public int final_cltv_expiry_delta;
87                 internal Payee_Clear(long ptr) : base(null, ptr) {
88                         long node_id = bindings.LDKPayee_Clear_get_node_id(ptr);
89                         byte[] node_id_conv = InternalUtils.decodeUint8Array(node_id);
90                         this.node_id = node_id_conv;
91                         long route_hints = bindings.LDKPayee_Clear_get_route_hints(ptr);
92                         int route_hints_conv_11_len = InternalUtils.getArrayLength(route_hints);
93                         RouteHint[] route_hints_conv_11_arr = new RouteHint[route_hints_conv_11_len];
94                         for (int l = 0; l < route_hints_conv_11_len; l++) {
95                                 long route_hints_conv_11 = InternalUtils.getU64ArrayElem(route_hints, l);
96                                 org.ldk.structs.RouteHint route_hints_conv_11_hu_conv = null; if (route_hints_conv_11 < 0 || route_hints_conv_11 > 4096) { route_hints_conv_11_hu_conv = new org.ldk.structs.RouteHint(null, route_hints_conv_11); }
97                                 if (route_hints_conv_11_hu_conv != null) { route_hints_conv_11_hu_conv.ptrs_to.AddLast(this); };
98                                 route_hints_conv_11_arr[l] = route_hints_conv_11_hu_conv;
99                         }
100                         bindings.free_buffer(route_hints);
101                         this.route_hints = route_hints_conv_11_arr;
102                         long features = bindings.LDKPayee_Clear_get_features(ptr);
103                         org.ldk.structs.Bolt11InvoiceFeatures features_hu_conv = null; if (features < 0 || features > 4096) { features_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, features); }
104                         if (features_hu_conv != null) { features_hu_conv.ptrs_to.AddLast(this); };
105                         this.features = features_hu_conv;
106                         this.final_cltv_expiry_delta = bindings.LDKPayee_Clear_get_final_cltv_expiry_delta(ptr);
107                 }
108         }
109         internal long clone_ptr() {
110                 long ret = bindings.Payee_clone_ptr(this.ptr);
111                 GC.KeepAlive(this);
112                 return ret;
113         }
114
115         /**
116          * Creates a copy of the Payee
117          */
118         public Payee clone() {
119                 long ret = bindings.Payee_clone(this.ptr);
120                 GC.KeepAlive(this);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Utility method to constructs a new Blinded-variant Payee
129          */
130         public static Payee blinded(TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints, org.ldk.structs.Bolt12InvoiceFeatures features) {
131                 long ret = bindings.Payee_blinded(InternalUtils.encodeUint64Array(InternalUtils.mapArray(route_hints, route_hints_conv_37 => route_hints_conv_37 != null ? route_hints_conv_37.ptr : 0)), features == null ? 0 : features.ptr);
132                 GC.KeepAlive(route_hints);
133                 GC.KeepAlive(features);
134                 if (ret >= 0 && ret <= 4096) { return null; }
135                 org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
136                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features); };
138                 return ret_hu_conv;
139         }
140
141         /**
142          * Utility method to constructs a new Clear-variant Payee
143          */
144         public static Payee clear(byte[] node_id, RouteHint[] route_hints, org.ldk.structs.Bolt11InvoiceFeatures features, int final_cltv_expiry_delta) {
145                 long ret = bindings.Payee_clear(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_id, 33)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(route_hints, route_hints_conv_11 => route_hints_conv_11 == null ? 0 : route_hints_conv_11.ptr)), features == null ? 0 : features.ptr, final_cltv_expiry_delta);
146                 GC.KeepAlive(node_id);
147                 GC.KeepAlive(route_hints);
148                 GC.KeepAlive(features);
149                 GC.KeepAlive(final_cltv_expiry_delta);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
152                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
153                 foreach (RouteHint route_hints_conv_11 in route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_hints_conv_11); }; };
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features); };
155                 return ret_hu_conv;
156         }
157
158         /**
159          * Generates a non-cryptographic 64-bit hash of the Payee.
160          */
161         public long hash() {
162                 long ret = bindings.Payee_hash(this.ptr);
163                 GC.KeepAlive(this);
164                 return ret;
165         }
166
167         public override int GetHashCode() {
168                 return (int)this.hash();
169         }
170         /**
171          * Checks if two Payees contain equal inner contents.
172          * This ignores pointers and is_owned flags and looks at the values in fields.
173          */
174         public bool eq(org.ldk.structs.Payee b) {
175                 bool ret = bindings.Payee_eq(this.ptr, b == null ? 0 : b.ptr);
176                 GC.KeepAlive(this);
177                 GC.KeepAlive(b);
178                 return ret;
179         }
180
181         public override bool Equals(object o) {
182                 if (!(o is Payee)) return false;
183                 return this.eq((Payee)o);
184         }
185 }
186 } } }