[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / EntropySource.cs
index 5a9cecf5bc03f013bb5a43dd7a8f564827ad0786..f400924edd2dda1fc204f51b74b1ac681fb5da8b 100644 (file)
@@ -1,3 +1,4 @@
+
 using org.ldk.impl;
 using org.ldk.enums;
 using org.ldk.util;
@@ -5,52 +6,63 @@ using System;
 
 namespace org { namespace ldk { namespace structs {
 
+
+
+/** An implementation of EntropySource */
+public interface EntropySourceInterface {
+       /**Gets a unique, cryptographically-secure, random 32-byte value. This method must return a
+        * different value each time it is called.
+        */
+       byte[] get_secure_random_bytes();
+}
+
 /**
  * A trait that describes a source of entropy.
  */
 public class EntropySource : CommonBase {
-       internal readonly bindings.LDKEntropySource bindings_instance;
+       internal bindings.LDKEntropySource bindings_instance;
+       internal long instance_idx;
+
        internal EntropySource(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
-       private EntropySource(bindings.LDKEntropySource arg) : base(bindings.LDKEntropySource_new(arg)) {
-               this.ptrs_to.AddLast(arg);
-               this.bindings_instance = arg;
-       }
        ~EntropySource() {
                if (ptr != 0) { bindings.EntropySource_free(ptr); }
        }
 
-       public interface EntropySourceInterface {
-               /**
-                * Gets a unique, cryptographically-secure, random 32-byte value. This method must return a
-                * different value each time it is called.
-                */
-               byte[] get_secure_random_bytes();
-       }
        private class LDKEntropySourceHolder { internal EntropySource held; }
        private class LDKEntropySourceImpl : bindings.LDKEntropySource {
                internal LDKEntropySourceImpl(EntropySourceInterface arg, LDKEntropySourceHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
                private EntropySourceInterface arg;
                private LDKEntropySourceHolder impl_holder;
-               public byte[] get_secure_random_bytes() {
+               public long get_secure_random_bytes() {
                        byte[] ret = arg.get_secure_random_bytes();
                                GC.KeepAlive(arg);
-                       byte[] result = InternalUtils.check_arr_len(ret, 32);
+                       long result = InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(ret, 32));
                        return result;
                }
        }
+
+       /** Creates a new instance of EntropySource from a given implementation */
        public static EntropySource new_impl(EntropySourceInterface arg) {
                LDKEntropySourceHolder impl_holder = new LDKEntropySourceHolder();
-               impl_holder.held = new EntropySource(new LDKEntropySourceImpl(arg, impl_holder));
+               LDKEntropySourceImpl impl = new LDKEntropySourceImpl(arg, impl_holder);
+               long[] ptr_idx = bindings.LDKEntropySource_new(impl);
+
+               impl_holder.held = new EntropySource(null, ptr_idx[0]);
+               impl_holder.held.instance_idx = ptr_idx[1];
+               impl_holder.held.bindings_instance = impl;
                return impl_holder.held;
        }
+
        /**
         * Gets a unique, cryptographically-secure, random 32-byte value. This method must return a
         * different value each time it is called.
         */
        public byte[] get_secure_random_bytes() {
-               byte[] ret = bindings.EntropySource_get_secure_random_bytes(this.ptr);
+               long ret = bindings.EntropySource_get_secure_random_bytes(this.ptr);
                GC.KeepAlive(this);
-               return ret;
+               if (ret >= 0 && ret <= 4096) { return null; }
+               byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
+               return ret_conv;
        }
 
 }