[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / WalletSource.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 WalletSource */
12 public interface WalletSourceInterface {
13         /**Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
14          */
15         Result_CVec_UtxoZNoneZ list_confirmed_utxos();
16         /**Returns a script to use for change above dust resulting from a successful coin selection
17          * attempt.
18          */
19         Result_CVec_u8ZNoneZ get_change_script();
20         /**Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
21          * the transaction known to the wallet (i.e., any provided via
22          * [`WalletSource::list_confirmed_utxos`]).
23          */
24         Result_TransactionNoneZ sign_tx(byte[] tx);
25 }
26
27 /**
28  * An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
29  * provide a default implementation to [`CoinSelectionSource`].
30  */
31 public class WalletSource : CommonBase {
32         internal bindings.LDKWalletSource bindings_instance;
33         internal long instance_idx;
34
35         internal WalletSource(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
36         ~WalletSource() {
37                 if (ptr != 0) { bindings.WalletSource_free(ptr); }
38         }
39
40         private class LDKWalletSourceHolder { internal WalletSource held; }
41         private class LDKWalletSourceImpl : bindings.LDKWalletSource {
42                 internal LDKWalletSourceImpl(WalletSourceInterface arg, LDKWalletSourceHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
43                 private WalletSourceInterface arg;
44                 private LDKWalletSourceHolder impl_holder;
45                 public long list_confirmed_utxos() {
46                         Result_CVec_UtxoZNoneZ ret = arg.list_confirmed_utxos();
47                                 GC.KeepAlive(arg);
48                         long result = ret == null ? 0 : ret.clone_ptr();
49                         return result;
50                 }
51                 public long get_change_script() {
52                         Result_CVec_u8ZNoneZ ret = arg.get_change_script();
53                                 GC.KeepAlive(arg);
54                         long result = ret == null ? 0 : ret.clone_ptr();
55                         return result;
56                 }
57                 public long sign_tx(long _tx) {
58                         byte[] _tx_conv = InternalUtils.decodeUint8Array(_tx);
59                         Result_TransactionNoneZ ret = arg.sign_tx(_tx_conv);
60                                 GC.KeepAlive(arg);
61                         long result = ret == null ? 0 : ret.clone_ptr();
62                         return result;
63                 }
64         }
65
66         /** Creates a new instance of WalletSource from a given implementation */
67         public static WalletSource new_impl(WalletSourceInterface arg) {
68                 LDKWalletSourceHolder impl_holder = new LDKWalletSourceHolder();
69                 LDKWalletSourceImpl impl = new LDKWalletSourceImpl(arg, impl_holder);
70                 long[] ptr_idx = bindings.LDKWalletSource_new(impl);
71
72                 impl_holder.held = new WalletSource(null, ptr_idx[0]);
73                 impl_holder.held.instance_idx = ptr_idx[1];
74                 impl_holder.held.bindings_instance = impl;
75                 return impl_holder.held;
76         }
77
78         /**
79          * Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
80          */
81         public Result_CVec_UtxoZNoneZ list_confirmed_utxos() {
82                 long ret = bindings.WalletSource_list_confirmed_utxos(this.ptr);
83                 GC.KeepAlive(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 Result_CVec_UtxoZNoneZ ret_hu_conv = Result_CVec_UtxoZNoneZ.constr_from_ptr(ret);
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Returns a script to use for change above dust resulting from a successful coin selection
91          * attempt.
92          */
93         public Result_CVec_u8ZNoneZ get_change_script() {
94                 long ret = bindings.WalletSource_get_change_script(this.ptr);
95                 GC.KeepAlive(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 Result_CVec_u8ZNoneZ ret_hu_conv = Result_CVec_u8ZNoneZ.constr_from_ptr(ret);
98                 return ret_hu_conv;
99         }
100
101         /**
102          * Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
103          * the transaction known to the wallet (i.e., any provided via
104          * [`WalletSource::list_confirmed_utxos`]).
105          */
106         public Result_TransactionNoneZ sign_tx(byte[] tx) {
107                 long ret = bindings.WalletSource_sign_tx(this.ptr, InternalUtils.encodeUint8Array(tx));
108                 GC.KeepAlive(this);
109                 GC.KeepAlive(tx);
110                 if (ret >= 0 && ret <= 4096) { return null; }
111                 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
112                 return ret_hu_conv;
113         }
114
115 }
116 } } }