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 * Information used to forward or fail this HTLC that is being forwarded within a blinded path.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class BlindedForward extends CommonBase {
16 BlindedForward(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.BlindedForward_free(ptr); }
24 * The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound
25 * onion payload if we're the introduction node. Useful for calculating the next hop's
26 * [`msgs::UpdateAddHTLC::blinding_point`].
28 public byte[] get_inbound_blinding_point() {
29 byte[] ret = bindings.BlindedForward_get_inbound_blinding_point(this.ptr);
30 Reference.reachabilityFence(this);
35 * The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound
36 * onion payload if we're the introduction node. Useful for calculating the next hop's
37 * [`msgs::UpdateAddHTLC::blinding_point`].
39 public void set_inbound_blinding_point(byte[] val) {
40 bindings.BlindedForward_set_inbound_blinding_point(this.ptr, InternalUtils.check_arr_len(val, 33));
41 Reference.reachabilityFence(this);
42 Reference.reachabilityFence(val);
46 * If needed, this determines how this HTLC should be failed backwards, based on whether we are
47 * the introduction node.
49 public BlindedFailure get_failure() {
50 BlindedFailure ret = bindings.BlindedForward_get_failure(this.ptr);
51 Reference.reachabilityFence(this);
56 * If needed, this determines how this HTLC should be failed backwards, based on whether we are
57 * the introduction node.
59 public void set_failure(org.ldk.enums.BlindedFailure val) {
60 bindings.BlindedForward_set_failure(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * Constructs a new BlindedForward given each field
68 public static BlindedForward of(byte[] inbound_blinding_point_arg, org.ldk.enums.BlindedFailure failure_arg) {
69 long ret = bindings.BlindedForward_new(InternalUtils.check_arr_len(inbound_blinding_point_arg, 33), failure_arg);
70 Reference.reachabilityFence(inbound_blinding_point_arg);
71 Reference.reachabilityFence(failure_arg);
72 if (ret >= 0 && ret <= 4096) { return null; }
73 org.ldk.structs.BlindedForward ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedForward(null, ret); }
74 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
79 long ret = bindings.BlindedForward_clone_ptr(this.ptr);
80 Reference.reachabilityFence(this);
85 * Creates a copy of the BlindedForward
87 public BlindedForward clone() {
88 long ret = bindings.BlindedForward_clone(this.ptr);
89 Reference.reachabilityFence(this);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.BlindedForward ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BlindedForward(null, ret); }
92 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
97 * Generates a non-cryptographic 64-bit hash of the BlindedForward.
100 long ret = bindings.BlindedForward_hash(this.ptr);
101 Reference.reachabilityFence(this);
105 @Override public int hashCode() {
106 return (int)this.hash();
109 * Checks if two BlindedForwards contain equal inner contents.
110 * This ignores pointers and is_owned flags and looks at the values in fields.
111 * Two objects with NULL inner values will be considered "equal" here.
113 public boolean eq(org.ldk.structs.BlindedForward b) {
114 boolean ret = bindings.BlindedForward_eq(this.ptr, b.ptr);
115 Reference.reachabilityFence(this);
116 Reference.reachabilityFence(b);
117 if (this != null) { this.ptrs_to.add(b); };
121 @Override public boolean equals(Object o) {
122 if (!(o instanceof BlindedForward)) return false;
123 return this.eq((BlindedForward)o);
126 * Serialize the BlindedForward object into a byte array which can be read by BlindedForward_read
128 public byte[] write() {
129 byte[] ret = bindings.BlindedForward_write(this.ptr);
130 Reference.reachabilityFence(this);
135 * Read a BlindedForward from a byte array, created by BlindedForward_write
137 public static Result_BlindedForwardDecodeErrorZ read(byte[] ser) {
138 long ret = bindings.BlindedForward_read(ser);
139 Reference.reachabilityFence(ser);
140 if (ret >= 0 && ret <= 4096) { return null; }
141 Result_BlindedForwardDecodeErrorZ ret_hu_conv = Result_BlindedForwardDecodeErrorZ.constr_from_ptr(ret);