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 * A hash for use in a specific context by tweaking with a context-dependent tag as per [BIP 340]
13 * and computed over the merkle root of a TLV stream to sign as defined in [BOLT 12].
15 * [BIP 340]: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
16 * [BOLT 12]: https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md#signature-calculation
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class TaggedHash extends CommonBase {
20 TaggedHash(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.TaggedHash_free(ptr); }
28 long ret = bindings.TaggedHash_clone_ptr(this.ptr);
29 Reference.reachabilityFence(this);
34 * Creates a copy of the TaggedHash
36 public TaggedHash clone() {
37 long ret = bindings.TaggedHash_clone(this.ptr);
38 Reference.reachabilityFence(this);
39 if (ret >= 0 && ret <= 4096) { return null; }
40 org.ldk.structs.TaggedHash ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TaggedHash(null, ret); }
41 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
46 * Returns the digest to sign.
48 public byte[] as_digest() {
49 byte[] ret = bindings.TaggedHash_as_digest(this.ptr);
50 Reference.reachabilityFence(this);
55 * Returns the tag used in the tagged hash.
58 String ret = bindings.TaggedHash_tag(this.ptr);
59 Reference.reachabilityFence(this);
64 * Returns the merkle root used in the tagged hash.
66 public byte[] merkle_root() {
67 byte[] ret = bindings.TaggedHash_merkle_root(this.ptr);
68 Reference.reachabilityFence(this);