6 namespace org { namespace ldk { namespace structs {
10 * Packet of hop data for next peer
12 public class Packet : CommonBase {
13 internal Packet(object _dummy, long ptr) : base(ptr) { }
15 if (ptr != 0) { bindings.Packet_free(ptr); }
19 * Bolt 04 version number
21 public byte get_version() {
22 byte ret = bindings.Packet_get_version(this.ptr);
28 * Bolt 04 version number
30 public void set_version(byte val) {
31 bindings.Packet_set_version(this.ptr, val);
37 * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
39 public byte[] get_public_key() {
40 long ret = bindings.Packet_get_public_key(this.ptr);
42 if (ret >= 0 && ret <= 4096) { return null; }
43 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
48 * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data
50 public void set_public_key(byte[] val) {
51 bindings.Packet_set_public_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
57 * Encrypted payload for the next hop
59 * Returns a copy of the field.
61 public byte[] get_hop_data() {
62 long ret = bindings.Packet_get_hop_data(this.ptr);
64 if (ret >= 0 && ret <= 4096) { return null; }
65 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
70 * Encrypted payload for the next hop
72 public void set_hop_data(byte[] val) {
73 bindings.Packet_set_hop_data(this.ptr, InternalUtils.encodeUint8Array(val));
79 * HMAC to verify the integrity of hop_data
81 public byte[] get_hmac() {
82 long ret = bindings.Packet_get_hmac(this.ptr);
84 if (ret >= 0 && ret <= 4096) { return null; }
85 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
90 * HMAC to verify the integrity of hop_data
92 public void set_hmac(byte[] val) {
93 bindings.Packet_set_hmac(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
99 * Constructs a new Packet given each field
101 public static Packet of(byte version_arg, byte[] public_key_arg, byte[] hop_data_arg, byte[] hmac_arg) {
102 long ret = bindings.Packet_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.Packet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Packet(null, ret); }
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
113 internal long clone_ptr() {
114 long ret = bindings.Packet_clone_ptr(this.ptr);
120 * Creates a copy of the Packet
122 public Packet clone() {
123 long ret = bindings.Packet_clone(this.ptr);
125 if (ret >= 0 && ret <= 4096) { return null; }
126 org.ldk.structs.Packet ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Packet(null, ret); }
127 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
132 * Generates a non-cryptographic 64-bit hash of the Packet.
135 long ret = bindings.Packet_hash(this.ptr);
140 public override int GetHashCode() {
141 return (int)this.hash();
144 * Checks if two Packets 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.
148 public bool eq(org.ldk.structs.Packet b) {
149 bool ret = bindings.Packet_eq(this.ptr, b == null ? 0 : b.ptr);
152 if (this != null) { this.ptrs_to.AddLast(b); };
156 public override bool Equals(object o) {
157 if (!(o is Packet)) return false;
158 return this.eq((Packet)o);
161 * Serialize the Packet object into a byte array which can be read by Packet_read
163 public byte[] write() {
164 long ret = bindings.Packet_write(this.ptr);
166 if (ret >= 0 && ret <= 4096) { return null; }
167 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);