1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Onion messages can be sent and received to blinded paths, which serve to hide the identity of
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class BlindedPath extends CommonBase {
17 BlindedPath(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.BlindedPath_free(ptr); }
25 long ret = bindings.BlindedPath_clone_ptr(this.ptr);
26 Reference.reachabilityFence(this);
31 * Creates a copy of the BlindedPath
33 public BlindedPath clone() {
34 long ret = bindings.BlindedPath_clone(this.ptr);
35 Reference.reachabilityFence(this);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 org.ldk.structs.BlindedPath ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedPath(null, ret); }
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
43 * Create a blinded path to be forwarded along `node_pks`. The last node pubkey in `node_pks`
44 * will be the destination node.
46 * Errors if less than two hops are provided or if `node_pk`(s) are invalid.
48 public static Result_BlindedPathNoneZ of(byte[][] node_pks, org.ldk.structs.EntropySource entropy_source) {
49 long ret = bindings.BlindedPath_new(node_pks != null ? Arrays.stream(node_pks).map(node_pks_conv_8 -> InternalUtils.check_arr_len(node_pks_conv_8, 33)).toArray(byte[][]::new) : null, entropy_source == null ? 0 : entropy_source.ptr);
50 Reference.reachabilityFence(node_pks);
51 Reference.reachabilityFence(entropy_source);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 Result_BlindedPathNoneZ ret_hu_conv = Result_BlindedPathNoneZ.constr_from_ptr(ret);
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
59 * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read
61 public byte[] write() {
62 byte[] ret = bindings.BlindedPath_write(this.ptr);
63 Reference.reachabilityFence(this);
68 * Read a BlindedPath from a byte array, created by BlindedPath_write
70 public static Result_BlindedPathDecodeErrorZ read(byte[] ser) {
71 long ret = bindings.BlindedPath_read(ser);
72 Reference.reachabilityFence(ser);
73 if (ret >= 0 && ret <= 4096) { return null; }
74 Result_BlindedPathDecodeErrorZ ret_hu_conv = Result_BlindedPathDecodeErrorZ.constr_from_ptr(ret);