[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Filter.cs
index 239fb060f97cfc10de9cc97916a3eda8c09e678b..32fb570e1abeb195ae3a23427350203d25908834 100644 (file)
@@ -1,3 +1,4 @@
+
 using org.ldk.impl;
 using org.ldk.enums;
 using org.ldk.util;
@@ -5,6 +6,24 @@ using System;
 
 namespace org { namespace ldk { namespace structs {
 
+
+
+/** An implementation of Filter */
+public interface FilterInterface {
+       /**Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
+        * a spending condition.
+        */
+       void register_tx(byte[] txid, byte[] script_pubkey);
+       /**Registers interest in spends of a transaction output.
+        * 
+        * Note that this method might be called during processing of a new block. You therefore need
+        * to ensure that also dependent output spents within an already connected block are correctly
+        * handled, e.g., by re-scanning the block in question whenever new outputs have been
+        * registered mid-processing.
+        */
+       void register_output(WatchedOutput output);
+}
+
 /**
  * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to
  * channels.
@@ -28,39 +47,23 @@ namespace org { namespace ldk { namespace structs {
  * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki
  */
 public class Filter : CommonBase {
-       internal readonly bindings.LDKFilter bindings_instance;
+       internal bindings.LDKFilter bindings_instance;
+       internal long instance_idx;
+
        internal Filter(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
-       private Filter(bindings.LDKFilter arg) : base(bindings.LDKFilter_new(arg)) {
-               this.ptrs_to.AddLast(arg);
-               this.bindings_instance = arg;
-       }
        ~Filter() {
                if (ptr != 0) { bindings.Filter_free(ptr); }
        }
 
-       public interface FilterInterface {
-               /**
-                * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
-                * a spending condition.
-                */
-               void register_tx(byte[] _txid, byte[] _script_pubkey);
-               /**
-                * Registers interest in spends of a transaction output.
-                * 
-                * Note that this method might be called during processing of a new block. You therefore need
-                * to ensure that also dependent output spents within an already connected block are correctly
-                * handled, e.g., by re-scanning the block in question whenever new outputs have been
-                * registered mid-processing.
-                */
-               void register_output(WatchedOutput _output);
-       }
        private class LDKFilterHolder { internal Filter held; }
        private class LDKFilterImpl : bindings.LDKFilter {
                internal LDKFilterImpl(FilterInterface arg, LDKFilterHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
                private FilterInterface arg;
                private LDKFilterHolder impl_holder;
-               public void register_tx(byte[] _txid, byte[] _script_pubkey) {
-                       arg.register_tx(_txid, _script_pubkey);
+               public void register_tx(long _txid, long _script_pubkey) {
+                       byte[] _txid_conv = InternalUtils.decodeUint8Array(_txid);
+                       byte[] _script_pubkey_conv = InternalUtils.decodeUint8Array(_script_pubkey);
+                       arg.register_tx(_txid_conv, _script_pubkey_conv);
                                GC.KeepAlive(arg);
                }
                public void register_output(long _output) {
@@ -70,17 +73,25 @@ public class Filter : CommonBase {
                                GC.KeepAlive(arg);
                }
        }
+
+       /** Creates a new instance of Filter from a given implementation */
        public static Filter new_impl(FilterInterface arg) {
                LDKFilterHolder impl_holder = new LDKFilterHolder();
-               impl_holder.held = new Filter(new LDKFilterImpl(arg, impl_holder));
+               LDKFilterImpl impl = new LDKFilterImpl(arg, impl_holder);
+               long[] ptr_idx = bindings.LDKFilter_new(impl);
+
+               impl_holder.held = new Filter(null, ptr_idx[0]);
+               impl_holder.held.instance_idx = ptr_idx[1];
+               impl_holder.held.bindings_instance = impl;
                return impl_holder.held;
        }
+
        /**
         * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as
         * a spending condition.
         */
        public void register_tx(byte[] txid, byte[] script_pubkey) {
-               bindings.Filter_register_tx(this.ptr, InternalUtils.check_arr_len(txid, 32), script_pubkey);
+               bindings.Filter_register_tx(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(txid, 32)), InternalUtils.encodeUint8Array(script_pubkey));
                GC.KeepAlive(this);
                GC.KeepAlive(txid);
                GC.KeepAlive(script_pubkey);