[Java] Update auto-generated bindings to 0.0.117
[ldk-java] / src / main / java / org / ldk / structs / BlindedHop.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
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.
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.BlindedHop_free(ptr); }
23         }
24
25         /**
26          * The blinded node id of this hop in a [`BlindedPath`].
27          */
28         public byte[] get_blinded_node_id() {
29                 byte[] ret = bindings.BlindedHop_get_blinded_node_id(this.ptr);
30                 Reference.reachabilityFence(this);
31                 return ret;
32         }
33
34         /**
35          * The blinded node id of this hop in a [`BlindedPath`].
36          */
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);
41         }
42
43         /**
44          * The encrypted payload intended for this hop in a [`BlindedPath`].
45          * 
46          * Returns a copy of the field.
47          */
48         public byte[] get_encrypted_payload() {
49                 byte[] ret = bindings.BlindedHop_get_encrypted_payload(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * The encrypted payload intended for this hop in a [`BlindedPath`].
56          */
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);
61         }
62
63         /**
64          * Constructs a new BlindedHop given each field
65          */
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); };
73                 return ret_hu_conv;
74         }
75
76         long clone_ptr() {
77                 long ret = bindings.BlindedHop_clone_ptr(this.ptr);
78                 Reference.reachabilityFence(this);
79                 return ret;
80         }
81
82         /**
83          * Creates a copy of the BlindedHop
84          */
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); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Generates a non-cryptographic 64-bit hash of the BlindedHop.
96          */
97         public long hash() {
98                 long ret = bindings.BlindedHop_hash(this.ptr);
99                 Reference.reachabilityFence(this);
100                 return ret;
101         }
102
103         @Override public int hashCode() {
104                 return (int)this.hash();
105         }
106         /**
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.
110          */
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); };
116                 return ret;
117         }
118
119         @Override public boolean equals(Object o) {
120                 if (!(o instanceof BlindedHop)) return false;
121                 return this.eq((BlindedHop)o);
122         }
123         /**
124          * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read
125          */
126         public byte[] write() {
127                 byte[] ret = bindings.BlindedHop_write(this.ptr);
128                 Reference.reachabilityFence(this);
129                 return ret;
130         }
131
132         /**
133          * Read a BlindedHop from a byte array, created by BlindedHop_write
134          */
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);
140                 return ret_hu_conv;
141         }
142
143 }