cb736a78573e513cf94a94d871fc6e5844f8c7db
[ldk-java] / src / main / java / org / ldk / structs / TxAddInput.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A tx_add_input message for adding an input during interactive transaction construction
13  */
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 {
19                 super.finalize();
20                 if (ptr != 0) { bindings.TxAddInput_free(ptr); }
21         }
22
23         /**
24          * The channel ID
25          */
26         public byte[] get_channel_id() {
27                 byte[] ret = bindings.TxAddInput_get_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The channel ID
34          */
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);
39         }
40
41         /**
42          * A randomly chosen unique identifier for this input, which is even for initiators and odd for
43          * non-initiators.
44          */
45         public long get_serial_id() {
46                 long ret = bindings.TxAddInput_get_serial_id(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         /**
52          * A randomly chosen unique identifier for this input, which is even for initiators and odd for
53          * non-initiators.
54          */
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);
59         }
60
61         /**
62          * Serialized transaction that contains the output this input spends to verify that it is non
63          * malleable.
64          */
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); };
71                 return ret_hu_conv;
72         }
73
74         /**
75          * Serialized transaction that contains the output this input spends to verify that it is non
76          * malleable.
77          */
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); };
83         }
84
85         /**
86          * The index of the output being spent
87          */
88         public int get_prevtx_out() {
89                 int ret = bindings.TxAddInput_get_prevtx_out(this.ptr);
90                 Reference.reachabilityFence(this);
91                 return ret;
92         }
93
94         /**
95          * The index of the output being spent
96          */
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);
101         }
102
103         /**
104          * The sequence number of this input
105          */
106         public int get_sequence() {
107                 int ret = bindings.TxAddInput_get_sequence(this.ptr);
108                 Reference.reachabilityFence(this);
109                 return ret;
110         }
111
112         /**
113          * The sequence number of this input
114          */
115         public void set_sequence(int val) {
116                 bindings.TxAddInput_set_sequence(this.ptr, val);
117                 Reference.reachabilityFence(this);
118                 Reference.reachabilityFence(val);
119         }
120
121         /**
122          * Constructs a new TxAddInput given each field
123          */
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); };
135                 return ret_hu_conv;
136         }
137
138         long clone_ptr() {
139                 long ret = bindings.TxAddInput_clone_ptr(this.ptr);
140                 Reference.reachabilityFence(this);
141                 return ret;
142         }
143
144         /**
145          * Creates a copy of the TxAddInput
146          */
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); };
153                 return ret_hu_conv;
154         }
155
156         /**
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.
160          */
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); };
166                 return ret;
167         }
168
169         @Override public boolean equals(Object o) {
170                 if (!(o instanceof TxAddInput)) return false;
171                 return this.eq((TxAddInput)o);
172         }
173         /**
174          * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
175          */
176         public byte[] write() {
177                 byte[] ret = bindings.TxAddInput_write(this.ptr);
178                 Reference.reachabilityFence(this);
179                 return ret;
180         }
181
182         /**
183          * Read a TxAddInput from a byte array, created by TxAddInput_write
184          */
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);
190                 return ret_hu_conv;
191         }
192
193 }