[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / Packet.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  * Packet of hop data for next peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Packet extends CommonBase {
16         Packet(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.Packet_free(ptr); }
21         }
22
23         /**
24          * Bolt 04 version number
25          */
26         public byte get_version() {
27                 byte ret = bindings.Packet_get_version(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * Bolt 04 version number
34          */
35         public void set_version(byte val) {
36                 bindings.Packet_set_version(this.ptr, val);
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
43          */
44         public byte[] get_public_key() {
45                 byte[] ret = bindings.Packet_get_public_key(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
52          */
53         public void set_public_key(byte[] val) {
54                 bindings.Packet_set_public_key(this.ptr, InternalUtils.check_arr_len(val, 33));
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(val);
57         }
58
59         /**
60          * Encrypted payload for the next hop
61          * 
62          * Returns a copy of the field.
63          */
64         public byte[] get_hop_data() {
65                 byte[] ret = bindings.Packet_get_hop_data(this.ptr);
66                 Reference.reachabilityFence(this);
67                 return ret;
68         }
69
70         /**
71          * Encrypted payload for the next hop
72          */
73         public void set_hop_data(byte[] val) {
74                 bindings.Packet_set_hop_data(this.ptr, val);
75                 Reference.reachabilityFence(this);
76                 Reference.reachabilityFence(val);
77         }
78
79         /**
80          * HMAC to verify the integrity of hop_data
81          */
82         public byte[] get_hmac() {
83                 byte[] ret = bindings.Packet_get_hmac(this.ptr);
84                 Reference.reachabilityFence(this);
85                 return ret;
86         }
87
88         /**
89          * HMAC to verify the integrity of hop_data
90          */
91         public void set_hmac(byte[] val) {
92                 bindings.Packet_set_hmac(this.ptr, InternalUtils.check_arr_len(val, 32));
93                 Reference.reachabilityFence(this);
94                 Reference.reachabilityFence(val);
95         }
96
97         /**
98          * Constructs a new Packet given each field
99          */
100         public static Packet of(byte version_arg, byte[] public_key_arg, byte[] hop_data_arg, byte[] hmac_arg) {
101                 long ret = bindings.Packet_new(version_arg, InternalUtils.check_arr_len(public_key_arg, 33), hop_data_arg, InternalUtils.check_arr_len(hmac_arg, 32));
102                 Reference.reachabilityFence(version_arg);
103                 Reference.reachabilityFence(public_key_arg);
104                 Reference.reachabilityFence(hop_data_arg);
105                 Reference.reachabilityFence(hmac_arg);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 org.ldk.structs.Packet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Packet(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.Packet_clone_ptr(this.ptr);
114                 Reference.reachabilityFence(this);
115                 return ret;
116         }
117
118         /**
119          * Creates a copy of the Packet
120          */
121         public Packet clone() {
122                 long ret = bindings.Packet_clone(this.ptr);
123                 Reference.reachabilityFence(this);
124                 if (ret >= 0 && ret <= 4096) { return null; }
125                 org.ldk.structs.Packet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Packet(null, ret); }
126                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * Checks if two Packets 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.
134          */
135         public boolean eq(org.ldk.structs.Packet b) {
136                 boolean ret = bindings.Packet_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); };
140                 return ret;
141         }
142
143         @Override public boolean equals(Object o) {
144                 if (!(o instanceof Packet)) return false;
145                 return this.eq((Packet)o);
146         }
147         /**
148          * Serialize the Packet object into a byte array which can be read by Packet_read
149          */
150         public byte[] write() {
151                 byte[] ret = bindings.Packet_write(this.ptr);
152                 Reference.reachabilityFence(this);
153                 return ret;
154         }
155
156 }