[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / TxAddOutput.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_output message for adding an output during interactive transaction construction.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class TxAddOutput extends CommonBase {
16         TxAddOutput(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.TxAddOutput_free(ptr); }
21         }
22
23         /**
24          * The channel ID
25          */
26         public byte[] get_channel_id() {
27                 byte[] ret = bindings.TxAddOutput_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.TxAddOutput_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 output, which is even for initiators and odd for
43          * non-initiators.
44          */
45         public long get_serial_id() {
46                 long ret = bindings.TxAddOutput_get_serial_id(this.ptr);
47                 Reference.reachabilityFence(this);
48                 return ret;
49         }
50
51         /**
52          * A randomly chosen unique identifier for this output, which is even for initiators and odd for
53          * non-initiators.
54          */
55         public void set_serial_id(long val) {
56                 bindings.TxAddOutput_set_serial_id(this.ptr, val);
57                 Reference.reachabilityFence(this);
58                 Reference.reachabilityFence(val);
59         }
60
61         /**
62          * The satoshi value of the output
63          */
64         public long get_sats() {
65                 long ret = bindings.TxAddOutput_get_sats(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * The satoshi value of the output
72          */
73         public void set_sats(long val) {
74                 bindings.TxAddOutput_set_sats(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * The scriptPubKey for the output
81          */
82         public byte[] get_script() {
83                 byte[] ret = bindings.TxAddOutput_get_script(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * The scriptPubKey for the output
90          */
91         public void set_script(byte[] val) {
92                 bindings.TxAddOutput_set_script(this.ptr, val);
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * Constructs a new TxAddOutput given each field
99          */
100         public static TxAddOutput of(byte[] channel_id_arg, long serial_id_arg, long sats_arg, byte[] script_arg) {
101                 long ret = bindings.TxAddOutput_new(InternalUtils.check_arr_len(channel_id_arg, 32), serial_id_arg, sats_arg, script_arg);
102                 Reference.reachabilityFence(channel_id_arg);
103                 Reference.reachabilityFence(serial_id_arg);
104                 Reference.reachabilityFence(sats_arg);
105                 Reference.reachabilityFence(script_arg);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 org.ldk.structs.TxAddOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddOutput(null, ret); }
108                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
109                 return ret_hu_conv;
110         }
111
112         long clone_ptr() {
113                 long ret = bindings.TxAddOutput_clone_ptr(this.ptr);
114                 Reference.reachabilityFence(this);
115                 return ret;
116         }
117
118         /**
119          * Creates a copy of the TxAddOutput
120          */
121         public TxAddOutput clone() {
122                 long ret = bindings.TxAddOutput_clone(this.ptr);
123                 Reference.reachabilityFence(this);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 org.ldk.structs.TxAddOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddOutput(null, ret); }
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * Generates a non-cryptographic 64-bit hash of the TxAddOutput.
132          */
133         public long hash() {
134                 long ret = bindings.TxAddOutput_hash(this.ptr);
135                 Reference.reachabilityFence(this);
136                 return ret;
137         }
138
139         @Override public int hashCode() {
140                 return (int)this.hash();
141         }
142         /**
143          * Checks if two TxAddOutputs contain equal inner contents.
144          * This ignores pointers and is_owned flags and looks at the values in fields.
145          * Two objects with NULL inner values will be considered "equal" here.
146          */
147         public boolean eq(org.ldk.structs.TxAddOutput b) {
148                 boolean ret = bindings.TxAddOutput_eq(this.ptr, b == null ? 0 : b.ptr);
149                 Reference.reachabilityFence(this);
150                 Reference.reachabilityFence(b);
151                 if (this != null) { this.ptrs_to.add(b); };
152                 return ret;
153         }
154
155         @Override public boolean equals(Object o) {
156                 if (!(o instanceof TxAddOutput)) return false;
157                 return this.eq((TxAddOutput)o);
158         }
159         /**
160          * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
161          */
162         public byte[] write() {
163                 byte[] ret = bindings.TxAddOutput_write(this.ptr);
164                 Reference.reachabilityFence(this);
165                 return ret;
166         }
167
168         /**
169          * Read a TxAddOutput from a byte array, created by TxAddOutput_write
170          */
171         public static Result_TxAddOutputDecodeErrorZ read(byte[] ser) {
172                 long ret = bindings.TxAddOutput_read(ser);
173                 Reference.reachabilityFence(ser);
174                 if (ret >= 0 && ret <= 4096) { return null; }
175                 Result_TxAddOutputDecodeErrorZ ret_hu_conv = Result_TxAddOutputDecodeErrorZ.constr_from_ptr(ret);
176                 return ret_hu_conv;
177         }
178
179 }