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 * The blinded portion of a [`Path`], if we're routing to a recipient who provided blinded paths in
13 * their [`Bolt12Invoice`].
15 * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class BlindedTail extends CommonBase {
19 BlindedTail(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.BlindedTail_free(ptr); }
27 * The hops of the [`BlindedPath`] provided by the recipient.
29 * [`BlindedPath`]: crate::blinded_path::BlindedPath
31 public BlindedHop[] get_hops() {
32 long[] ret = bindings.BlindedTail_get_hops(this.ptr);
33 Reference.reachabilityFence(this);
34 int ret_conv_12_len = ret.length;
35 BlindedHop[] ret_conv_12_arr = new BlindedHop[ret_conv_12_len];
36 for (int m = 0; m < ret_conv_12_len; m++) {
37 long ret_conv_12 = ret[m];
38 org.ldk.structs.BlindedHop ret_conv_12_hu_conv = null; if (ret_conv_12 < 0 || ret_conv_12 > 4096) { ret_conv_12_hu_conv = new org.ldk.structs.BlindedHop(null, ret_conv_12); }
39 if (ret_conv_12_hu_conv != null) { ret_conv_12_hu_conv.ptrs_to.add(this); };
40 ret_conv_12_arr[m] = ret_conv_12_hu_conv;
42 return ret_conv_12_arr;
46 * The hops of the [`BlindedPath`] provided by the recipient.
48 * [`BlindedPath`]: crate::blinded_path::BlindedPath
50 public void set_hops(BlindedHop[] val) {
51 bindings.BlindedTail_set_hops(this.ptr, val != null ? Arrays.stream(val).mapToLong(val_conv_12 -> val_conv_12.ptr).toArray() : null);
52 Reference.reachabilityFence(this);
53 Reference.reachabilityFence(val);
54 for (BlindedHop val_conv_12: val) { if (this != null) { this.ptrs_to.add(val_conv_12); }; };
58 * The blinding point of the [`BlindedPath`] provided by the recipient.
60 * [`BlindedPath`]: crate::blinded_path::BlindedPath
62 public byte[] get_blinding_point() {
63 byte[] ret = bindings.BlindedTail_get_blinding_point(this.ptr);
64 Reference.reachabilityFence(this);
69 * The blinding point of the [`BlindedPath`] provided by the recipient.
71 * [`BlindedPath`]: crate::blinded_path::BlindedPath
73 public void set_blinding_point(byte[] val) {
74 bindings.BlindedTail_set_blinding_point(this.ptr, InternalUtils.check_arr_len(val, 33));
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
81 * inferring the destination. May be 0.
83 public int get_excess_final_cltv_expiry_delta() {
84 int ret = bindings.BlindedTail_get_excess_final_cltv_expiry_delta(this.ptr);
85 Reference.reachabilityFence(this);
90 * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from
91 * inferring the destination. May be 0.
93 public void set_excess_final_cltv_expiry_delta(int val) {
94 bindings.BlindedTail_set_excess_final_cltv_expiry_delta(this.ptr, val);
95 Reference.reachabilityFence(this);
96 Reference.reachabilityFence(val);
100 * The total amount paid on this [`Path`], excluding the fees.
102 public long get_final_value_msat() {
103 long ret = bindings.BlindedTail_get_final_value_msat(this.ptr);
104 Reference.reachabilityFence(this);
109 * The total amount paid on this [`Path`], excluding the fees.
111 public void set_final_value_msat(long val) {
112 bindings.BlindedTail_set_final_value_msat(this.ptr, val);
113 Reference.reachabilityFence(this);
114 Reference.reachabilityFence(val);
118 * Constructs a new BlindedTail given each field
120 public static BlindedTail of(BlindedHop[] hops_arg, byte[] blinding_point_arg, int excess_final_cltv_expiry_delta_arg, long final_value_msat_arg) {
121 long ret = bindings.BlindedTail_new(hops_arg != null ? Arrays.stream(hops_arg).mapToLong(hops_arg_conv_12 -> hops_arg_conv_12.ptr).toArray() : null, InternalUtils.check_arr_len(blinding_point_arg, 33), excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
122 Reference.reachabilityFence(hops_arg);
123 Reference.reachabilityFence(blinding_point_arg);
124 Reference.reachabilityFence(excess_final_cltv_expiry_delta_arg);
125 Reference.reachabilityFence(final_value_msat_arg);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.BlindedTail ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedTail(null, ret); }
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
129 for (BlindedHop hops_arg_conv_12: hops_arg) { if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(hops_arg_conv_12); }; };
134 long ret = bindings.BlindedTail_clone_ptr(this.ptr);
135 Reference.reachabilityFence(this);
140 * Creates a copy of the BlindedTail
142 public BlindedTail clone() {
143 long ret = bindings.BlindedTail_clone(this.ptr);
144 Reference.reachabilityFence(this);
145 if (ret >= 0 && ret <= 4096) { return null; }
146 org.ldk.structs.BlindedTail ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedTail(null, ret); }
147 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
152 * Generates a non-cryptographic 64-bit hash of the BlindedTail.
155 long ret = bindings.BlindedTail_hash(this.ptr);
156 Reference.reachabilityFence(this);
160 @Override public int hashCode() {
161 return (int)this.hash();
164 * Checks if two BlindedTails contain equal inner contents.
165 * This ignores pointers and is_owned flags and looks at the values in fields.
166 * Two objects with NULL inner values will be considered "equal" here.
168 public boolean eq(org.ldk.structs.BlindedTail b) {
169 boolean ret = bindings.BlindedTail_eq(this.ptr, b.ptr);
170 Reference.reachabilityFence(this);
171 Reference.reachabilityFence(b);
172 if (this != null) { this.ptrs_to.add(b); };
176 @Override public boolean equals(Object o) {
177 if (!(o instanceof BlindedTail)) return false;
178 return this.eq((BlindedTail)o);
181 * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read
183 public byte[] write() {
184 byte[] ret = bindings.BlindedTail_write(this.ptr);
185 Reference.reachabilityFence(this);
190 * Read a BlindedTail from a byte array, created by BlindedTail_write
192 public static Result_BlindedTailDecodeErrorZ read(byte[] ser) {
193 long ret = bindings.BlindedTail_read(ser);
194 Reference.reachabilityFence(ser);
195 if (ret >= 0 && ret <= 4096) { return null; }
196 Result_BlindedTailDecodeErrorZ ret_hu_conv = Result_BlindedTailDecodeErrorZ.constr_from_ptr(ret);