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 * Master key used in conjunction with per_commitment_point to generate [htlcpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#key-derivation) for the latest state of a channel.
13 * A watcher can be given a [RevocationBasepoint] to generate per commitment [RevocationKey] to create justice transactions.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class RevocationBasepoint extends CommonBase {
17 RevocationBasepoint(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.RevocationBasepoint_free(ptr); }
24 public byte[] get_a() {
25 byte[] ret = bindings.RevocationBasepoint_get_a(this.ptr);
26 Reference.reachabilityFence(this);
30 public void set_a(byte[] val) {
31 bindings.RevocationBasepoint_set_a(this.ptr, InternalUtils.check_arr_len(val, 33));
32 Reference.reachabilityFence(this);
33 Reference.reachabilityFence(val);
37 * Constructs a new RevocationBasepoint given each field
39 public static RevocationBasepoint of(byte[] a_arg) {
40 long ret = bindings.RevocationBasepoint_new(InternalUtils.check_arr_len(a_arg, 33));
41 Reference.reachabilityFence(a_arg);
42 if (ret >= 0 && ret <= 4096) { return null; }
43 org.ldk.structs.RevocationBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationBasepoint(null, ret); }
44 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
49 * Checks if two RevocationBasepoints contain equal inner contents.
50 * This ignores pointers and is_owned flags and looks at the values in fields.
51 * Two objects with NULL inner values will be considered "equal" here.
53 public boolean eq(org.ldk.structs.RevocationBasepoint b) {
54 boolean ret = bindings.RevocationBasepoint_eq(this.ptr, b == null ? 0 : b.ptr);
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(b);
57 if (this != null) { this.ptrs_to.add(b); };
61 @Override public boolean equals(Object o) {
62 if (!(o instanceof RevocationBasepoint)) return false;
63 return this.eq((RevocationBasepoint)o);
66 long ret = bindings.RevocationBasepoint_clone_ptr(this.ptr);
67 Reference.reachabilityFence(this);
72 * Creates a copy of the RevocationBasepoint
74 public RevocationBasepoint clone() {
75 long ret = bindings.RevocationBasepoint_clone(this.ptr);
76 Reference.reachabilityFence(this);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 org.ldk.structs.RevocationBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationBasepoint(null, ret); }
79 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
84 * Generates a non-cryptographic 64-bit hash of the RevocationBasepoint.
87 long ret = bindings.RevocationBasepoint_hash(this.ptr);
88 Reference.reachabilityFence(this);
92 @Override public int hashCode() {
93 return (int)this.hash();
96 * Get inner Public Key
98 public byte[] to_public_key() {
99 byte[] ret = bindings.RevocationBasepoint_to_public_key(this.ptr);
100 Reference.reachabilityFence(this);
105 * Serialize the RevocationBasepoint object into a byte array which can be read by RevocationBasepoint_read
107 public byte[] write() {
108 byte[] ret = bindings.RevocationBasepoint_write(this.ptr);
109 Reference.reachabilityFence(this);
114 * Read a RevocationBasepoint from a byte array, created by RevocationBasepoint_write
116 public static Result_RevocationBasepointDecodeErrorZ read(byte[] ser) {
117 long ret = bindings.RevocationBasepoint_read(ser);
118 Reference.reachabilityFence(ser);
119 if (ret >= 0 && ret <= 4096) { return null; }
120 Result_RevocationBasepointDecodeErrorZ ret_hu_conv = Result_RevocationBasepointDecodeErrorZ.constr_from_ptr(ret);