[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / Packet.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Packet of hop data for next peer
11  */
12 public class Packet : CommonBase {
13         internal Packet(object _dummy, long ptr) : base(ptr) { }
14         ~Packet() {
15                 if (ptr != 0) { bindings.Packet_free(ptr); }
16         }
17
18         /**
19          * Bolt 04 version number
20          */
21         public byte get_version() {
22                 byte ret = bindings.Packet_get_version(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * Bolt 04 version number
29          */
30         public void set_version(byte val) {
31                 bindings.Packet_set_version(this.ptr, val);
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
38          */
39         public byte[] get_public_key() {
40                 long ret = bindings.Packet_get_public_key(this.ptr);
41                 GC.KeepAlive(this);
42                 if (ret >= 0 && ret <= 4096) { return null; }
43                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
44                 return ret_conv;
45         }
46
47         /**
48          * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
49          */
50         public void set_public_key(byte[] val) {
51                 bindings.Packet_set_public_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
52                 GC.KeepAlive(this);
53                 GC.KeepAlive(val);
54         }
55
56         /**
57          * Encrypted payload for the next hop
58          * 
59          * Returns a copy of the field.
60          */
61         public byte[] get_hop_data() {
62                 long ret = bindings.Packet_get_hop_data(this.ptr);
63                 GC.KeepAlive(this);
64                 if (ret >= 0 && ret <= 4096) { return null; }
65                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
66                 return ret_conv;
67         }
68
69         /**
70          * Encrypted payload for the next hop
71          */
72         public void set_hop_data(byte[] val) {
73                 bindings.Packet_set_hop_data(this.ptr, InternalUtils.encodeUint8Array(val));
74                 GC.KeepAlive(this);
75                 GC.KeepAlive(val);
76         }
77
78         /**
79          * HMAC to verify the integrity of hop_data
80          */
81         public byte[] get_hmac() {
82                 long ret = bindings.Packet_get_hmac(this.ptr);
83                 GC.KeepAlive(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
86                 return ret_conv;
87         }
88
89         /**
90          * HMAC to verify the integrity of hop_data
91          */
92         public void set_hmac(byte[] val) {
93                 bindings.Packet_set_hmac(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
94                 GC.KeepAlive(this);
95                 GC.KeepAlive(val);
96         }
97
98         /**
99          * Constructs a new Packet given each field
100          */
101         public static Packet of(byte version_arg, byte[] public_key_arg, byte[] hop_data_arg, byte[] hmac_arg) {
102                 long ret = bindings.Packet_new(version_arg, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(public_key_arg, 33)), InternalUtils.encodeUint8Array(hop_data_arg), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(hmac_arg, 32)));
103                 GC.KeepAlive(version_arg);
104                 GC.KeepAlive(public_key_arg);
105                 GC.KeepAlive(hop_data_arg);
106                 GC.KeepAlive(hmac_arg);
107                 if (ret >= 0 && ret <= 4096) { return null; }
108                 org.ldk.structs.Packet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Packet(null, ret); }
109                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
110                 return ret_hu_conv;
111         }
112
113         internal long clone_ptr() {
114                 long ret = bindings.Packet_clone_ptr(this.ptr);
115                 GC.KeepAlive(this);
116                 return ret;
117         }
118
119         /**
120          * Creates a copy of the Packet
121          */
122         public Packet clone() {
123                 long ret = bindings.Packet_clone(this.ptr);
124                 GC.KeepAlive(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 org.ldk.structs.Packet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Packet(null, ret); }
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
128                 return ret_hu_conv;
129         }
130
131         /**
132          * Checks if two Packets contain equal inner contents.
133          * This ignores pointers and is_owned flags and looks at the values in fields.
134          * Two objects with NULL inner values will be considered "equal" here.
135          */
136         public bool eq(org.ldk.structs.Packet b) {
137                 bool ret = bindings.Packet_eq(this.ptr, b == null ? 0 : b.ptr);
138                 GC.KeepAlive(this);
139                 GC.KeepAlive(b);
140                 if (this != null) { this.ptrs_to.AddLast(b); };
141                 return ret;
142         }
143
144         public override bool Equals(object o) {
145                 if (!(o is Packet)) return false;
146                 return this.eq((Packet)o);
147         }
148         /**
149          * Serialize the Packet object into a byte array which can be read by Packet_read
150          */
151         public byte[] write() {
152                 long ret = bindings.Packet_write(this.ptr);
153                 GC.KeepAlive(this);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
156                 return ret_conv;
157         }
158
159 }
160 } } }