60e5e0b647724a80579fdf9657da15e236012bda
[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 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                 byte[] ret = bindings.OnionMessage_get_blinding_point(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * Used in decrypting the onion packet's payload.
29          */
30         public void set_blinding_point(byte[] val) {
31                 bindings.OnionMessage_set_blinding_point(this.ptr, InternalUtils.check_arr_len(val, 33));
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         internal long clone_ptr() {
37                 long ret = bindings.OnionMessage_clone_ptr(this.ptr);
38                 GC.KeepAlive(this);
39                 return ret;
40         }
41
42         /**
43          * Creates a copy of the OnionMessage
44          */
45         public OnionMessage clone() {
46                 long ret = bindings.OnionMessage_clone(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 org.ldk.structs.OnionMessage ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OnionMessage(null, ret); }
50                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
51                 return ret_hu_conv;
52         }
53
54         /**
55          * Checks if two OnionMessages contain equal inner contents.
56          * This ignores pointers and is_owned flags and looks at the values in fields.
57          * Two objects with NULL inner values will be considered "equal" here.
58          */
59         public bool eq(org.ldk.structs.OnionMessage b) {
60                 bool ret = bindings.OnionMessage_eq(this.ptr, b == null ? 0 : b.ptr);
61                 GC.KeepAlive(this);
62                 GC.KeepAlive(b);
63                 if (this != null) { this.ptrs_to.AddLast(b); };
64                 return ret;
65         }
66
67         public override bool Equals(object o) {
68                 if (!(o is OnionMessage)) return false;
69                 return this.eq((OnionMessage)o);
70         }
71         /**
72          * Read a OnionMessage from a byte array, created by OnionMessage_write
73          */
74         public static Result_OnionMessageDecodeErrorZ read(byte[] ser) {
75                 long ret = bindings.OnionMessage_read(ser);
76                 GC.KeepAlive(ser);
77                 if (ret >= 0 && ret <= 4096) { return null; }
78                 Result_OnionMessageDecodeErrorZ ret_hu_conv = Result_OnionMessageDecodeErrorZ.constr_from_ptr(ret);
79                 return ret_hu_conv;
80         }
81
82         /**
83          * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
84          */
85         public byte[] write() {
86                 byte[] ret = bindings.OnionMessage_write(this.ptr);
87                 GC.KeepAlive(this);
88                 return ret;
89         }
90
91 }
92 } } }