[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / OnionMessage.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  * An onion message to be sent to or received from a peer.
11  */
12 public class OnionMessage : CommonBase {
13         internal OnionMessage(object _dummy, long ptr) : base(ptr) { }
14         ~OnionMessage() {
15                 if (ptr != 0) { bindings.OnionMessage_free(ptr); }
16         }
17
18         /**
19          * Used in decrypting the onion packet's payload.
20          */
21         public byte[] get_blinding_point() {
22                 long ret = bindings.OnionMessage_get_blinding_point(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
26                 return ret_conv;
27         }
28
29         /**
30          * Used in decrypting the onion packet's payload.
31          */
32         public void set_blinding_point(byte[] val) {
33                 bindings.OnionMessage_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * The full onion packet including hop data, pubkey, and hmac
40          */
41         public Packet get_onion_routing_packet() {
42                 long ret = bindings.OnionMessage_get_onion_routing_packet(this.ptr);
43                 GC.KeepAlive(this);
44                 if (ret >= 0 && ret <= 4096) { return null; }
45                 org.ldk.structs.Packet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Packet(null, ret); }
46                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
47                 return ret_hu_conv;
48         }
49
50         /**
51          * The full onion packet including hop data, pubkey, and hmac
52          */
53         public void set_onion_routing_packet(org.ldk.structs.Packet val) {
54                 bindings.OnionMessage_set_onion_routing_packet(this.ptr, val == null ? 0 : val.ptr);
55                 GC.KeepAlive(this);
56                 GC.KeepAlive(val);
57                 if (this != null) { this.ptrs_to.AddLast(val); };
58         }
59
60         /**
61          * Constructs a new OnionMessage given each field
62          */
63         public static OnionMessage of(byte[] blinding_point_arg, org.ldk.structs.Packet onion_routing_packet_arg) {
64                 long ret = bindings.OnionMessage_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(blinding_point_arg, 33)), onion_routing_packet_arg == null ? 0 : onion_routing_packet_arg.ptr);
65                 GC.KeepAlive(blinding_point_arg);
66                 GC.KeepAlive(onion_routing_packet_arg);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.OnionMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessage(null, ret); }
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
70                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(onion_routing_packet_arg); };
71                 return ret_hu_conv;
72         }
73
74         internal long clone_ptr() {
75                 long ret = bindings.OnionMessage_clone_ptr(this.ptr);
76                 GC.KeepAlive(this);
77                 return ret;
78         }
79
80         /**
81          * Creates a copy of the OnionMessage
82          */
83         public OnionMessage clone() {
84                 long ret = bindings.OnionMessage_clone(this.ptr);
85                 GC.KeepAlive(this);
86                 if (ret >= 0 && ret <= 4096) { return null; }
87                 org.ldk.structs.OnionMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessage(null, ret); }
88                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
89                 return ret_hu_conv;
90         }
91
92         /**
93          * Generates a non-cryptographic 64-bit hash of the OnionMessage.
94          */
95         public long hash() {
96                 long ret = bindings.OnionMessage_hash(this.ptr);
97                 GC.KeepAlive(this);
98                 return ret;
99         }
100
101         public override int GetHashCode() {
102                 return (int)this.hash();
103         }
104         /**
105          * Checks if two OnionMessages contain equal inner contents.
106          * This ignores pointers and is_owned flags and looks at the values in fields.
107          * Two objects with NULL inner values will be considered "equal" here.
108          */
109         public bool eq(org.ldk.structs.OnionMessage b) {
110                 bool ret = bindings.OnionMessage_eq(this.ptr, b == null ? 0 : b.ptr);
111                 GC.KeepAlive(this);
112                 GC.KeepAlive(b);
113                 if (this != null) { this.ptrs_to.AddLast(b); };
114                 return ret;
115         }
116
117         public override bool Equals(object o) {
118                 if (!(o is OnionMessage)) return false;
119                 return this.eq((OnionMessage)o);
120         }
121         /**
122          * Read a OnionMessage from a byte array, created by OnionMessage_write
123          */
124         public static Result_OnionMessageDecodeErrorZ read(byte[] ser) {
125                 long ret = bindings.OnionMessage_read(InternalUtils.encodeUint8Array(ser));
126                 GC.KeepAlive(ser);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 Result_OnionMessageDecodeErrorZ ret_hu_conv = Result_OnionMessageDecodeErrorZ.constr_from_ptr(ret);
129                 return ret_hu_conv;
130         }
131
132         /**
133          * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
134          */
135         public byte[] write() {
136                 long ret = bindings.OnionMessage_write(this.ptr);
137                 GC.KeepAlive(this);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
140                 return ret_conv;
141         }
142
143 }
144 } } }