51c0892be4b01adc3454940afbd475efdb4b6de8
[ldk-java] / src / main / java / org / ldk / structs / TxRemoveOutput.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_remove_output message for removing an output during interactive transaction construction.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class TxRemoveOutput extends CommonBase {
16         TxRemoveOutput(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.TxRemoveOutput_free(ptr); }
21         }
22
23         /**
24          * The channel ID
25          */
26         public byte[] get_channel_id() {
27                 byte[] ret = bindings.TxRemoveOutput_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.TxRemoveOutput_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The serial ID of the output to be removed
43          */
44         public long get_serial_id() {
45                 long ret = bindings.TxRemoveOutput_get_serial_id(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * The serial ID of the output to be removed
52          */
53         public void set_serial_id(long val) {
54                 bindings.TxRemoveOutput_set_serial_id(this.ptr, val);
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(val);
57         }
58
59         /**
60          * Constructs a new TxRemoveOutput given each field
61          */
62         public static TxRemoveOutput of(byte[] channel_id_arg, long serial_id_arg) {
63                 long ret = bindings.TxRemoveOutput_new(InternalUtils.check_arr_len(channel_id_arg, 32), serial_id_arg);
64                 Reference.reachabilityFence(channel_id_arg);
65                 Reference.reachabilityFence(serial_id_arg);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 org.ldk.structs.TxRemoveOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxRemoveOutput(null, ret); }
68                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
69                 return ret_hu_conv;
70         }
71
72         long clone_ptr() {
73                 long ret = bindings.TxRemoveOutput_clone_ptr(this.ptr);
74                 Reference.reachabilityFence(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of the TxRemoveOutput
80          */
81         public TxRemoveOutput clone() {
82                 long ret = bindings.TxRemoveOutput_clone(this.ptr);
83                 Reference.reachabilityFence(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.TxRemoveOutput ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxRemoveOutput(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Checks if two TxRemoveOutputs contain equal inner contents.
92          * This ignores pointers and is_owned flags and looks at the values in fields.
93          * Two objects with NULL inner values will be considered "equal" here.
94          */
95         public boolean eq(org.ldk.structs.TxRemoveOutput b) {
96                 boolean ret = bindings.TxRemoveOutput_eq(this.ptr, b == null ? 0 : b.ptr);
97                 Reference.reachabilityFence(this);
98                 Reference.reachabilityFence(b);
99                 if (this != null) { this.ptrs_to.add(b); };
100                 return ret;
101         }
102
103         @Override public boolean equals(Object o) {
104                 if (!(o instanceof TxRemoveOutput)) return false;
105                 return this.eq((TxRemoveOutput)o);
106         }
107         /**
108          * Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read
109          */
110         public byte[] write() {
111                 byte[] ret = bindings.TxRemoveOutput_write(this.ptr);
112                 Reference.reachabilityFence(this);
113                 return ret;
114         }
115
116         /**
117          * Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write
118          */
119         public static Result_TxRemoveOutputDecodeErrorZ read(byte[] ser) {
120                 long ret = bindings.TxRemoveOutput_read(ser);
121                 Reference.reachabilityFence(ser);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 Result_TxRemoveOutputDecodeErrorZ ret_hu_conv = Result_TxRemoveOutputDecodeErrorZ.constr_from_ptr(ret);
124                 return ret_hu_conv;
125         }
126
127 }