6 namespace org { namespace ldk { namespace structs {
9 * The recipient of a payment, differing based on whether they've hidden their identity with route
12 public class Payee : CommonBase {
13 protected Payee(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.Payee_free(ptr); }
18 internal static Payee constr_from_ptr(long ptr) {
19 long raw_ty = bindings.LDKPayee_ty_from_ptr(ptr);
21 case 0: return new Payee_Blinded(ptr);
22 case 1: return new Payee_Clear(ptr);
24 throw new ArgumentException("Impossible enum variant");
28 /** A Payee of type Blinded */
29 public class Payee_Blinded : Payee {
31 * Aggregated routing info and blinded paths, for routing to the payee without knowing their
34 public TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints;
36 * Features supported by the payee.
38 * May be set from the payee's invoice. May be `None` if the invoice does not contain any
41 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
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 = route_hints.Length;
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 = 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;
54 this.route_hints = route_hints_conv_37_arr;
55 long features = bindings.LDKPayee_Blinded_get_features(ptr);
56 org.ldk.structs.Bolt12InvoiceFeatures features_hu_conv = null; if (features < 0 || features > 4096) { features_hu_conv = new org.ldk.structs.Bolt12InvoiceFeatures(null, features); }
57 if (features_hu_conv != null) { features_hu_conv.ptrs_to.AddLast(this); };
58 this.features = features_hu_conv;
61 /** A Payee of type Clear */
62 public class Payee_Clear : Payee {
64 * The node id of the payee.
66 public byte[] node_id;
68 * Hints for routing to the payee, containing channels connecting the payee to public nodes.
70 public RouteHint[] route_hints;
72 * Features supported by the payee.
74 * May be set from the payee's invoice or via [`for_keysend`]. May be `None` if the invoice
75 * does not contain any features.
77 * [`for_keysend`]: PaymentParameters::for_keysend
79 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
81 public Bolt11InvoiceFeatures features;
83 * The minimum CLTV delta at the end of the route. This value must not be zero.
85 public int final_cltv_expiry_delta;
86 internal Payee_Clear(long ptr) : base(null, ptr) {
87 this.node_id = bindings.LDKPayee_Clear_get_node_id(ptr);
88 long[] route_hints = bindings.LDKPayee_Clear_get_route_hints(ptr);
89 int route_hints_conv_11_len = route_hints.Length;
90 RouteHint[] route_hints_conv_11_arr = new RouteHint[route_hints_conv_11_len];
91 for (int l = 0; l < route_hints_conv_11_len; l++) {
92 long route_hints_conv_11 = route_hints[l];
93 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); }
94 if (route_hints_conv_11_hu_conv != null) { route_hints_conv_11_hu_conv.ptrs_to.AddLast(this); };
95 route_hints_conv_11_arr[l] = route_hints_conv_11_hu_conv;
97 this.route_hints = route_hints_conv_11_arr;
98 long features = bindings.LDKPayee_Clear_get_features(ptr);
99 org.ldk.structs.Bolt11InvoiceFeatures features_hu_conv = null; if (features < 0 || features > 4096) { features_hu_conv = new org.ldk.structs.Bolt11InvoiceFeatures(null, features); }
100 if (features_hu_conv != null) { features_hu_conv.ptrs_to.AddLast(this); };
101 this.features = features_hu_conv;
102 this.final_cltv_expiry_delta = bindings.LDKPayee_Clear_get_final_cltv_expiry_delta(ptr);
105 internal long clone_ptr() {
106 long ret = bindings.Payee_clone_ptr(this.ptr);
112 * Creates a copy of the Payee
114 public Payee clone() {
115 long ret = bindings.Payee_clone(this.ptr);
117 if (ret >= 0 && ret <= 4096) { return null; }
118 org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
124 * Utility method to constructs a new Blinded-variant Payee
126 public static Payee blinded(TwoTuple_BlindedPayInfoBlindedPathZ[] route_hints, org.ldk.structs.Bolt12InvoiceFeatures features) {
127 long ret = bindings.Payee_blinded(route_hints != null ? InternalUtils.mapArray(route_hints, route_hints_conv_37 => route_hints_conv_37 != null ? route_hints_conv_37.ptr : 0) : null, features == null ? 0 : features.ptr);
128 GC.KeepAlive(route_hints);
129 GC.KeepAlive(features);
130 if (ret >= 0 && ret <= 4096) { return null; }
131 org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
132 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
133 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features); };
138 * Utility method to constructs a new Clear-variant Payee
140 public static Payee clear(byte[] node_id, RouteHint[] route_hints, org.ldk.structs.Bolt11InvoiceFeatures features, int final_cltv_expiry_delta) {
141 long ret = bindings.Payee_clear(InternalUtils.check_arr_len(node_id, 33), route_hints != null ? InternalUtils.mapArray(route_hints, route_hints_conv_11 => route_hints_conv_11 == null ? 0 : route_hints_conv_11.ptr) : null, features == null ? 0 : features.ptr, final_cltv_expiry_delta);
142 GC.KeepAlive(node_id);
143 GC.KeepAlive(route_hints);
144 GC.KeepAlive(features);
145 GC.KeepAlive(final_cltv_expiry_delta);
146 if (ret >= 0 && ret <= 4096) { return null; }
147 org.ldk.structs.Payee ret_hu_conv = org.ldk.structs.Payee.constr_from_ptr(ret);
148 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
149 foreach (RouteHint route_hints_conv_11 in route_hints) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(route_hints_conv_11); }; };
150 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(features); };
155 * Generates a non-cryptographic 64-bit hash of the Payee.
158 long ret = bindings.Payee_hash(this.ptr);
163 public override int GetHashCode() {
164 return (int)this.hash();
167 * Checks if two Payees contain equal inner contents.
168 * This ignores pointers and is_owned flags and looks at the values in fields.
170 public bool eq(org.ldk.structs.Payee b) {
171 bool ret = bindings.Payee_eq(this.ptr, b == null ? 0 : b.ptr);
177 public override bool Equals(object o) {
178 if (!(o is Payee)) return false;
179 return this.eq((Payee)o);