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 * An input that must be included in a transaction when performing coin selection through
13 * [`CoinSelectionSource::select_confirmed_utxos`]. It is guaranteed to be a SegWit input, so it
14 * must have an empty [`TxIn::script_sig`] when spent.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Input extends CommonBase {
18 Input(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.Input_free(ptr); }
26 * The unique identifier of the input.
28 public OutPoint get_outpoint() {
29 long ret = bindings.Input_get_outpoint(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
38 * The unique identifier of the input.
40 public void set_outpoint(org.ldk.structs.OutPoint val) {
41 bindings.Input_set_outpoint(this.ptr, val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * The UTXO being spent by the input.
50 public TxOut get_previous_utxo() {
51 long ret = bindings.Input_get_previous_utxo(this.ptr);
52 Reference.reachabilityFence(this);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 TxOut ret_conv = new TxOut(null, ret);
59 * The UTXO being spent by the input.
61 public void set_previous_utxo(org.ldk.structs.TxOut val) {
62 bindings.Input_set_previous_utxo(this.ptr, val.ptr);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(val);
68 * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
69 * [`TxIn::witness`], each with their lengths included, required to satisfy the output's
72 public long get_satisfaction_weight() {
73 long ret = bindings.Input_get_satisfaction_weight(this.ptr);
74 Reference.reachabilityFence(this);
79 * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and
80 * [`TxIn::witness`], each with their lengths included, required to satisfy the output's
83 public void set_satisfaction_weight(long val) {
84 bindings.Input_set_satisfaction_weight(this.ptr, val);
85 Reference.reachabilityFence(this);
86 Reference.reachabilityFence(val);
90 * Constructs a new Input given each field
92 public static Input of(org.ldk.structs.OutPoint outpoint_arg, org.ldk.structs.TxOut previous_utxo_arg, long satisfaction_weight_arg) {
93 long ret = bindings.Input_new(outpoint_arg.ptr, previous_utxo_arg.ptr, satisfaction_weight_arg);
94 Reference.reachabilityFence(outpoint_arg);
95 Reference.reachabilityFence(previous_utxo_arg);
96 Reference.reachabilityFence(satisfaction_weight_arg);
97 if (ret >= 0 && ret <= 4096) { return null; }
98 org.ldk.structs.Input ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Input(null, ret); }
99 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
100 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
105 long ret = bindings.Input_clone_ptr(this.ptr);
106 Reference.reachabilityFence(this);
111 * Creates a copy of the Input
113 public Input clone() {
114 long ret = bindings.Input_clone(this.ptr);
115 Reference.reachabilityFence(this);
116 if (ret >= 0 && ret <= 4096) { return null; }
117 org.ldk.structs.Input ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Input(null, ret); }
118 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
123 * Generates a non-cryptographic 64-bit hash of the Input.
126 long ret = bindings.Input_hash(this.ptr);
127 Reference.reachabilityFence(this);
131 @Override public int hashCode() {
132 return (int)this.hash();
135 * Checks if two Inputs contain equal inner contents.
136 * This ignores pointers and is_owned flags and looks at the values in fields.
137 * Two objects with NULL inner values will be considered "equal" here.
139 public boolean eq(org.ldk.structs.Input b) {
140 boolean ret = bindings.Input_eq(this.ptr, b.ptr);
141 Reference.reachabilityFence(this);
142 Reference.reachabilityFence(b);
143 if (this != null) { this.ptrs_to.add(b); };
147 @Override public boolean equals(Object o) {
148 if (!(o instanceof Input)) return false;
149 return this.eq((Input)o);