[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / HtlcBasepoint.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Base key used in conjunction with a `per_commitment_point` to generate an [`HtlcKey`].
13  * 
14  * HTLC keys are used to ensure only the recipient of an HTLC can claim it on-chain with the HTLC
15  * preimage and that only the sender of an HTLC can claim it on-chain after it has timed out.
16  * Thus, both channel counterparties' HTLC keys will appears in each HTLC output's script.
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class HtlcBasepoint extends CommonBase {
20         HtlcBasepoint(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.HtlcBasepoint_free(ptr); }
25         }
26
27         public byte[] get_a() {
28                 byte[] ret = bindings.HtlcBasepoint_get_a(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         public void set_a(byte[] val) {
34                 bindings.HtlcBasepoint_set_a(this.ptr, InternalUtils.check_arr_len(val, 33));
35                 Reference.reachabilityFence(this);
36                 Reference.reachabilityFence(val);
37         }
38
39         /**
40          * Constructs a new HtlcBasepoint given each field
41          */
42         public static HtlcBasepoint of(byte[] a_arg) {
43                 long ret = bindings.HtlcBasepoint_new(InternalUtils.check_arr_len(a_arg, 33));
44                 Reference.reachabilityFence(a_arg);
45                 if (ret >= 0 && ret <= 4096) { return null; }
46                 org.ldk.structs.HtlcBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcBasepoint(null, ret); }
47                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
48                 return ret_hu_conv;
49         }
50
51         /**
52          * Checks if two HtlcBasepoints contain equal inner contents.
53          * This ignores pointers and is_owned flags and looks at the values in fields.
54          * Two objects with NULL inner values will be considered "equal" here.
55          */
56         public boolean eq(org.ldk.structs.HtlcBasepoint b) {
57                 boolean ret = bindings.HtlcBasepoint_eq(this.ptr, b == null ? 0 : b.ptr);
58                 Reference.reachabilityFence(this);
59                 Reference.reachabilityFence(b);
60                 if (this != null) { this.ptrs_to.add(b); };
61                 return ret;
62         }
63
64         @Override public boolean equals(Object o) {
65                 if (!(o instanceof HtlcBasepoint)) return false;
66                 return this.eq((HtlcBasepoint)o);
67         }
68         long clone_ptr() {
69                 long ret = bindings.HtlcBasepoint_clone_ptr(this.ptr);
70                 Reference.reachabilityFence(this);
71                 return ret;
72         }
73
74         /**
75          * Creates a copy of the HtlcBasepoint
76          */
77         public HtlcBasepoint clone() {
78                 long ret = bindings.HtlcBasepoint_clone(this.ptr);
79                 Reference.reachabilityFence(this);
80                 if (ret >= 0 && ret <= 4096) { return null; }
81                 org.ldk.structs.HtlcBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcBasepoint(null, ret); }
82                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * Generates a non-cryptographic 64-bit hash of the HtlcBasepoint.
88          */
89         public long hash() {
90                 long ret = bindings.HtlcBasepoint_hash(this.ptr);
91                 Reference.reachabilityFence(this);
92                 return ret;
93         }
94
95         @Override public int hashCode() {
96                 return (int)this.hash();
97         }
98         /**
99          * Get inner Public Key
100          */
101         public byte[] to_public_key() {
102                 byte[] ret = bindings.HtlcBasepoint_to_public_key(this.ptr);
103                 Reference.reachabilityFence(this);
104                 return ret;
105         }
106
107         /**
108          * Serialize the HtlcBasepoint object into a byte array which can be read by HtlcBasepoint_read
109          */
110         public byte[] write() {
111                 byte[] ret = bindings.HtlcBasepoint_write(this.ptr);
112                 Reference.reachabilityFence(this);
113                 return ret;
114         }
115
116         /**
117          * Read a HtlcBasepoint from a byte array, created by HtlcBasepoint_write
118          */
119         public static Result_HtlcBasepointDecodeErrorZ read(byte[] ser) {
120                 long ret = bindings.HtlcBasepoint_read(ser);
121                 Reference.reachabilityFence(ser);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 Result_HtlcBasepointDecodeErrorZ ret_hu_conv = Result_HtlcBasepointDecodeErrorZ.constr_from_ptr(ret);
124                 return ret_hu_conv;
125         }
126
127 }