X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FBlindedHop.java;fp=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FBlindedHop.java;h=5432512ef5c7c4851469d12a1088fe620572228b;hb=76982ad5233afc2759d085bb243f33149369ab9b;hp=0000000000000000000000000000000000000000;hpb=227672ae3d27961f63d45913aad01dbae1f53e99;p=ldk-java diff --git a/src/main/java/org/ldk/structs/BlindedHop.java b/src/main/java/org/ldk/structs/BlindedHop.java new file mode 100644 index 00000000..5432512e --- /dev/null +++ b/src/main/java/org/ldk/structs/BlindedHop.java @@ -0,0 +1,44 @@ +package org.ldk.structs; + +import org.ldk.impl.bindings; +import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; + + +/** + * Used to construct the blinded hops portion of a blinded route. These hops cannot be identified + * by outside observers and thus can be used to hide the identity of the recipient. + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays +public class BlindedHop extends CommonBase { + BlindedHop(Object _dummy, long ptr) { super(ptr); } + @Override @SuppressWarnings("deprecation") + protected void finalize() throws Throwable { + super.finalize(); + if (ptr != 0) { bindings.BlindedHop_free(ptr); } + } + + /** + * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read + */ + public byte[] write() { + byte[] ret = bindings.BlindedHop_write(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Read a BlindedHop from a byte array, created by BlindedHop_write + */ + public static Result_BlindedHopDecodeErrorZ read(byte[] ser) { + long ret = bindings.BlindedHop_read(ser); + Reference.reachabilityFence(ser); + if (ret >= 0 && ret <= 4096) { return null; } + Result_BlindedHopDecodeErrorZ ret_hu_conv = Result_BlindedHopDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + +}