[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / TxCreationKeys.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  * The set of public keys which are used in the creation of one commitment transaction.
13  * These are derived from the channel base keys and per-commitment data.
14  * 
15  * A broadcaster key is provided from potential broadcaster of the computed transaction.
16  * A countersignatory key is coming from a protocol participant unable to broadcast the
17  * transaction.
18  * 
19  * These keys are assumed to be good, either because the code derived them from
20  * channel basepoints via the new function, or they were obtained via
21  * CommitmentTransaction.trust().keys() because we trusted the source of the
22  * pre-calculated keys.
23  */
24 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
25 public class TxCreationKeys extends CommonBase {
26         TxCreationKeys(Object _dummy, long ptr) { super(ptr); }
27         @Override @SuppressWarnings("deprecation")
28         protected void finalize() throws Throwable {
29                 super.finalize();
30                 if (ptr != 0) { bindings.TxCreationKeys_free(ptr); }
31         }
32
33         /**
34          * The broadcaster's per-commitment public key which was used to derive the other keys.
35          */
36         public byte[] get_per_commitment_point() {
37                 byte[] ret = bindings.TxCreationKeys_get_per_commitment_point(this.ptr);
38                 Reference.reachabilityFence(this);
39                 return ret;
40         }
41
42         /**
43          * The broadcaster's per-commitment public key which was used to derive the other keys.
44          */
45         public void set_per_commitment_point(byte[] val) {
46                 bindings.TxCreationKeys_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
47                 Reference.reachabilityFence(this);
48                 Reference.reachabilityFence(val);
49         }
50
51         /**
52          * The revocation key which is used to allow the broadcaster of the commitment
53          * transaction to provide their counterparty the ability to punish them if they broadcast
54          * an old state.
55          */
56         public RevocationKey get_revocation_key() {
57                 long ret = bindings.TxCreationKeys_get_revocation_key(this.ptr);
58                 Reference.reachabilityFence(this);
59                 if (ret >= 0 && ret <= 4096) { return null; }
60                 org.ldk.structs.RevocationKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationKey(null, ret); }
61                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
62                 return ret_hu_conv;
63         }
64
65         /**
66          * The revocation key which is used to allow the broadcaster of the commitment
67          * transaction to provide their counterparty the ability to punish them if they broadcast
68          * an old state.
69          */
70         public void set_revocation_key(org.ldk.structs.RevocationKey val) {
71                 bindings.TxCreationKeys_set_revocation_key(this.ptr, val == null ? 0 : val.ptr);
72                 Reference.reachabilityFence(this);
73                 Reference.reachabilityFence(val);
74                 if (this != null) { this.ptrs_to.add(val); };
75         }
76
77         /**
78          * Broadcaster's HTLC Key
79          */
80         public HtlcKey get_broadcaster_htlc_key() {
81                 long ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr);
82                 Reference.reachabilityFence(this);
83                 if (ret >= 0 && ret <= 4096) { return null; }
84                 org.ldk.structs.HtlcKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcKey(null, ret); }
85                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Broadcaster's HTLC Key
91          */
92         public void set_broadcaster_htlc_key(org.ldk.structs.HtlcKey val) {
93                 bindings.TxCreationKeys_set_broadcaster_htlc_key(this.ptr, val == null ? 0 : val.ptr);
94                 Reference.reachabilityFence(this);
95                 Reference.reachabilityFence(val);
96                 if (this != null) { this.ptrs_to.add(val); };
97         }
98
99         /**
100          * Countersignatory's HTLC Key
101          */
102         public HtlcKey get_countersignatory_htlc_key() {
103                 long ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr);
104                 Reference.reachabilityFence(this);
105                 if (ret >= 0 && ret <= 4096) { return null; }
106                 org.ldk.structs.HtlcKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcKey(null, ret); }
107                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Countersignatory's HTLC Key
113          */
114         public void set_countersignatory_htlc_key(org.ldk.structs.HtlcKey val) {
115                 bindings.TxCreationKeys_set_countersignatory_htlc_key(this.ptr, val == null ? 0 : val.ptr);
116                 Reference.reachabilityFence(this);
117                 Reference.reachabilityFence(val);
118                 if (this != null) { this.ptrs_to.add(val); };
119         }
120
121         /**
122          * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
123          */
124         public DelayedPaymentKey get_broadcaster_delayed_payment_key() {
125                 long ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr);
126                 Reference.reachabilityFence(this);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 org.ldk.structs.DelayedPaymentKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentKey(null, ret); }
129                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
130                 return ret_hu_conv;
131         }
132
133         /**
134          * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
135          */
136         public void set_broadcaster_delayed_payment_key(org.ldk.structs.DelayedPaymentKey val) {
137                 bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this.ptr, val == null ? 0 : val.ptr);
138                 Reference.reachabilityFence(this);
139                 Reference.reachabilityFence(val);
140                 if (this != null) { this.ptrs_to.add(val); };
141         }
142
143         /**
144          * Constructs a new TxCreationKeys given each field
145          */
146         public static TxCreationKeys of(byte[] per_commitment_point_arg, org.ldk.structs.RevocationKey revocation_key_arg, org.ldk.structs.HtlcKey broadcaster_htlc_key_arg, org.ldk.structs.HtlcKey countersignatory_htlc_key_arg, org.ldk.structs.DelayedPaymentKey broadcaster_delayed_payment_key_arg) {
147                 long ret = bindings.TxCreationKeys_new(InternalUtils.check_arr_len(per_commitment_point_arg, 33), revocation_key_arg == null ? 0 : revocation_key_arg.ptr, broadcaster_htlc_key_arg == null ? 0 : broadcaster_htlc_key_arg.ptr, countersignatory_htlc_key_arg == null ? 0 : countersignatory_htlc_key_arg.ptr, broadcaster_delayed_payment_key_arg == null ? 0 : broadcaster_delayed_payment_key_arg.ptr);
148                 Reference.reachabilityFence(per_commitment_point_arg);
149                 Reference.reachabilityFence(revocation_key_arg);
150                 Reference.reachabilityFence(broadcaster_htlc_key_arg);
151                 Reference.reachabilityFence(countersignatory_htlc_key_arg);
152                 Reference.reachabilityFence(broadcaster_delayed_payment_key_arg);
153                 if (ret >= 0 && ret <= 4096) { return null; }
154                 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(revocation_key_arg); };
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(broadcaster_htlc_key_arg); };
158                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(countersignatory_htlc_key_arg); };
159                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(broadcaster_delayed_payment_key_arg); };
160                 return ret_hu_conv;
161         }
162
163         /**
164          * Checks if two TxCreationKeyss contain equal inner contents.
165          * This ignores pointers and is_owned flags and looks at the values in fields.
166          * Two objects with NULL inner values will be considered "equal" here.
167          */
168         public boolean eq(org.ldk.structs.TxCreationKeys b) {
169                 boolean ret = bindings.TxCreationKeys_eq(this.ptr, b == null ? 0 : b.ptr);
170                 Reference.reachabilityFence(this);
171                 Reference.reachabilityFence(b);
172                 if (this != null) { this.ptrs_to.add(b); };
173                 return ret;
174         }
175
176         @Override public boolean equals(Object o) {
177                 if (!(o instanceof TxCreationKeys)) return false;
178                 return this.eq((TxCreationKeys)o);
179         }
180         long clone_ptr() {
181                 long ret = bindings.TxCreationKeys_clone_ptr(this.ptr);
182                 Reference.reachabilityFence(this);
183                 return ret;
184         }
185
186         /**
187          * Creates a copy of the TxCreationKeys
188          */
189         public TxCreationKeys clone() {
190                 long ret = bindings.TxCreationKeys_clone(this.ptr);
191                 Reference.reachabilityFence(this);
192                 if (ret >= 0 && ret <= 4096) { return null; }
193                 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
194                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
195                 return ret_hu_conv;
196         }
197
198         /**
199          * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
200          */
201         public byte[] write() {
202                 byte[] ret = bindings.TxCreationKeys_write(this.ptr);
203                 Reference.reachabilityFence(this);
204                 return ret;
205         }
206
207         /**
208          * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
209          */
210         public static Result_TxCreationKeysDecodeErrorZ read(byte[] ser) {
211                 long ret = bindings.TxCreationKeys_read(ser);
212                 Reference.reachabilityFence(ser);
213                 if (ret >= 0 && ret <= 4096) { return null; }
214                 Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
215                 return ret_hu_conv;
216         }
217
218         /**
219          * Create per-state keys from channel base points and the per-commitment point.
220          * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
221          */
222         public static TxCreationKeys derive_new(byte[] per_commitment_point, org.ldk.structs.DelayedPaymentBasepoint broadcaster_delayed_payment_base, org.ldk.structs.HtlcBasepoint broadcaster_htlc_base, org.ldk.structs.RevocationBasepoint countersignatory_revocation_base, org.ldk.structs.HtlcBasepoint countersignatory_htlc_base) {
223                 long ret = bindings.TxCreationKeys_derive_new(InternalUtils.check_arr_len(per_commitment_point, 33), broadcaster_delayed_payment_base == null ? 0 : broadcaster_delayed_payment_base.ptr, broadcaster_htlc_base == null ? 0 : broadcaster_htlc_base.ptr, countersignatory_revocation_base == null ? 0 : countersignatory_revocation_base.ptr, countersignatory_htlc_base == null ? 0 : countersignatory_htlc_base.ptr);
224                 Reference.reachabilityFence(per_commitment_point);
225                 Reference.reachabilityFence(broadcaster_delayed_payment_base);
226                 Reference.reachabilityFence(broadcaster_htlc_base);
227                 Reference.reachabilityFence(countersignatory_revocation_base);
228                 Reference.reachabilityFence(countersignatory_htlc_base);
229                 if (ret >= 0 && ret <= 4096) { return null; }
230                 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
231                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
232                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(broadcaster_delayed_payment_base); };
233                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(broadcaster_htlc_base); };
234                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(countersignatory_revocation_base); };
235                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(countersignatory_htlc_base); };
236                 return ret_hu_conv;
237         }
238
239         /**
240          * Generate per-state keys from channel static keys.
241          * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
242          */
243         public static TxCreationKeys from_channel_static_keys(byte[] per_commitment_point, org.ldk.structs.ChannelPublicKeys broadcaster_keys, org.ldk.structs.ChannelPublicKeys countersignatory_keys) {
244                 long ret = bindings.TxCreationKeys_from_channel_static_keys(InternalUtils.check_arr_len(per_commitment_point, 33), broadcaster_keys == null ? 0 : broadcaster_keys.ptr, countersignatory_keys == null ? 0 : countersignatory_keys.ptr);
245                 Reference.reachabilityFence(per_commitment_point);
246                 Reference.reachabilityFence(broadcaster_keys);
247                 Reference.reachabilityFence(countersignatory_keys);
248                 if (ret >= 0 && ret <= 4096) { return null; }
249                 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
250                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
251                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(broadcaster_keys); };
252                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(countersignatory_keys); };
253                 return ret_hu_conv;
254         }
255
256 }