1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would
13 * avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Wallet extends CommonBase {
18 Wallet(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.Wallet_free(ptr); }
26 * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation
27 * of [`CoinSelectionSource`].
29 public static Wallet of(org.ldk.structs.WalletSource source, org.ldk.structs.Logger logger) {
30 long ret = bindings.Wallet_new(source.ptr, logger.ptr);
31 Reference.reachabilityFence(source);
32 Reference.reachabilityFence(logger);
33 if (ret >= 0 && ret <= 4096) { return null; }
34 org.ldk.structs.Wallet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Wallet(null, ret); }
35 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
36 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(source); };
37 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(logger); };
42 * Constructs a new CoinSelectionSource which calls the relevant methods on this_arg.
43 * This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is
45 public CoinSelectionSource as_CoinSelectionSource() {
46 long ret = bindings.Wallet_as_CoinSelectionSource(this.ptr);
47 Reference.reachabilityFence(this);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 CoinSelectionSource ret_hu_conv = new CoinSelectionSource(null, ret);
50 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };