1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * An encrypted payload and node id corresponding to a hop in a payment or onion message path, to
13 * be encoded in the sender's onion packet. These hops cannot be identified by outside observers
14 * and thus can be used to hide the identity of the recipient.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class BlindedHop extends CommonBase {
18 BlindedHop(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.BlindedHop_free(ptr); }
26 * The blinded node id of this hop in a [`BlindedPath`].
28 public byte[] get_blinded_node_id() {
29 byte[] ret = bindings.BlindedHop_get_blinded_node_id(this.ptr);
30 Reference.reachabilityFence(this);
35 * The blinded node id of this hop in a [`BlindedPath`].
37 public void set_blinded_node_id(byte[] val) {
38 bindings.BlindedHop_set_blinded_node_id(this.ptr, InternalUtils.check_arr_len(val, 33));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The encrypted payload intended for this hop in a [`BlindedPath`].
46 * Returns a copy of the field.
48 public byte[] get_encrypted_payload() {
49 byte[] ret = bindings.BlindedHop_get_encrypted_payload(this.ptr);
50 Reference.reachabilityFence(this);
55 * The encrypted payload intended for this hop in a [`BlindedPath`].
57 public void set_encrypted_payload(byte[] val) {
58 bindings.BlindedHop_set_encrypted_payload(this.ptr, val);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
64 * Constructs a new BlindedHop given each field
66 public static BlindedHop of(byte[] blinded_node_id_arg, byte[] encrypted_payload_arg) {
67 long ret = bindings.BlindedHop_new(InternalUtils.check_arr_len(blinded_node_id_arg, 33), encrypted_payload_arg);
68 Reference.reachabilityFence(blinded_node_id_arg);
69 Reference.reachabilityFence(encrypted_payload_arg);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 org.ldk.structs.BlindedHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedHop(null, ret); }
72 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
77 long ret = bindings.BlindedHop_clone_ptr(this.ptr);
78 Reference.reachabilityFence(this);
83 * Creates a copy of the BlindedHop
85 public BlindedHop clone() {
86 long ret = bindings.BlindedHop_clone(this.ptr);
87 Reference.reachabilityFence(this);
88 if (ret >= 0 && ret <= 4096) { return null; }
89 org.ldk.structs.BlindedHop ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedHop(null, ret); }
90 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
95 * Generates a non-cryptographic 64-bit hash of the BlindedHop.
98 long ret = bindings.BlindedHop_hash(this.ptr);
99 Reference.reachabilityFence(this);
103 @Override public int hashCode() {
104 return (int)this.hash();
107 * Checks if two BlindedHops contain equal inner contents.
108 * This ignores pointers and is_owned flags and looks at the values in fields.
109 * Two objects with NULL inner values will be considered "equal" here.
111 public boolean eq(org.ldk.structs.BlindedHop b) {
112 boolean ret = bindings.BlindedHop_eq(this.ptr, b == null ? 0 : b.ptr);
113 Reference.reachabilityFence(this);
114 Reference.reachabilityFence(b);
115 if (this != null) { this.ptrs_to.add(b); };
119 @Override public boolean equals(Object o) {
120 if (!(o instanceof BlindedHop)) return false;
121 return this.eq((BlindedHop)o);
124 * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read
126 public byte[] write() {
127 byte[] ret = bindings.BlindedHop_write(this.ptr);
128 Reference.reachabilityFence(this);
133 * Read a BlindedHop from a byte array, created by BlindedHop_write
135 public static Result_BlindedHopDecodeErrorZ read(byte[] ser) {
136 long ret = bindings.BlindedHop_read(ser);
137 Reference.reachabilityFence(ser);
138 if (ret >= 0 && ret <= 4096) { return null; }
139 Result_BlindedHopDecodeErrorZ ret_hu_conv = Result_BlindedHopDecodeErrorZ.constr_from_ptr(ret);