[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / EntropySource.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of EntropySource */
12 public interface EntropySourceInterface {
13         /**Gets a unique, cryptographically-secure, random 32-byte value. This method must return a
14          * different value each time it is called.
15          */
16         byte[] get_secure_random_bytes();
17 }
18
19 /**
20  * A trait that describes a source of entropy.
21  */
22 public class EntropySource : CommonBase {
23         internal bindings.LDKEntropySource bindings_instance;
24         internal long instance_idx;
25
26         internal EntropySource(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
27         ~EntropySource() {
28                 if (ptr != 0) { bindings.EntropySource_free(ptr); }
29         }
30
31         private class LDKEntropySourceHolder { internal EntropySource held; }
32         private class LDKEntropySourceImpl : bindings.LDKEntropySource {
33                 internal LDKEntropySourceImpl(EntropySourceInterface arg, LDKEntropySourceHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
34                 private EntropySourceInterface arg;
35                 private LDKEntropySourceHolder impl_holder;
36                 public long get_secure_random_bytes() {
37                         byte[] ret = arg.get_secure_random_bytes();
38                                 GC.KeepAlive(arg);
39                         long result = InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(ret, 32));
40                         return result;
41                 }
42         }
43
44         /** Creates a new instance of EntropySource from a given implementation */
45         public static EntropySource new_impl(EntropySourceInterface arg) {
46                 LDKEntropySourceHolder impl_holder = new LDKEntropySourceHolder();
47                 LDKEntropySourceImpl impl = new LDKEntropySourceImpl(arg, impl_holder);
48                 long[] ptr_idx = bindings.LDKEntropySource_new(impl);
49
50                 impl_holder.held = new EntropySource(null, ptr_idx[0]);
51                 impl_holder.held.instance_idx = ptr_idx[1];
52                 impl_holder.held.bindings_instance = impl;
53                 return impl_holder.held;
54         }
55
56         /**
57          * Gets a unique, cryptographically-secure, random 32-byte value. This method must return a
58          * different value each time it is called.
59          */
60         public byte[] get_secure_random_bytes() {
61                 long ret = bindings.EntropySource_get_secure_random_bytes(this.ptr);
62                 GC.KeepAlive(this);
63                 if (ret >= 0 && ret <= 4096) { return null; }
64                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
65                 return ret_conv;
66         }
67
68 }
69 } } }