[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Listen.cs
index 44a2652279c2c227f8d56b8dcc256f43be3a8641..fa31f7146fb3764782bffb6f0b712f5b09390aeb 100644 (file)
@@ -1,3 +1,4 @@
+
 using org.ldk.impl;
 using org.ldk.enums;
 using org.ldk.util;
@@ -5,6 +6,22 @@ using System;
 
 namespace org { namespace ldk { namespace structs {
 
+
+
+/** An implementation of Listen */
+public interface ListenInterface {
+       /**Notifies the listener that a block was added at the given height, with the transaction data
+        * possibly filtered.
+        */
+       void filtered_block_connected(byte[] header, TwoTuple_usizeTransactionZ[] txdata, int height);
+       /**Notifies the listener that a block was added at the given height.
+        */
+       void block_connected(byte[] block, int height);
+       /**Notifies the listener that a block was removed at the given height.
+        */
+       void block_disconnected(byte[] header, int height);
+}
+
 /**
  * The `Listen` trait is used to notify when blocks have been connected or disconnected from the
  * chain.
@@ -19,68 +36,63 @@ namespace org { namespace ldk { namespace structs {
  * other similar filtering.
  */
 public class Listen : CommonBase {
-       internal readonly bindings.LDKListen bindings_instance;
+       internal bindings.LDKListen bindings_instance;
+       internal long instance_idx;
+
        internal Listen(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
-       private Listen(bindings.LDKListen arg) : base(bindings.LDKListen_new(arg)) {
-               this.ptrs_to.AddLast(arg);
-               this.bindings_instance = arg;
-       }
        ~Listen() {
                if (ptr != 0) { bindings.Listen_free(ptr); }
        }
 
-       public interface ListenInterface {
-               /**
-                * Notifies the listener that a block was added at the given height, with the transaction data
-                * possibly filtered.
-                */
-               void filtered_block_connected(byte[] _header, TwoTuple_usizeTransactionZ[] _txdata, int _height);
-               /**
-                * Notifies the listener that a block was added at the given height.
-                */
-               void block_connected(byte[] _block, int _height);
-               /**
-                * Notifies the listener that a block was removed at the given height.
-                */
-               void block_disconnected(byte[] _header, int _height);
-       }
        private class LDKListenHolder { internal Listen held; }
        private class LDKListenImpl : bindings.LDKListen {
                internal LDKListenImpl(ListenInterface arg, LDKListenHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
                private ListenInterface arg;
                private LDKListenHolder impl_holder;
-               public void filtered_block_connected(byte[] _header, long[] _txdata, int _height) {
-                       int _txdata_conv_28_len = _txdata.Length;
+               public void filtered_block_connected(long _header, long _txdata, int _height) {
+                       byte[] _header_conv = InternalUtils.decodeUint8Array(_header);
+                       int _txdata_conv_28_len = InternalUtils.getArrayLength(_txdata);
                        TwoTuple_usizeTransactionZ[] _txdata_conv_28_arr = new TwoTuple_usizeTransactionZ[_txdata_conv_28_len];
                        for (int c = 0; c < _txdata_conv_28_len; c++) {
-                               long _txdata_conv_28 = _txdata[c];
+                               long _txdata_conv_28 = InternalUtils.getU64ArrayElem(_txdata, c);
                                TwoTuple_usizeTransactionZ _txdata_conv_28_hu_conv = new TwoTuple_usizeTransactionZ(null, _txdata_conv_28);
                                if (_txdata_conv_28_hu_conv != null) { _txdata_conv_28_hu_conv.ptrs_to.AddLast(this); };
                                _txdata_conv_28_arr[c] = _txdata_conv_28_hu_conv;
                        }
-                       arg.filtered_block_connected(_header, _txdata_conv_28_arr, _height);
+                       bindings.free_buffer(_txdata);
+                       arg.filtered_block_connected(_header_conv, _txdata_conv_28_arr, _height);
                                GC.KeepAlive(arg);
                }
-               public void block_connected(byte[] _block, int _height) {
-                       arg.block_connected(_block, _height);
+               public void block_connected(long _block, int _height) {
+                       byte[] _block_conv = InternalUtils.decodeUint8Array(_block);
+                       arg.block_connected(_block_conv, _height);
                                GC.KeepAlive(arg);
                }
-               public void block_disconnected(byte[] _header, int _height) {
-                       arg.block_disconnected(_header, _height);
+               public void block_disconnected(long _header, int _height) {
+                       byte[] _header_conv = InternalUtils.decodeUint8Array(_header);
+                       arg.block_disconnected(_header_conv, _height);
                                GC.KeepAlive(arg);
                }
        }
+
+       /** Creates a new instance of Listen from a given implementation */
        public static Listen new_impl(ListenInterface arg) {
                LDKListenHolder impl_holder = new LDKListenHolder();
-               impl_holder.held = new Listen(new LDKListenImpl(arg, impl_holder));
+               LDKListenImpl impl = new LDKListenImpl(arg, impl_holder);
+               long[] ptr_idx = bindings.LDKListen_new(impl);
+
+               impl_holder.held = new Listen(null, ptr_idx[0]);
+               impl_holder.held.instance_idx = ptr_idx[1];
+               impl_holder.held.bindings_instance = impl;
                return impl_holder.held;
        }
+
        /**
         * Notifies the listener that a block was added at the given height, with the transaction data
         * possibly filtered.
         */
        public void filtered_block_connected(byte[] header, TwoTuple_usizeTransactionZ[] txdata, int height) {
-               bindings.Listen_filtered_block_connected(this.ptr, InternalUtils.check_arr_len(header, 80), txdata != null ? InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28 != null ? txdata_conv_28.ptr : 0) : null, height);
+               bindings.Listen_filtered_block_connected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28 != null ? txdata_conv_28.ptr : 0)), height);
                GC.KeepAlive(this);
                GC.KeepAlive(header);
                GC.KeepAlive(txdata);
@@ -91,7 +103,7 @@ public class Listen : CommonBase {
         * Notifies the listener that a block was added at the given height.
         */
        public void block_connected(byte[] block, int height) {
-               bindings.Listen_block_connected(this.ptr, block, height);
+               bindings.Listen_block_connected(this.ptr, InternalUtils.encodeUint8Array(block), height);
                GC.KeepAlive(this);
                GC.KeepAlive(block);
                GC.KeepAlive(height);
@@ -101,7 +113,7 @@ public class Listen : CommonBase {
         * Notifies the listener that a block was removed at the given height.
         */
        public void block_disconnected(byte[] header, int height) {
-               bindings.Listen_block_disconnected(this.ptr, InternalUtils.check_arr_len(header, 80), height);
+               bindings.Listen_block_disconnected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), height);
                GC.KeepAlive(this);
                GC.KeepAlive(header);
                GC.KeepAlive(height);