aab749c205cfc730783cd2ac181b070476ff197e
[ldk-java] / src / main / java / org / ldk / structs / ChannelPublicKeys.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  * One counterparty's public keys which do not change over the life of a channel.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChannelPublicKeys extends CommonBase {
16         ChannelPublicKeys(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.ChannelPublicKeys_free(ptr); }
21         }
22
23         /**
24          * The public key which is used to sign all commitment transactions, as it appears in the
25          * on-chain channel lock-in 2-of-2 multisig output.
26          */
27         public byte[] get_funding_pubkey() {
28                 byte[] ret = bindings.ChannelPublicKeys_get_funding_pubkey(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * The public key which is used to sign all commitment transactions, as it appears in the
35          * on-chain channel lock-in 2-of-2 multisig output.
36          */
37         public void set_funding_pubkey(byte[] val) {
38                 bindings.ChannelPublicKeys_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
39                 Reference.reachabilityFence(this);
40                 Reference.reachabilityFence(val);
41         }
42
43         /**
44          * The base point which is used (with derive_public_revocation_key) to derive per-commitment
45          * revocation keys. This is combined with the per-commitment-secret generated by the
46          * counterparty to create a secret which the counterparty can reveal to revoke previous
47          * states.
48          */
49         public byte[] get_revocation_basepoint() {
50                 byte[] ret = bindings.ChannelPublicKeys_get_revocation_basepoint(this.ptr);
51                 Reference.reachabilityFence(this);
52                 return ret;
53         }
54
55         /**
56          * The base point which is used (with derive_public_revocation_key) to derive per-commitment
57          * revocation keys. This is combined with the per-commitment-secret generated by the
58          * counterparty to create a secret which the counterparty can reveal to revoke previous
59          * states.
60          */
61         public void set_revocation_basepoint(byte[] val) {
62                 bindings.ChannelPublicKeys_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
63                 Reference.reachabilityFence(this);
64                 Reference.reachabilityFence(val);
65         }
66
67         /**
68          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
69          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
70          * static across every commitment transaction.
71          */
72         public byte[] get_payment_point() {
73                 byte[] ret = bindings.ChannelPublicKeys_get_payment_point(this.ptr);
74                 Reference.reachabilityFence(this);
75                 return ret;
76         }
77
78         /**
79          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
80          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
81          * static across every commitment transaction.
82          */
83         public void set_payment_point(byte[] val) {
84                 bindings.ChannelPublicKeys_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
85                 Reference.reachabilityFence(this);
86                 Reference.reachabilityFence(val);
87         }
88
89         /**
90          * The base point which is used (with derive_public_key) to derive a per-commitment payment
91          * public key which receives non-HTLC-encumbered funds which are only available for spending
92          * after some delay (or can be claimed via the revocation path).
93          */
94         public byte[] get_delayed_payment_basepoint() {
95                 byte[] ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this.ptr);
96                 Reference.reachabilityFence(this);
97                 return ret;
98         }
99
100         /**
101          * The base point which is used (with derive_public_key) to derive a per-commitment payment
102          * public key which receives non-HTLC-encumbered funds which are only available for spending
103          * after some delay (or can be claimed via the revocation path).
104          */
105         public void set_delayed_payment_basepoint(byte[] val) {
106                 bindings.ChannelPublicKeys_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
107                 Reference.reachabilityFence(this);
108                 Reference.reachabilityFence(val);
109         }
110
111         /**
112          * The base point which is used (with derive_public_key) to derive a per-commitment public key
113          * which is used to encumber HTLC-in-flight outputs.
114          */
115         public byte[] get_htlc_basepoint() {
116                 byte[] ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this.ptr);
117                 Reference.reachabilityFence(this);
118                 return ret;
119         }
120
121         /**
122          * The base point which is used (with derive_public_key) to derive a per-commitment public key
123          * which is used to encumber HTLC-in-flight outputs.
124          */
125         public void set_htlc_basepoint(byte[] val) {
126                 bindings.ChannelPublicKeys_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
127                 Reference.reachabilityFence(this);
128                 Reference.reachabilityFence(val);
129         }
130
131         /**
132          * Constructs a new ChannelPublicKeys given each field
133          */
134         public static ChannelPublicKeys of(byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_point_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg) {
135                 long ret = bindings.ChannelPublicKeys_new(InternalUtils.check_arr_len(funding_pubkey_arg, 33), InternalUtils.check_arr_len(revocation_basepoint_arg, 33), InternalUtils.check_arr_len(payment_point_arg, 33), InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33), InternalUtils.check_arr_len(htlc_basepoint_arg, 33));
136                 Reference.reachabilityFence(funding_pubkey_arg);
137                 Reference.reachabilityFence(revocation_basepoint_arg);
138                 Reference.reachabilityFence(payment_point_arg);
139                 Reference.reachabilityFence(delayed_payment_basepoint_arg);
140                 Reference.reachabilityFence(htlc_basepoint_arg);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
143                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
144                 return ret_hu_conv;
145         }
146
147         long clone_ptr() {
148                 long ret = bindings.ChannelPublicKeys_clone_ptr(this.ptr);
149                 Reference.reachabilityFence(this);
150                 return ret;
151         }
152
153         /**
154          * Creates a copy of the ChannelPublicKeys
155          */
156         public ChannelPublicKeys clone() {
157                 long ret = bindings.ChannelPublicKeys_clone(this.ptr);
158                 Reference.reachabilityFence(this);
159                 if (ret >= 0 && ret <= 4096) { return null; }
160                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
161                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
162                 return ret_hu_conv;
163         }
164
165         /**
166          * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys.
167          */
168         public long hash() {
169                 long ret = bindings.ChannelPublicKeys_hash(this.ptr);
170                 Reference.reachabilityFence(this);
171                 return ret;
172         }
173
174         @Override public int hashCode() {
175                 return (int)this.hash();
176         }
177         /**
178          * Checks if two ChannelPublicKeyss contain equal inner contents.
179          * This ignores pointers and is_owned flags and looks at the values in fields.
180          * Two objects with NULL inner values will be considered "equal" here.
181          */
182         public boolean eq(org.ldk.structs.ChannelPublicKeys b) {
183                 boolean ret = bindings.ChannelPublicKeys_eq(this.ptr, b == null ? 0 : b.ptr);
184                 Reference.reachabilityFence(this);
185                 Reference.reachabilityFence(b);
186                 if (this != null) { this.ptrs_to.add(b); };
187                 return ret;
188         }
189
190         @Override public boolean equals(Object o) {
191                 if (!(o instanceof ChannelPublicKeys)) return false;
192                 return this.eq((ChannelPublicKeys)o);
193         }
194         /**
195          * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read
196          */
197         public byte[] write() {
198                 byte[] ret = bindings.ChannelPublicKeys_write(this.ptr);
199                 Reference.reachabilityFence(this);
200                 return ret;
201         }
202
203         /**
204          * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write
205          */
206         public static Result_ChannelPublicKeysDecodeErrorZ read(byte[] ser) {
207                 long ret = bindings.ChannelPublicKeys_read(ser);
208                 Reference.reachabilityFence(ser);
209                 if (ret >= 0 && ret <= 4096) { return null; }
210                 Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
211                 return ret_hu_conv;
212         }
213
214 }