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 ChannelId get_channel_id() {
27 long ret = bindings.TxAddOutput_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); };
38 public void set_channel_id(org.ldk.structs.ChannelId val) {
39 bindings.TxAddOutput_set_channel_id(this.ptr, val.ptr);
40 Reference.reachabilityFence(this);
41 Reference.reachabilityFence(val);
42 if (this != null) { this.ptrs_to.add(val); };
46 * A randomly chosen unique identifier for this output, which is even for initiators and odd for
49 public long get_serial_id() {
50 long ret = bindings.TxAddOutput_get_serial_id(this.ptr);
51 Reference.reachabilityFence(this);
56 * A randomly chosen unique identifier for this output, which is even for initiators and odd for
59 public void set_serial_id(long val) {
60 bindings.TxAddOutput_set_serial_id(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * The satoshi value of the output
68 public long get_sats() {
69 long ret = bindings.TxAddOutput_get_sats(this.ptr);
70 Reference.reachabilityFence(this);
75 * The satoshi value of the output
77 public void set_sats(long val) {
78 bindings.TxAddOutput_set_sats(this.ptr, val);
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * The scriptPubKey for the output
86 public byte[] get_script() {
87 byte[] ret = bindings.TxAddOutput_get_script(this.ptr);
88 Reference.reachabilityFence(this);
93 * The scriptPubKey for the output
95 public void set_script(byte[] val) {
96 bindings.TxAddOutput_set_script(this.ptr, val);
97 Reference.reachabilityFence(this);
98 Reference.reachabilityFence(val);
102 * Constructs a new TxAddOutput given each field
104 public static TxAddOutput of(org.ldk.structs.ChannelId channel_id_arg, long serial_id_arg, long sats_arg, byte[] script_arg) {
105 long ret = bindings.TxAddOutput_new(channel_id_arg.ptr, serial_id_arg, sats_arg, script_arg);
106 Reference.reachabilityFence(channel_id_arg);
107 Reference.reachabilityFence(serial_id_arg);
108 Reference.reachabilityFence(sats_arg);
109 Reference.reachabilityFence(script_arg);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 org.ldk.structs.TxAddOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddOutput(null, ret); }
112 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
113 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
118 long ret = bindings.TxAddOutput_clone_ptr(this.ptr);
119 Reference.reachabilityFence(this);
124 * Creates a copy of the TxAddOutput
126 public TxAddOutput clone() {
127 long ret = bindings.TxAddOutput_clone(this.ptr);
128 Reference.reachabilityFence(this);
129 if (ret >= 0 && ret <= 4096) { return null; }
130 org.ldk.structs.TxAddOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxAddOutput(null, ret); }
131 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
136 * Generates a non-cryptographic 64-bit hash of the TxAddOutput.
139 long ret = bindings.TxAddOutput_hash(this.ptr);
140 Reference.reachabilityFence(this);
144 @Override public int hashCode() {
145 return (int)this.hash();
148 * Checks if two TxAddOutputs contain equal inner contents.
149 * This ignores pointers and is_owned flags and looks at the values in fields.
150 * Two objects with NULL inner values will be considered "equal" here.
152 public boolean eq(org.ldk.structs.TxAddOutput b) {
153 boolean ret = bindings.TxAddOutput_eq(this.ptr, b.ptr);
154 Reference.reachabilityFence(this);
155 Reference.reachabilityFence(b);
156 if (this != null) { this.ptrs_to.add(b); };
160 @Override public boolean equals(Object o) {
161 if (!(o instanceof TxAddOutput)) return false;
162 return this.eq((TxAddOutput)o);
165 * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read
167 public byte[] write() {
168 byte[] ret = bindings.TxAddOutput_write(this.ptr);
169 Reference.reachabilityFence(this);
174 * Read a TxAddOutput from a byte array, created by TxAddOutput_write
176 public static Result_TxAddOutputDecodeErrorZ read(byte[] ser) {
177 long ret = bindings.TxAddOutput_read(ser);
178 Reference.reachabilityFence(ser);
179 if (ret >= 0 && ret <= 4096) { return null; }
180 Result_TxAddOutputDecodeErrorZ ret_hu_conv = Result_TxAddOutputDecodeErrorZ.constr_from_ptr(ret);