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_output message for adding an output during interactive transaction construction.
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 {
20 if (ptr != 0) { bindings.TxAddOutput_free(ptr); }
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.TxAddOutput_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
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);
42 * A randomly chosen unique identifier for this output, which is even for initiators and odd for
45 public long get_serial_id() {
46 long ret = bindings.TxAddOutput_get_serial_id(this.ptr);
47 Reference.reachabilityFence(this);
52 * A randomly chosen unique identifier for this output, which is even for initiators and odd for
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);
62 * The satoshi value of the output
64 public long get_sats() {
65 long ret = bindings.TxAddOutput_get_sats(this.ptr);
66 Reference.reachabilityFence(this);
71 * The satoshi value of the output
73 public void set_sats(long val) {
74 bindings.TxAddOutput_set_sats(this.ptr, val);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The scriptPubKey for the output
82 public byte[] get_script() {
83 byte[] ret = bindings.TxAddOutput_get_script(this.ptr);
84 Reference.reachabilityFence(this);
89 * The scriptPubKey for the output
91 public void set_script(byte[] val) {
92 bindings.TxAddOutput_set_script(this.ptr, val);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(val);
98 * Constructs a new TxAddOutput given each field
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); };
113 long ret = bindings.TxAddOutput_clone_ptr(this.ptr);
114 Reference.reachabilityFence(this);
119 * Creates a copy of the TxAddOutput
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); };
131 * Checks if two TxAddOutputs contain equal inner contents.
132 * This ignores pointers and is_owned flags and looks at the values in fields.
133 * Two objects with NULL inner values will be considered "equal" here.
135 public boolean eq(org.ldk.structs.TxAddOutput b) {
136 boolean ret = bindings.TxAddOutput_eq(this.ptr, b == null ? 0 : b.ptr);
137 Reference.reachabilityFence(this);
138 Reference.reachabilityFence(b);
139 if (this != null) { this.ptrs_to.add(b); };
143 @Override public boolean equals(Object o) {
144 if (!(o instanceof TxAddOutput)) return false;
145 return this.eq((TxAddOutput)o);
148 * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
150 public byte[] write() {
151 byte[] ret = bindings.TxAddOutput_write(this.ptr);
152 Reference.reachabilityFence(this);
157 * Read a TxAddOutput from a byte array, created by TxAddOutput_write
159 public static Result_TxAddOutputDecodeErrorZ read(byte[] ser) {
160 long ret = bindings.TxAddOutput_read(ser);
161 Reference.reachabilityFence(ser);
162 if (ret >= 0 && ret <= 4096) { return null; }
163 Result_TxAddOutputDecodeErrorZ ret_hu_conv = Result_TxAddOutputDecodeErrorZ.constr_from_ptr(ret);