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 tx_add_input message for adding an input during interactive transaction construction
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class TxAddInput extends CommonBase {
16 TxAddInput(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.TxAddInput_free(ptr); }
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.TxAddInput_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
35 public void set_channel_id(byte[] val) {
36 bindings.TxAddInput_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * A randomly chosen unique identifier for this input, which is even for initiators and odd for
45 public long get_serial_id() {
46 long ret = bindings.TxAddInput_get_serial_id(this.ptr);
47 Reference.reachabilityFence(this);
52 * A randomly chosen unique identifier for this input, which is even for initiators and odd for
55 public void set_serial_id(long val) {
56 bindings.TxAddInput_set_serial_id(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * Serialized transaction that contains the output this input spends to verify that it is non
65 public TransactionU16LenLimited get_prevtx() {
66 long ret = bindings.TxAddInput_get_prevtx(this.ptr);
67 Reference.reachabilityFence(this);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 org.ldk.structs.TransactionU16LenLimited ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TransactionU16LenLimited(null, ret); }
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
75 * Serialized transaction that contains the output this input spends to verify that it is non
78 public void set_prevtx(org.ldk.structs.TransactionU16LenLimited val) {
79 bindings.TxAddInput_set_prevtx(this.ptr, val == null ? 0 : val.ptr);
80 Reference.reachabilityFence(this);
81 Reference.reachabilityFence(val);
82 if (this != null) { this.ptrs_to.add(val); };
86 * The index of the output being spent
88 public int get_prevtx_out() {
89 int ret = bindings.TxAddInput_get_prevtx_out(this.ptr);
90 Reference.reachabilityFence(this);
95 * The index of the output being spent
97 public void set_prevtx_out(int val) {
98 bindings.TxAddInput_set_prevtx_out(this.ptr, val);
99 Reference.reachabilityFence(this);
100 Reference.reachabilityFence(val);
104 * The sequence number of this input
106 public int get_sequence() {
107 int ret = bindings.TxAddInput_get_sequence(this.ptr);
108 Reference.reachabilityFence(this);
113 * The sequence number of this input
115 public void set_sequence(int val) {
116 bindings.TxAddInput_set_sequence(this.ptr, val);
117 Reference.reachabilityFence(this);
118 Reference.reachabilityFence(val);
122 * Constructs a new TxAddInput given each field
124 public static TxAddInput of(byte[] channel_id_arg, long serial_id_arg, org.ldk.structs.TransactionU16LenLimited prevtx_arg, int prevtx_out_arg, int sequence_arg) {
125 long ret = bindings.TxAddInput_new(InternalUtils.check_arr_len(channel_id_arg, 32), serial_id_arg, prevtx_arg == null ? 0 : prevtx_arg.ptr, prevtx_out_arg, sequence_arg);
126 Reference.reachabilityFence(channel_id_arg);
127 Reference.reachabilityFence(serial_id_arg);
128 Reference.reachabilityFence(prevtx_arg);
129 Reference.reachabilityFence(prevtx_out_arg);
130 Reference.reachabilityFence(sequence_arg);
131 if (ret >= 0 && ret <= 4096) { return null; }
132 org.ldk.structs.TxAddInput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddInput(null, ret); }
133 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
134 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(prevtx_arg); };
139 long ret = bindings.TxAddInput_clone_ptr(this.ptr);
140 Reference.reachabilityFence(this);
145 * Creates a copy of the TxAddInput
147 public TxAddInput clone() {
148 long ret = bindings.TxAddInput_clone(this.ptr);
149 Reference.reachabilityFence(this);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 org.ldk.structs.TxAddInput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddInput(null, ret); }
152 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
157 * Checks if two TxAddInputs contain equal inner contents.
158 * This ignores pointers and is_owned flags and looks at the values in fields.
159 * Two objects with NULL inner values will be considered "equal" here.
161 public boolean eq(org.ldk.structs.TxAddInput b) {
162 boolean ret = bindings.TxAddInput_eq(this.ptr, b == null ? 0 : b.ptr);
163 Reference.reachabilityFence(this);
164 Reference.reachabilityFence(b);
165 if (this != null) { this.ptrs_to.add(b); };
169 @Override public boolean equals(Object o) {
170 if (!(o instanceof TxAddInput)) return false;
171 return this.eq((TxAddInput)o);
174 * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
176 public byte[] write() {
177 byte[] ret = bindings.TxAddInput_write(this.ptr);
178 Reference.reachabilityFence(this);
183 * Read a TxAddInput from a byte array, created by TxAddInput_write
185 public static Result_TxAddInputDecodeErrorZ read(byte[] ser) {
186 long ret = bindings.TxAddInput_read(ser);
187 Reference.reachabilityFence(ser);
188 if (ret >= 0 && ret <= 4096) { return null; }
189 Result_TxAddInputDecodeErrorZ ret_hu_conv = Result_TxAddInputDecodeErrorZ.constr_from_ptr(ret);