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