6 namespace org { namespace ldk { namespace structs {
10 * Onion messages and payments can be sent and received to blinded paths, which serve to hide the
11 * identity of the recipient.
13 public class BlindedPath : CommonBase {
14 internal BlindedPath(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.BlindedPath_free(ptr); }
20 * To send to a blinded path, the sender first finds a route to the unblinded
21 * `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
22 * message or payment's next hop and forward it along.
24 * [`encrypted_payload`]: BlindedHop::encrypted_payload
26 public IntroductionNode get_introduction_node() {
27 long ret = bindings.BlindedPath_get_introduction_node(this.ptr);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 org.ldk.structs.IntroductionNode ret_hu_conv = org.ldk.structs.IntroductionNode.constr_from_ptr(ret);
31 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
36 * To send to a blinded path, the sender first finds a route to the unblinded
37 * `introduction_node`, which can unblind its [`encrypted_payload`] to find out the onion
38 * message or payment's next hop and forward it along.
40 * [`encrypted_payload`]: BlindedHop::encrypted_payload
42 public void set_introduction_node(org.ldk.structs.IntroductionNode val) {
43 bindings.BlindedPath_set_introduction_node(this.ptr, val.ptr);
46 if (this != null) { this.ptrs_to.AddLast(val); };
50 * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
53 * [`encrypted_payload`]: BlindedHop::encrypted_payload
55 public byte[] get_blinding_point() {
56 long ret = bindings.BlindedPath_get_blinding_point(this.ptr);
58 if (ret >= 0 && ret <= 4096) { return null; }
59 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
64 * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
67 * [`encrypted_payload`]: BlindedHop::encrypted_payload
69 public void set_blinding_point(byte[] val) {
70 bindings.BlindedPath_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
76 * The hops composing the blinded path.
78 public BlindedHop[] get_blinded_hops() {
79 long ret = bindings.BlindedPath_get_blinded_hops(this.ptr);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 int ret_conv_12_len = InternalUtils.getArrayLength(ret);
83 BlindedHop[] ret_conv_12_arr = new BlindedHop[ret_conv_12_len];
84 for (int m = 0; m < ret_conv_12_len; m++) {
85 long ret_conv_12 = InternalUtils.getU64ArrayElem(ret, m);
86 org.ldk.structs.BlindedHop ret_conv_12_hu_conv = null; if (ret_conv_12 < 0 || ret_conv_12 > 4096) { ret_conv_12_hu_conv = new org.ldk.structs.BlindedHop(null, ret_conv_12); }
87 if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.AddLast(this); };
88 ret_conv_12_arr[m] = ret_conv_12_hu_conv;
90 bindings.free_buffer(ret);
91 return ret_conv_12_arr;
95 * The hops composing the blinded path.
97 public void set_blinded_hops(BlindedHop[] val) {
98 bindings.BlindedPath_set_blinded_hops(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_12 => val_conv_12.ptr)));
101 foreach (BlindedHop val_conv_12 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_12); }; };
105 * Constructs a new BlindedPath given each field
107 public static BlindedPath of(org.ldk.structs.IntroductionNode introduction_node_arg, byte[] blinding_point_arg, BlindedHop[] blinded_hops_arg) {
108 long ret = bindings.BlindedPath_new(introduction_node_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(blinding_point_arg, 33)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(blinded_hops_arg, blinded_hops_arg_conv_12 => blinded_hops_arg_conv_12.ptr)));
109 GC.KeepAlive(introduction_node_arg);
110 GC.KeepAlive(blinding_point_arg);
111 GC.KeepAlive(blinded_hops_arg);
112 if (ret >= 0 && ret <= 4096) { return null; }
113 org.ldk.structs.BlindedPath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedPath(null, ret); }
114 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
115 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(introduction_node_arg); };
116 foreach (BlindedHop blinded_hops_arg_conv_12 in blinded_hops_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(blinded_hops_arg_conv_12); }; };
120 internal long clone_ptr() {
121 long ret = bindings.BlindedPath_clone_ptr(this.ptr);
127 * Creates a copy of the BlindedPath
129 public BlindedPath clone() {
130 long ret = bindings.BlindedPath_clone(this.ptr);
132 if (ret >= 0 && ret <= 4096) { return null; }
133 org.ldk.structs.BlindedPath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedPath(null, ret); }
134 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
139 * Generates a non-cryptographic 64-bit hash of the BlindedPath.
142 long ret = bindings.BlindedPath_hash(this.ptr);
147 public override int GetHashCode() {
148 return (int)this.hash();
151 * Checks if two BlindedPaths contain equal inner contents.
152 * This ignores pointers and is_owned flags and looks at the values in fields.
153 * Two objects with NULL inner values will be considered "equal" here.
155 public bool eq(org.ldk.structs.BlindedPath b) {
156 bool ret = bindings.BlindedPath_eq(this.ptr, b.ptr);
159 if (this != null) { this.ptrs_to.AddLast(b); };
163 public override bool Equals(object o) {
164 if (!(o is BlindedPath)) return false;
165 return this.eq((BlindedPath)o);
168 * Create a one-hop blinded path for a message.
170 public static Result_BlindedPathNoneZ one_hop_for_message(byte[] recipient_node_id, org.ldk.structs.EntropySource entropy_source) {
171 long ret = bindings.BlindedPath_one_hop_for_message(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(recipient_node_id, 33)), entropy_source.ptr);
172 GC.KeepAlive(recipient_node_id);
173 GC.KeepAlive(entropy_source);
174 if (ret >= 0 && ret <= 4096) { return null; }
175 Result_BlindedPathNoneZ ret_hu_conv = Result_BlindedPathNoneZ.constr_from_ptr(ret);
176 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
181 * Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node
182 * pubkey in `node_pks` will be the destination node.
184 * Errors if no hops are provided or if `node_pk`(s) are invalid.
186 public static Result_BlindedPathNoneZ new_for_message(byte[][] node_pks, org.ldk.structs.EntropySource entropy_source) {
187 long ret = bindings.BlindedPath_new_for_message(InternalUtils.encodeUint64Array(InternalUtils.mapArray(node_pks, node_pks_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(node_pks_conv_8, 33)))), entropy_source.ptr);
188 GC.KeepAlive(node_pks);
189 GC.KeepAlive(entropy_source);
190 if (ret >= 0 && ret <= 4096) { return null; }
191 Result_BlindedPathNoneZ ret_hu_conv = Result_BlindedPathNoneZ.constr_from_ptr(ret);
192 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
197 * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e.,
198 * it is found in the network graph).
200 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
202 public NodeId public_introduction_node_id(org.ldk.structs.ReadOnlyNetworkGraph network_graph) {
203 long ret = bindings.BlindedPath_public_introduction_node_id(this.ptr, network_graph.ptr);
205 GC.KeepAlive(network_graph);
206 if (ret >= 0 && ret <= 4096) { return null; }
207 org.ldk.structs.NodeId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.NodeId(null, ret); }
208 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
209 if (this != null) { this.ptrs_to.AddLast(network_graph); };
214 * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read
216 public byte[] write() {
217 long ret = bindings.BlindedPath_write(this.ptr);
219 if (ret >= 0 && ret <= 4096) { return null; }
220 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
225 * Read a BlindedPath from a byte array, created by BlindedPath_write
227 public static Result_BlindedPathDecodeErrorZ read(byte[] ser) {
228 long ret = bindings.BlindedPath_read(InternalUtils.encodeUint8Array(ser));
230 if (ret >= 0 && ret <= 4096) { return null; }
231 Result_BlindedPathDecodeErrorZ ret_hu_conv = Result_BlindedPathDecodeErrorZ.constr_from_ptr(ret);