6 namespace org { namespace ldk { namespace structs {
9 * An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
10 * provide a default implementation to [`CoinSelectionSource`].
12 public class WalletSource : CommonBase {
13 internal readonly bindings.LDKWalletSource bindings_instance;
14 internal WalletSource(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
15 private WalletSource(bindings.LDKWalletSource arg) : base(bindings.LDKWalletSource_new(arg)) {
16 this.ptrs_to.AddLast(arg);
17 this.bindings_instance = arg;
20 if (ptr != 0) { bindings.WalletSource_free(ptr); }
23 public interface WalletSourceInterface {
25 * Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
27 Result_CVec_UtxoZNoneZ list_confirmed_utxos();
29 * Returns a script to use for change above dust resulting from a successful coin selection
32 Result_ScriptNoneZ get_change_script();
34 * Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
35 * the transaction known to the wallet (i.e., any provided via
36 * [`WalletSource::list_confirmed_utxos`]).
38 Result_TransactionNoneZ sign_tx(byte[] _tx);
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();
48 long result = ret == null ? 0 : ret.clone_ptr();
51 public long get_change_script() {
52 Result_ScriptNoneZ ret = arg.get_change_script();
54 long result = ret == null ? 0 : ret.clone_ptr();
57 public long sign_tx(byte[] _tx) {
58 Result_TransactionNoneZ ret = arg.sign_tx(_tx);
60 long result = ret == null ? 0 : ret.clone_ptr();
64 public static WalletSource new_impl(WalletSourceInterface arg) {
65 LDKWalletSourceHolder impl_holder = new LDKWalletSourceHolder();
66 impl_holder.held = new WalletSource(new LDKWalletSourceImpl(arg, impl_holder));
67 return impl_holder.held;
70 * Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
72 public Result_CVec_UtxoZNoneZ list_confirmed_utxos() {
73 long ret = bindings.WalletSource_list_confirmed_utxos(this.ptr);
75 if (ret >= 0 && ret <= 4096) { return null; }
76 Result_CVec_UtxoZNoneZ ret_hu_conv = Result_CVec_UtxoZNoneZ.constr_from_ptr(ret);
81 * Returns a script to use for change above dust resulting from a successful coin selection
84 public Result_ScriptNoneZ get_change_script() {
85 long ret = bindings.WalletSource_get_change_script(this.ptr);
87 if (ret >= 0 && ret <= 4096) { return null; }
88 Result_ScriptNoneZ ret_hu_conv = Result_ScriptNoneZ.constr_from_ptr(ret);
93 * Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within
94 * the transaction known to the wallet (i.e., any provided via
95 * [`WalletSource::list_confirmed_utxos`]).
97 public Result_TransactionNoneZ sign_tx(byte[] tx) {
98 long ret = bindings.WalletSource_sign_tx(this.ptr, tx);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);