6 namespace org { namespace ldk { namespace structs {
10 * An unspent transaction output that is available to spend resulting from a successful
11 * [`CoinSelection`] attempt.
13 public class Utxo : CommonBase {
14 internal Utxo(object _dummy, long ptr) : base(ptr) { }
16 if (ptr != 0) { bindings.Utxo_free(ptr); }
20 * The unique identifier of the output.
22 public OutPoint get_outpoint() {
23 long ret = bindings.Utxo_get_outpoint(this.ptr);
25 if (ret >= 0 && ret <= 4096) { return null; }
26 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
27 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
32 * The unique identifier of the output.
34 public void set_outpoint(org.ldk.structs.OutPoint val) {
35 bindings.Utxo_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
38 if (this != null) { this.ptrs_to.AddLast(val); };
42 * The output to spend.
44 public TxOut get_output() {
45 long ret = bindings.Utxo_get_output(this.ptr);
47 if (ret >= 0 && ret <= 4096) { return null; }
48 TxOut ret_conv = new TxOut(null, ret);
53 * The output to spend.
55 public void set_output(org.ldk.structs.TxOut val) {
56 bindings.Utxo_set_output(this.ptr, val.ptr);
62 * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
63 * with their lengths included, required to satisfy the output's script. The weight consumed by
64 * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
66 public long get_satisfaction_weight() {
67 long ret = bindings.Utxo_get_satisfaction_weight(this.ptr);
73 * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each
74 * with their lengths included, required to satisfy the output's script. The weight consumed by
75 * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`].
77 public void set_satisfaction_weight(long val) {
78 bindings.Utxo_set_satisfaction_weight(this.ptr, val);
84 * Constructs a new Utxo given each field
86 public static Utxo of(org.ldk.structs.OutPoint outpoint_arg, org.ldk.structs.TxOut output_arg, long satisfaction_weight_arg) {
87 long ret = bindings.Utxo_new(outpoint_arg == null ? 0 : outpoint_arg.ptr, output_arg.ptr, satisfaction_weight_arg);
88 GC.KeepAlive(outpoint_arg);
89 GC.KeepAlive(output_arg);
90 GC.KeepAlive(satisfaction_weight_arg);
91 if (ret >= 0 && ret <= 4096) { return null; }
92 org.ldk.structs.Utxo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Utxo(null, ret); }
93 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
94 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint_arg); };
98 internal long clone_ptr() {
99 long ret = bindings.Utxo_clone_ptr(this.ptr);
105 * Creates a copy of the Utxo
107 public Utxo clone() {
108 long ret = bindings.Utxo_clone(this.ptr);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 org.ldk.structs.Utxo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Utxo(null, ret); }
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
117 * Generates a non-cryptographic 64-bit hash of the Utxo.
120 long ret = bindings.Utxo_hash(this.ptr);
125 public override int GetHashCode() {
126 return (int)this.hash();
129 * Checks if two Utxos contain equal inner contents.
130 * This ignores pointers and is_owned flags and looks at the values in fields.
131 * Two objects with NULL inner values will be considered "equal" here.
133 public bool eq(org.ldk.structs.Utxo b) {
134 bool ret = bindings.Utxo_eq(this.ptr, b == null ? 0 : b.ptr);
137 if (this != null) { this.ptrs_to.AddLast(b); };
141 public override bool Equals(object o) {
142 if (!(o is Utxo)) return false;
143 return this.eq((Utxo)o);
146 * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output.
148 public static Utxo new_p2pkh(org.ldk.structs.OutPoint outpoint, long value, byte[] pubkey_hash) {
149 long ret = bindings.Utxo_new_p2pkh(outpoint == null ? 0 : outpoint.ptr, value, InternalUtils.check_arr_len(pubkey_hash, 20));
150 GC.KeepAlive(outpoint);
152 GC.KeepAlive(pubkey_hash);
153 if (ret >= 0 && ret <= 4096) { return null; }
154 org.ldk.structs.Utxo ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Utxo(null, ret); }
155 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
156 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint); };