5432512ef5c7c4851469d12a1088fe620572228b
[ldk-java] / src / main / java / org / ldk / structs / BlindedHop.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  * Used to construct the blinded hops portion of a blinded route. These hops cannot be identified
13  * by outside observers and thus can be used to hide the identity of the recipient.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class BlindedHop extends CommonBase {
17         BlindedHop(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.BlindedHop_free(ptr); }
22         }
23
24         /**
25          * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read
26          */
27         public byte[] write() {
28                 byte[] ret = bindings.BlindedHop_write(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * Read a BlindedHop from a byte array, created by BlindedHop_write
35          */
36         public static Result_BlindedHopDecodeErrorZ read(byte[] ser) {
37                 long ret = bindings.BlindedHop_read(ser);
38                 Reference.reachabilityFence(ser);
39                 if (ret >= 0 && ret <= 4096) { return null; }
40                 Result_BlindedHopDecodeErrorZ ret_hu_conv = Result_BlindedHopDecodeErrorZ.constr_from_ptr(ret);
41                 return ret_hu_conv;
42         }
43
44 }