[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / TrampolineOnionPacket.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  * BOLT 4 onion packet including hop data for the next peer.
11  */
12 public class TrampolineOnionPacket : CommonBase {
13         internal TrampolineOnionPacket(object _dummy, long ptr) : base(ptr) { }
14         ~TrampolineOnionPacket() {
15                 if (ptr != 0) { bindings.TrampolineOnionPacket_free(ptr); }
16         }
17
18         /**
19          * Bolt 04 version number
20          */
21         public byte get_version() {
22                 byte ret = bindings.TrampolineOnionPacket_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.TrampolineOnionPacket_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.TrampolineOnionPacket_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.TrampolineOnionPacket_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.TrampolineOnionPacket_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.TrampolineOnionPacket_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.TrampolineOnionPacket_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.TrampolineOnionPacket_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 TrampolineOnionPacket given each field
100          */
101         public static TrampolineOnionPacket of(byte version_arg, byte[] public_key_arg, byte[] hop_data_arg, byte[] hmac_arg) {
102                 long ret = bindings.TrampolineOnionPacket_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.TrampolineOnionPacket ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrampolineOnionPacket(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.TrampolineOnionPacket_clone_ptr(this.ptr);
115                 GC.KeepAlive(this);
116                 return ret;
117         }
118
119         /**
120          * Creates a copy of the TrampolineOnionPacket
121          */
122         public TrampolineOnionPacket clone() {
123                 long ret = bindings.TrampolineOnionPacket_clone(this.ptr);
124                 GC.KeepAlive(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 org.ldk.structs.TrampolineOnionPacket ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrampolineOnionPacket(null, ret); }
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
128                 return ret_hu_conv;
129         }
130
131         /**
132          * Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket.
133          */
134         public long hash() {
135                 long ret = bindings.TrampolineOnionPacket_hash(this.ptr);
136                 GC.KeepAlive(this);
137                 return ret;
138         }
139
140         public override int GetHashCode() {
141                 return (int)this.hash();
142         }
143         /**
144          * Checks if two TrampolineOnionPackets contain equal inner contents.
145          * This ignores pointers and is_owned flags and looks at the values in fields.
146          * Two objects with NULL inner values will be considered "equal" here.
147          */
148         public bool eq(org.ldk.structs.TrampolineOnionPacket b) {
149                 bool ret = bindings.TrampolineOnionPacket_eq(this.ptr, b.ptr);
150                 GC.KeepAlive(this);
151                 GC.KeepAlive(b);
152                 if (this != null) { this.ptrs_to.AddLast(b); };
153                 return ret;
154         }
155
156         public override bool Equals(object o) {
157                 if (!(o is TrampolineOnionPacket)) return false;
158                 return this.eq((TrampolineOnionPacket)o);
159         }
160         /**
161          * Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read
162          */
163         public byte[] write() {
164                 long ret = bindings.TrampolineOnionPacket_write(this.ptr);
165                 GC.KeepAlive(this);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
168                 return ret_conv;
169         }
170
171 }
172 } } }