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 = 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;
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;
62 /** A Payee of type Clear */
63 public class Payee_Clear : Payee {
65 * The node id of the payee.
67 public byte[] node_id;
69 * Hints for routing to the payee, containing channels connecting the payee to public nodes.
71 public RouteHint[] route_hints;
73 * Features supported by the payee.
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.
78 * [`for_keysend`]: PaymentParameters::for_keysend
80 * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None
82 public Bolt11InvoiceFeatures features;
84 * The minimum CLTV delta at the end of the route. This value must not be zero.
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;
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);
109 internal long clone_ptr() {
110 long ret = bindings.Payee_clone_ptr(this.ptr);
116 * Creates a copy of the Payee
118 public Payee clone() {
119 long ret = bindings.Payee_clone(this.ptr);
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); };
128 * Utility method to constructs a new Blinded-variant Payee
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.ptr)), 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); };
142 * Utility method to constructs a new Clear-variant Payee
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.ptr)), 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); };
159 * Generates a non-cryptographic 64-bit hash of the Payee.
162 long ret = bindings.Payee_hash(this.ptr);
167 public override int GetHashCode() {
168 return (int)this.hash();
171 * Checks if two Payees contain equal inner contents.
172 * This ignores pointers and is_owned flags and looks at the values in fields.
174 public bool eq(org.ldk.structs.Payee b) {
175 bool ret = bindings.Payee_eq(this.ptr, b.ptr);
181 public override bool Equals(object o) {
182 if (!(o is Payee)) return false;
183 return this.eq((Payee)o);