[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / WalletSource.cs
index 4c9182825204e4617f29ae522551a7c8a3a99141..7ad196cedc970a34be90eb5301d426ff64dfbba7 100644 (file)
@@ -1,3 +1,4 @@
+
 using org.ldk.impl;
 using org.ldk.enums;
 using org.ldk.util;
@@ -5,38 +6,37 @@ using System;
 
 namespace org { namespace ldk { namespace structs {
 
+
+
+/** An implementation of WalletSource */
+public interface WalletSourceInterface {
+       /**Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
+        */
+       Result_CVec_UtxoZNoneZ list_confirmed_utxos();
+       /**Returns a script to use for change above dust resulting from a successful coin selection
+        * attempt.
+        */
+       Result_CVec_u8ZNoneZ get_change_script();
+       /**Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
+        * the transaction known to the wallet (i.e., any provided via
+        * [`WalletSource::list_confirmed_utxos`]).
+        */
+       Result_TransactionNoneZ sign_tx(byte[] tx);
+}
+
 /**
  * An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
  * provide a default implementation to [`CoinSelectionSource`].
  */
 public class WalletSource : CommonBase {
-       internal readonly bindings.LDKWalletSource bindings_instance;
+       internal bindings.LDKWalletSource bindings_instance;
+       internal long instance_idx;
+
        internal WalletSource(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
-       private WalletSource(bindings.LDKWalletSource arg) : base(bindings.LDKWalletSource_new(arg)) {
-               this.ptrs_to.AddLast(arg);
-               this.bindings_instance = arg;
-       }
        ~WalletSource() {
                if (ptr != 0) { bindings.WalletSource_free(ptr); }
        }
 
-       public interface WalletSourceInterface {
-               /**
-                * Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
-                */
-               Result_CVec_UtxoZNoneZ list_confirmed_utxos();
-               /**
-                * Returns a script to use for change above dust resulting from a successful coin selection
-                * attempt.
-                */
-               Result_ScriptNoneZ get_change_script();
-               /**
-                * Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
-                * the transaction known to the wallet (i.e., any provided via
-                * [`WalletSource::list_confirmed_utxos`]).
-                */
-               Result_TransactionNoneZ sign_tx(byte[] _tx);
-       }
        private class LDKWalletSourceHolder { internal WalletSource held; }
        private class LDKWalletSourceImpl : bindings.LDKWalletSource {
                internal LDKWalletSourceImpl(WalletSourceInterface arg, LDKWalletSourceHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
@@ -49,23 +49,32 @@ public class WalletSource : CommonBase {
                        return result;
                }
                public long get_change_script() {
-                       Result_ScriptNoneZ ret = arg.get_change_script();
+                       Result_CVec_u8ZNoneZ ret = arg.get_change_script();
                                GC.KeepAlive(arg);
                        long result = ret == null ? 0 : ret.clone_ptr();
                        return result;
                }
-               public long sign_tx(byte[] _tx) {
-                       Result_TransactionNoneZ ret = arg.sign_tx(_tx);
+               public long sign_tx(long _tx) {
+                       byte[] _tx_conv = InternalUtils.decodeUint8Array(_tx);
+                       Result_TransactionNoneZ ret = arg.sign_tx(_tx_conv);
                                GC.KeepAlive(arg);
                        long result = ret == null ? 0 : ret.clone_ptr();
                        return result;
                }
        }
+
+       /** Creates a new instance of WalletSource from a given implementation */
        public static WalletSource new_impl(WalletSourceInterface arg) {
                LDKWalletSourceHolder impl_holder = new LDKWalletSourceHolder();
-               impl_holder.held = new WalletSource(new LDKWalletSourceImpl(arg, impl_holder));
+               LDKWalletSourceImpl impl = new LDKWalletSourceImpl(arg, impl_holder);
+               long[] ptr_idx = bindings.LDKWalletSource_new(impl);
+
+               impl_holder.held = new WalletSource(null, ptr_idx[0]);
+               impl_holder.held.instance_idx = ptr_idx[1];
+               impl_holder.held.bindings_instance = impl;
                return impl_holder.held;
        }
+
        /**
         * Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
         */
@@ -81,11 +90,11 @@ public class WalletSource : CommonBase {
         * Returns a script to use for change above dust resulting from a successful coin selection
         * attempt.
         */
-       public Result_ScriptNoneZ get_change_script() {
+       public Result_CVec_u8ZNoneZ get_change_script() {
                long ret = bindings.WalletSource_get_change_script(this.ptr);
                GC.KeepAlive(this);
                if (ret >= 0 && ret <= 4096) { return null; }
-               Result_ScriptNoneZ ret_hu_conv = Result_ScriptNoneZ.constr_from_ptr(ret);
+               Result_CVec_u8ZNoneZ ret_hu_conv = Result_CVec_u8ZNoneZ.constr_from_ptr(ret);
                return ret_hu_conv;
        }
 
@@ -95,7 +104,7 @@ public class WalletSource : CommonBase {
         * [`WalletSource::list_confirmed_utxos`]).
         */
        public Result_TransactionNoneZ sign_tx(byte[] tx) {
-               long ret = bindings.WalletSource_sign_tx(this.ptr, tx);
+               long ret = bindings.WalletSource_sign_tx(this.ptr, InternalUtils.encodeUint8Array(tx));
                GC.KeepAlive(this);
                GC.KeepAlive(tx);
                if (ret >= 0 && ret <= 4096) { return null; }