1c80c723c5d981a81b072572914e817e8c1d9553
[ldk-java] / src / main / java / org / ldk / structs / TxComplete.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_complete message signalling the conclusion of a peer's transaction contributions during
13  * interactive transaction construction.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class TxComplete extends CommonBase {
17         TxComplete(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.TxComplete_free(ptr); }
22         }
23
24         /**
25          * The channel ID
26          */
27         public byte[] get_channel_id() {
28                 byte[] ret = bindings.TxComplete_get_channel_id(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * The channel ID
35          */
36         public void set_channel_id(byte[] val) {
37                 bindings.TxComplete_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
38                 Reference.reachabilityFence(this);
39                 Reference.reachabilityFence(val);
40         }
41
42         /**
43          * Constructs a new TxComplete given each field
44          */
45         public static TxComplete of(byte[] channel_id_arg) {
46                 long ret = bindings.TxComplete_new(InternalUtils.check_arr_len(channel_id_arg, 32));
47                 Reference.reachabilityFence(channel_id_arg);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 org.ldk.structs.TxComplete ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxComplete(null, ret); }
50                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
51                 return ret_hu_conv;
52         }
53
54         long clone_ptr() {
55                 long ret = bindings.TxComplete_clone_ptr(this.ptr);
56                 Reference.reachabilityFence(this);
57                 return ret;
58         }
59
60         /**
61          * Creates a copy of the TxComplete
62          */
63         public TxComplete clone() {
64                 long ret = bindings.TxComplete_clone(this.ptr);
65                 Reference.reachabilityFence(this);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 org.ldk.structs.TxComplete ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxComplete(null, ret); }
68                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
69                 return ret_hu_conv;
70         }
71
72         /**
73          * Checks if two TxCompletes contain equal inner contents.
74          * This ignores pointers and is_owned flags and looks at the values in fields.
75          * Two objects with NULL inner values will be considered "equal" here.
76          */
77         public boolean eq(org.ldk.structs.TxComplete b) {
78                 boolean ret = bindings.TxComplete_eq(this.ptr, b == null ? 0 : b.ptr);
79                 Reference.reachabilityFence(this);
80                 Reference.reachabilityFence(b);
81                 if (this != null) { this.ptrs_to.add(b); };
82                 return ret;
83         }
84
85         @Override public boolean equals(Object o) {
86                 if (!(o instanceof TxComplete)) return false;
87                 return this.eq((TxComplete)o);
88         }
89         /**
90          * Serialize the TxComplete object into a byte array which can be read by TxComplete_read
91          */
92         public byte[] write() {
93                 byte[] ret = bindings.TxComplete_write(this.ptr);
94                 Reference.reachabilityFence(this);
95                 return ret;
96         }
97
98         /**
99          * Read a TxComplete from a byte array, created by TxComplete_write
100          */
101         public static Result_TxCompleteDecodeErrorZ read(byte[] ser) {
102                 long ret = bindings.TxComplete_read(ser);
103                 Reference.reachabilityFence(ser);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 Result_TxCompleteDecodeErrorZ ret_hu_conv = Result_TxCompleteDecodeErrorZ.constr_from_ptr(ret);
106                 return ret_hu_conv;
107         }
108
109 }