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_id`, 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 byte[] get_introduction_node_id() {
27 long ret = bindings.BlindedPath_get_introduction_node_id(this.ptr);
29 if (ret >= 0 && ret <= 4096) { return null; }
30 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
35 * To send to a blinded path, the sender first finds a route to the unblinded
36 * `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion
37 * message or payment's next hop and forward it along.
39 * [`encrypted_payload`]: BlindedHop::encrypted_payload
41 public void set_introduction_node_id(byte[] val) {
42 bindings.BlindedPath_set_introduction_node_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
48 * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
51 * [`encrypted_payload`]: BlindedHop::encrypted_payload
53 public byte[] get_blinding_point() {
54 long ret = bindings.BlindedPath_get_blinding_point(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
62 * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion
65 * [`encrypted_payload`]: BlindedHop::encrypted_payload
67 public void set_blinding_point(byte[] val) {
68 bindings.BlindedPath_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
74 * The hops composing the blinded path.
76 public BlindedHop[] get_blinded_hops() {
77 long ret = bindings.BlindedPath_get_blinded_hops(this.ptr);
79 if (ret >= 0 && ret <= 4096) { return null; }
80 int ret_conv_12_len = InternalUtils.getArrayLength(ret);
81 BlindedHop[] ret_conv_12_arr = new BlindedHop[ret_conv_12_len];
82 for (int m = 0; m < ret_conv_12_len; m++) {
83 long ret_conv_12 = InternalUtils.getU64ArrayElem(ret, m);
84 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); }
85 if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.AddLast(this); };
86 ret_conv_12_arr[m] = ret_conv_12_hu_conv;
88 bindings.free_buffer(ret);
89 return ret_conv_12_arr;
93 * The hops composing the blinded path.
95 public void set_blinded_hops(BlindedHop[] val) {
96 bindings.BlindedPath_set_blinded_hops(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_12 => val_conv_12 == null ? 0 : val_conv_12.ptr)));
99 foreach (BlindedHop val_conv_12 in val) { if (this != null) { this.ptrs_to.AddLast(val_conv_12); }; };
103 * Constructs a new BlindedPath given each field
105 public static BlindedPath of(byte[] introduction_node_id_arg, byte[] blinding_point_arg, BlindedHop[] blinded_hops_arg) {
106 long ret = bindings.BlindedPath_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(introduction_node_id_arg, 33)), 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 == null ? 0 : blinded_hops_arg_conv_12.ptr)));
107 GC.KeepAlive(introduction_node_id_arg);
108 GC.KeepAlive(blinding_point_arg);
109 GC.KeepAlive(blinded_hops_arg);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 org.ldk.structs.BlindedPath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedPath(null, ret); }
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
113 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); }; };
117 internal long clone_ptr() {
118 long ret = bindings.BlindedPath_clone_ptr(this.ptr);
124 * Creates a copy of the BlindedPath
126 public BlindedPath clone() {
127 long ret = bindings.BlindedPath_clone(this.ptr);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.BlindedPath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedPath(null, ret); }
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
136 * Generates a non-cryptographic 64-bit hash of the BlindedPath.
139 long ret = bindings.BlindedPath_hash(this.ptr);
144 public override int GetHashCode() {
145 return (int)this.hash();
148 * Checks if two BlindedPaths contain equal inner contents.
149 * This ignores pointers and is_owned flags and looks at the values in fields.
150 * Two objects with NULL inner values will be considered "equal" here.
152 public bool eq(org.ldk.structs.BlindedPath b) {
153 bool ret = bindings.BlindedPath_eq(this.ptr, b == null ? 0 : b.ptr);
156 if (this != null) { this.ptrs_to.AddLast(b); };
160 public override bool Equals(object o) {
161 if (!(o is BlindedPath)) return false;
162 return this.eq((BlindedPath)o);
165 * Create a one-hop blinded path for a message.
167 public static Result_BlindedPathNoneZ one_hop_for_message(byte[] recipient_node_id, org.ldk.structs.EntropySource entropy_source) {
168 long ret = bindings.BlindedPath_one_hop_for_message(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(recipient_node_id, 33)), entropy_source.ptr);
169 GC.KeepAlive(recipient_node_id);
170 GC.KeepAlive(entropy_source);
171 if (ret >= 0 && ret <= 4096) { return null; }
172 Result_BlindedPathNoneZ ret_hu_conv = Result_BlindedPathNoneZ.constr_from_ptr(ret);
173 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
178 * Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node
179 * pubkey in `node_pks` will be the destination node.
181 * Errors if no hops are provided or if `node_pk`(s) are invalid.
183 public static Result_BlindedPathNoneZ new_for_message(byte[][] node_pks, org.ldk.structs.EntropySource entropy_source) {
184 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);
185 GC.KeepAlive(node_pks);
186 GC.KeepAlive(entropy_source);
187 if (ret >= 0 && ret <= 4096) { return null; }
188 Result_BlindedPathNoneZ ret_hu_conv = Result_BlindedPathNoneZ.constr_from_ptr(ret);
189 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(entropy_source); };
194 * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read
196 public byte[] write() {
197 long ret = bindings.BlindedPath_write(this.ptr);
199 if (ret >= 0 && ret <= 4096) { return null; }
200 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
205 * Read a BlindedPath from a byte array, created by BlindedPath_write
207 public static Result_BlindedPathDecodeErrorZ read(byte[] ser) {
208 long ret = bindings.BlindedPath_read(InternalUtils.encodeUint8Array(ser));
210 if (ret >= 0 && ret <= 4096) { return null; }
211 Result_BlindedPathDecodeErrorZ ret_hu_conv = Result_BlindedPathDecodeErrorZ.constr_from_ptr(ret);