]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/RandomBytes.java
[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / RandomBytes.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  * An implementation of [`EntropySource`] using ChaCha20.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class RandomBytes extends CommonBase {
16         RandomBytes(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.RandomBytes_free(ptr); }
21         }
22
23         /**
24          * Creates a new instance using the given seed.
25          */
26         public static RandomBytes of(byte[] seed) {
27                 long ret = bindings.RandomBytes_new(InternalUtils.check_arr_len(seed, 32));
28                 Reference.reachabilityFence(seed);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.RandomBytes ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RandomBytes(null, ret); }
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * Constructs a new EntropySource which calls the relevant methods on this_arg.
37          * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
38          */
39         public EntropySource as_EntropySource() {
40                 long ret = bindings.RandomBytes_as_EntropySource(this.ptr);
41                 Reference.reachabilityFence(this);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 EntropySource ret_hu_conv = new EntropySource(null, ret);
44                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
45                 return ret_hu_conv;
46         }
47
48 }