[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / OnionPacket.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 OnionPacket : CommonBase {
13         internal OnionPacket(object _dummy, long ptr) : base(ptr) { }
14         ~OnionPacket() {
15                 if (ptr != 0) { bindings.OnionPacket_free(ptr); }
16         }
17
18         /**
19          * BOLT 4 version number.
20          */
21         public byte get_version() {
22                 byte ret = bindings.OnionPacket_get_version(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * BOLT 4 version number.
29          */
30         public void set_version(byte val) {
31                 bindings.OnionPacket_set_version(this.ptr, val);
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * In order to ensure we always return an error on onion decode in compliance with [BOLT
38          * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
39          * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
40          * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
41          * like.
42          * 
43          * Returns a copy of the field.
44          */
45         public Result_PublicKeySecp256k1ErrorZ get_public_key() {
46                 long ret = bindings.OnionPacket_get_public_key(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 Result_PublicKeySecp256k1ErrorZ ret_hu_conv = Result_PublicKeySecp256k1ErrorZ.constr_from_ptr(ret);
50                 return ret_hu_conv;
51         }
52
53         /**
54          * In order to ensure we always return an error on onion decode in compliance with [BOLT
55          * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to
56          * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral
57          * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd
58          * like.
59          */
60         public void set_public_key(org.ldk.structs.Result_PublicKeySecp256k1ErrorZ val) {
61                 bindings.OnionPacket_set_public_key(this.ptr, val != null ? val.ptr : 0);
62                 GC.KeepAlive(this);
63                 GC.KeepAlive(val);
64         }
65
66         /**
67          * HMAC to verify the integrity of hop_data.
68          */
69         public byte[] get_hmac() {
70                 long ret = bindings.OnionPacket_get_hmac(this.ptr);
71                 GC.KeepAlive(this);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
74                 return ret_conv;
75         }
76
77         /**
78          * HMAC to verify the integrity of hop_data.
79          */
80         public void set_hmac(byte[] val) {
81                 bindings.OnionPacket_set_hmac(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
82                 GC.KeepAlive(this);
83                 GC.KeepAlive(val);
84         }
85
86         internal long clone_ptr() {
87                 long ret = bindings.OnionPacket_clone_ptr(this.ptr);
88                 GC.KeepAlive(this);
89                 return ret;
90         }
91
92         /**
93          * Creates a copy of the OnionPacket
94          */
95         public OnionPacket clone() {
96                 long ret = bindings.OnionPacket_clone(this.ptr);
97                 GC.KeepAlive(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 org.ldk.structs.OnionPacket ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionPacket(null, ret); }
100                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
101                 return ret_hu_conv;
102         }
103
104         /**
105          * Generates a non-cryptographic 64-bit hash of the OnionPacket.
106          */
107         public long hash() {
108                 long ret = bindings.OnionPacket_hash(this.ptr);
109                 GC.KeepAlive(this);
110                 return ret;
111         }
112
113         public override int GetHashCode() {
114                 return (int)this.hash();
115         }
116         /**
117          * Checks if two OnionPackets contain equal inner contents.
118          * This ignores pointers and is_owned flags and looks at the values in fields.
119          * Two objects with NULL inner values will be considered "equal" here.
120          */
121         public bool eq(org.ldk.structs.OnionPacket b) {
122                 bool ret = bindings.OnionPacket_eq(this.ptr, b == null ? 0 : b.ptr);
123                 GC.KeepAlive(this);
124                 GC.KeepAlive(b);
125                 if (this != null) { this.ptrs_to.AddLast(b); };
126                 return ret;
127         }
128
129         public override bool Equals(object o) {
130                 if (!(o is OnionPacket)) return false;
131                 return this.eq((OnionPacket)o);
132         }
133         /**
134          * Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read
135          */
136         public byte[] write() {
137                 long ret = bindings.OnionPacket_write(this.ptr);
138                 GC.KeepAlive(this);
139                 if (ret >= 0 && ret <= 4096) { return null; }
140                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
141                 return ret_conv;
142         }
143
144         /**
145          * Read a OnionPacket from a byte array, created by OnionPacket_write
146          */
147         public static Result_OnionPacketDecodeErrorZ read(byte[] ser) {
148                 long ret = bindings.OnionPacket_read(InternalUtils.encodeUint8Array(ser));
149                 GC.KeepAlive(ser);
150                 if (ret >= 0 && ret <= 4096) { return null; }
151                 Result_OnionPacketDecodeErrorZ ret_hu_conv = Result_OnionPacketDecodeErrorZ.constr_from_ptr(ret);
152                 return ret_hu_conv;
153         }
154
155 }
156 } } }