[Java] Update auto-generated bindings to LDK 0.0.123
[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 ChannelId get_channel_id() {
27                 long ret = bindings.TxAddInput_get_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 if (ret >= 0 && ret <= 4096) { return null; }
30                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
31                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
32                 return ret_hu_conv;
33         }
34
35         /**
36          * The channel ID
37          */
38         public void set_channel_id(org.ldk.structs.ChannelId val) {
39                 bindings.TxAddInput_set_channel_id(this.ptr, val.ptr);
40                 Reference.reachabilityFence(this);
41                 Reference.reachabilityFence(val);
42                 if (this != null) { this.ptrs_to.add(val); };
43         }
44
45         /**
46          * A randomly chosen unique identifier for this input, which is even for initiators and odd for
47          * non-initiators.
48          */
49         public long get_serial_id() {
50                 long ret = bindings.TxAddInput_get_serial_id(this.ptr);
51                 Reference.reachabilityFence(this);
52                 return ret;
53         }
54
55         /**
56          * A randomly chosen unique identifier for this input, which is even for initiators and odd for
57          * non-initiators.
58          */
59         public void set_serial_id(long val) {
60                 bindings.TxAddInput_set_serial_id(this.ptr, val);
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * Serialized transaction that contains the output this input spends to verify that it is non
67          * malleable.
68          */
69         public TransactionU16LenLimited get_prevtx() {
70                 long ret = bindings.TxAddInput_get_prevtx(this.ptr);
71                 Reference.reachabilityFence(this);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 org.ldk.structs.TransactionU16LenLimited ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TransactionU16LenLimited(null, ret); }
74                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Serialized transaction that contains the output this input spends to verify that it is non
80          * malleable.
81          */
82         public void set_prevtx(org.ldk.structs.TransactionU16LenLimited val) {
83                 bindings.TxAddInput_set_prevtx(this.ptr, val.ptr);
84                 Reference.reachabilityFence(this);
85                 Reference.reachabilityFence(val);
86                 if (this != null) { this.ptrs_to.add(val); };
87         }
88
89         /**
90          * The index of the output being spent
91          */
92         public int get_prevtx_out() {
93                 int ret = bindings.TxAddInput_get_prevtx_out(this.ptr);
94                 Reference.reachabilityFence(this);
95                 return ret;
96         }
97
98         /**
99          * The index of the output being spent
100          */
101         public void set_prevtx_out(int val) {
102                 bindings.TxAddInput_set_prevtx_out(this.ptr, val);
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(val);
105         }
106
107         /**
108          * The sequence number of this input
109          */
110         public int get_sequence() {
111                 int ret = bindings.TxAddInput_get_sequence(this.ptr);
112                 Reference.reachabilityFence(this);
113                 return ret;
114         }
115
116         /**
117          * The sequence number of this input
118          */
119         public void set_sequence(int val) {
120                 bindings.TxAddInput_set_sequence(this.ptr, val);
121                 Reference.reachabilityFence(this);
122                 Reference.reachabilityFence(val);
123         }
124
125         /**
126          * Constructs a new TxAddInput given each field
127          */
128         public static TxAddInput of(org.ldk.structs.ChannelId channel_id_arg, long serial_id_arg, org.ldk.structs.TransactionU16LenLimited prevtx_arg, int prevtx_out_arg, int sequence_arg) {
129                 long ret = bindings.TxAddInput_new(channel_id_arg.ptr, serial_id_arg, prevtx_arg.ptr, prevtx_out_arg, sequence_arg);
130                 Reference.reachabilityFence(channel_id_arg);
131                 Reference.reachabilityFence(serial_id_arg);
132                 Reference.reachabilityFence(prevtx_arg);
133                 Reference.reachabilityFence(prevtx_out_arg);
134                 Reference.reachabilityFence(sequence_arg);
135                 if (ret >= 0 && ret <= 4096) { return null; }
136                 org.ldk.structs.TxAddInput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddInput(null, ret); }
137                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
138                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
139                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(prevtx_arg); };
140                 return ret_hu_conv;
141         }
142
143         long clone_ptr() {
144                 long ret = bindings.TxAddInput_clone_ptr(this.ptr);
145                 Reference.reachabilityFence(this);
146                 return ret;
147         }
148
149         /**
150          * Creates a copy of the TxAddInput
151          */
152         public TxAddInput clone() {
153                 long ret = bindings.TxAddInput_clone(this.ptr);
154                 Reference.reachabilityFence(this);
155                 if (ret >= 0 && ret <= 4096) { return null; }
156                 org.ldk.structs.TxAddInput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddInput(null, ret); }
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
158                 return ret_hu_conv;
159         }
160
161         /**
162          * Generates a non-cryptographic 64-bit hash of the TxAddInput.
163          */
164         public long hash() {
165                 long ret = bindings.TxAddInput_hash(this.ptr);
166                 Reference.reachabilityFence(this);
167                 return ret;
168         }
169
170         @Override public int hashCode() {
171                 return (int)this.hash();
172         }
173         /**
174          * Checks if two TxAddInputs contain equal inner contents.
175          * This ignores pointers and is_owned flags and looks at the values in fields.
176          * Two objects with NULL inner values will be considered "equal" here.
177          */
178         public boolean eq(org.ldk.structs.TxAddInput b) {
179                 boolean ret = bindings.TxAddInput_eq(this.ptr, b.ptr);
180                 Reference.reachabilityFence(this);
181                 Reference.reachabilityFence(b);
182                 if (this != null) { this.ptrs_to.add(b); };
183                 return ret;
184         }
185
186         @Override public boolean equals(Object o) {
187                 if (!(o instanceof TxAddInput)) return false;
188                 return this.eq((TxAddInput)o);
189         }
190         /**
191          * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read
192          */
193         public byte[] write() {
194                 byte[] ret = bindings.TxAddInput_write(this.ptr);
195                 Reference.reachabilityFence(this);
196                 return ret;
197         }
198
199         /**
200          * Read a TxAddInput from a byte array, created by TxAddInput_write
201          */
202         public static Result_TxAddInputDecodeErrorZ read(byte[] ser) {
203                 long ret = bindings.TxAddInput_read(ser);
204                 Reference.reachabilityFence(ser);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 Result_TxAddInputDecodeErrorZ ret_hu_conv = Result_TxAddInputDecodeErrorZ.constr_from_ptr(ret);
207                 return ret_hu_conv;
208         }
209
210 }