[Java] Update auto-generated Java bindings for 0.0.113
[ldk-java] / src / main / java / org / ldk / structs / BlindedPath.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Onion messages can be sent and received to blinded paths, which serve to hide the identity of
13  * the recipient.
14  */
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 {
20                 super.finalize();
21                 if (ptr != 0) { bindings.BlindedPath_free(ptr); }
22         }
23
24         long clone_ptr() {
25                 long ret = bindings.BlindedPath_clone_ptr(this.ptr);
26                 Reference.reachabilityFence(this);
27                 return ret;
28         }
29
30         /**
31          * Creates a copy of the BlindedPath
32          */
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); };
39                 return ret_hu_conv;
40         }
41
42         /**
43          * Create a blinded path to be forwarded along `node_pks`. The last node pubkey in `node_pks`
44          * will be the destination node.
45          * 
46          * Errors if less than two hops are provided or if `node_pk`(s) are invalid.
47          */
48         public static Result_BlindedPathNoneZ of(byte[][] node_pks, org.ldk.structs.KeysInterface keys_manager) {
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, keys_manager == null ? 0 : keys_manager.ptr);
50                 Reference.reachabilityFence(node_pks);
51                 Reference.reachabilityFence(keys_manager);
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(keys_manager); };
55                 return ret_hu_conv;
56         }
57
58         /**
59          * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read
60          */
61         public byte[] write() {
62                 byte[] ret = bindings.BlindedPath_write(this.ptr);
63                 Reference.reachabilityFence(this);
64                 return ret;
65         }
66
67         /**
68          * Read a BlindedPath from a byte array, created by BlindedPath_write
69          */
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);
75                 return ret_hu_conv;
76         }
77
78 }