6 namespace org { namespace ldk { namespace structs {
10 * An onion message to be sent to or received from a peer.
12 public class OnionMessage : CommonBase {
13 internal OnionMessage(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.OnionMessage_free(ptr); }
19 * Used in decrypting the onion packet's payload.
21 public byte[] get_blinding_point() {
22 long ret = bindings.OnionMessage_get_blinding_point(this.ptr);
24 if (ret >= 0 && ret <= 4096) { return null; }
25 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
30 * Used in decrypting the onion packet's payload.
32 public void set_blinding_point(byte[] val) {
33 bindings.OnionMessage_set_blinding_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
39 * The full onion packet including hop data, pubkey, and hmac
41 public Packet get_onion_routing_packet() {
42 long ret = bindings.OnionMessage_get_onion_routing_packet(this.ptr);
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); };
51 * The full onion packet including hop data, pubkey, and hmac
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);
57 if (this != null) { this.ptrs_to.AddLast(val); };
61 * Constructs a new OnionMessage given each field
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); };
74 internal long clone_ptr() {
75 long ret = bindings.OnionMessage_clone_ptr(this.ptr);
81 * Creates a copy of the OnionMessage
83 public OnionMessage clone() {
84 long ret = bindings.OnionMessage_clone(this.ptr);
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); };
93 * Checks if two OnionMessages contain equal inner contents.
94 * This ignores pointers and is_owned flags and looks at the values in fields.
95 * Two objects with NULL inner values will be considered "equal" here.
97 public bool eq(org.ldk.structs.OnionMessage b) {
98 bool ret = bindings.OnionMessage_eq(this.ptr, b == null ? 0 : b.ptr);
101 if (this != null) { this.ptrs_to.AddLast(b); };
105 public override bool Equals(object o) {
106 if (!(o is OnionMessage)) return false;
107 return this.eq((OnionMessage)o);
110 * Read a OnionMessage from a byte array, created by OnionMessage_write
112 public static Result_OnionMessageDecodeErrorZ read(byte[] ser) {
113 long ret = bindings.OnionMessage_read(InternalUtils.encodeUint8Array(ser));
115 if (ret >= 0 && ret <= 4096) { return null; }
116 Result_OnionMessageDecodeErrorZ ret_hu_conv = Result_OnionMessageDecodeErrorZ.constr_from_ptr(ret);
121 * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read
123 public byte[] write() {
124 long ret = bindings.OnionMessage_write(this.ptr);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);