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 * The result of a successful coin selection attempt for a transaction requiring additional UTXOs
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class CoinSelection extends CommonBase {
17 CoinSelection(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.CoinSelection_free(ptr); }
25 * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
26 * requiring additional fees.
28 public Utxo[] get_confirmed_utxos() {
29 long[] ret = bindings.CoinSelection_get_confirmed_utxos(this.ptr);
30 Reference.reachabilityFence(this);
31 int ret_conv_6_len = ret.length;
32 Utxo[] ret_conv_6_arr = new Utxo[ret_conv_6_len];
33 for (int g = 0; g < ret_conv_6_len; g++) {
34 long ret_conv_6 = ret[g];
35 org.ldk.structs.Utxo ret_conv_6_hu_conv = null; if (ret_conv_6 < 0 || ret_conv_6 > 4096) { ret_conv_6_hu_conv = new org.ldk.structs.Utxo(null, ret_conv_6); }
36 if (ret_conv_6_hu_conv != null) { ret_conv_6_hu_conv.ptrs_to.add(this); };
37 ret_conv_6_arr[g] = ret_conv_6_hu_conv;
39 return ret_conv_6_arr;
43 * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction
44 * requiring additional fees.
46 public void set_confirmed_utxos(Utxo[] val) {
47 bindings.CoinSelection_set_confirmed_utxos(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_6 -> val_conv_6.ptr).toArray() : null);
48 Reference.reachabilityFence(this);
49 Reference.reachabilityFence(val);
53 * An additional output tracking whether any change remained after coin selection. This output
54 * should always have a value above dust for its given `script_pubkey`. It should not be
55 * spent until the transaction it belongs to confirms to ensure mempool descendant limits are
56 * not met. This implies no other party should be able to spend it except us.
58 public Option_TxOutZ get_change_output() {
59 long ret = bindings.CoinSelection_get_change_output(this.ptr);
60 Reference.reachabilityFence(this);
61 if (ret >= 0 && ret <= 4096) { return null; }
62 org.ldk.structs.Option_TxOutZ ret_hu_conv = org.ldk.structs.Option_TxOutZ.constr_from_ptr(ret);
63 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
68 * An additional output tracking whether any change remained after coin selection. This output
69 * should always have a value above dust for its given `script_pubkey`. It should not be
70 * spent until the transaction it belongs to confirms to ensure mempool descendant limits are
71 * not met. This implies no other party should be able to spend it except us.
73 public void set_change_output(org.ldk.structs.Option_TxOutZ val) {
74 bindings.CoinSelection_set_change_output(this.ptr, val.ptr);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * Constructs a new CoinSelection given each field
82 public static CoinSelection of(Utxo[] confirmed_utxos_arg, org.ldk.structs.Option_TxOutZ change_output_arg) {
83 long ret = bindings.CoinSelection_new(confirmed_utxos_arg != null ? Arrays.stream(confirmed_utxos_arg).mapToLong(confirmed_utxos_arg_conv_6 -> confirmed_utxos_arg_conv_6.ptr).toArray() : null, change_output_arg.ptr);
84 Reference.reachabilityFence(confirmed_utxos_arg);
85 Reference.reachabilityFence(change_output_arg);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 org.ldk.structs.CoinSelection ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CoinSelection(null, ret); }
88 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
93 long ret = bindings.CoinSelection_clone_ptr(this.ptr);
94 Reference.reachabilityFence(this);
99 * Creates a copy of the CoinSelection
101 public CoinSelection clone() {
102 long ret = bindings.CoinSelection_clone(this.ptr);
103 Reference.reachabilityFence(this);
104 if (ret >= 0 && ret <= 4096) { return null; }
105 org.ldk.structs.CoinSelection ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CoinSelection(null, ret); }
106 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };