[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / RandomBytes.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * An implementation of [`EntropySource`] using ChaCha20.
11  */
12 public class RandomBytes : CommonBase {
13         internal RandomBytes(object _dummy, long ptr) : base(ptr) { }
14         ~RandomBytes() {
15                 if (ptr != 0) { bindings.RandomBytes_free(ptr); }
16         }
17
18         /**
19          * Creates a new instance using the given seed.
20          */
21         public static RandomBytes of(byte[] seed) {
22                 long ret = bindings.RandomBytes_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(seed, 32)));
23                 GC.KeepAlive(seed);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 org.ldk.structs.RandomBytes ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RandomBytes(null, ret); }
26                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
27                 return ret_hu_conv;
28         }
29
30         /**
31          * Constructs a new EntropySource which calls the relevant methods on this_arg.
32          * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is
33          */
34         public EntropySource as_EntropySource() {
35                 long ret = bindings.RandomBytes_as_EntropySource(this.ptr);
36                 GC.KeepAlive(this);
37                 if (ret >= 0 && ret <= 4096) { return null; }
38                 EntropySource ret_hu_conv = new EntropySource(null, ret);
39                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
40                 return ret_hu_conv;
41         }
42
43 }
44 } } }