Update auto-generated bindings
[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 javax.annotation.Nullable;
8
9
10 /**
11  * The set of public keys which are used in the creation of one commitment transaction.
12  * These are derived from the channel base keys and per-commitment data.
13  * 
14  * A broadcaster key is provided from potential broadcaster of the computed transaction.
15  * A countersignatory key is coming from a protocol participant unable to broadcast the
16  * transaction.
17  * 
18  * These keys are assumed to be good, either because the code derived them from
19  * channel basepoints via the new function, or they were obtained via
20  * CommitmentTransaction.trust().keys() because we trusted the source of the
21  * pre-calculated keys.
22  */
23 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
24 public class TxCreationKeys extends CommonBase {
25         TxCreationKeys(Object _dummy, long ptr) { super(ptr); }
26         @Override @SuppressWarnings("deprecation")
27         protected void finalize() throws Throwable {
28                 super.finalize();
29                 if (ptr != 0) { bindings.TxCreationKeys_free(ptr); }
30         }
31
32         /**
33          * The broadcaster's per-commitment public key which was used to derive the other keys.
34          */
35         public byte[] get_per_commitment_point() {
36                 byte[] ret = bindings.TxCreationKeys_get_per_commitment_point(this.ptr);
37                 return ret;
38         }
39
40         /**
41          * The broadcaster's per-commitment public key which was used to derive the other keys.
42          */
43         public void set_per_commitment_point(byte[] val) {
44                 bindings.TxCreationKeys_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
45         }
46
47         /**
48          * The revocation key which is used to allow the broadcaster of the commitment
49          * transaction to provide their counterparty the ability to punish them if they broadcast
50          * an old state.
51          */
52         public byte[] get_revocation_key() {
53                 byte[] ret = bindings.TxCreationKeys_get_revocation_key(this.ptr);
54                 return ret;
55         }
56
57         /**
58          * The revocation key which is used to allow the broadcaster of the commitment
59          * transaction to provide their counterparty the ability to punish them if they broadcast
60          * an old state.
61          */
62         public void set_revocation_key(byte[] val) {
63                 bindings.TxCreationKeys_set_revocation_key(this.ptr, InternalUtils.check_arr_len(val, 33));
64         }
65
66         /**
67          * Broadcaster's HTLC Key
68          */
69         public byte[] get_broadcaster_htlc_key() {
70                 byte[] ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr);
71                 return ret;
72         }
73
74         /**
75          * Broadcaster's HTLC Key
76          */
77         public void set_broadcaster_htlc_key(byte[] val) {
78                 bindings.TxCreationKeys_set_broadcaster_htlc_key(this.ptr, InternalUtils.check_arr_len(val, 33));
79         }
80
81         /**
82          * Countersignatory's HTLC Key
83          */
84         public byte[] get_countersignatory_htlc_key() {
85                 byte[] ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr);
86                 return ret;
87         }
88
89         /**
90          * Countersignatory's HTLC Key
91          */
92         public void set_countersignatory_htlc_key(byte[] val) {
93                 bindings.TxCreationKeys_set_countersignatory_htlc_key(this.ptr, InternalUtils.check_arr_len(val, 33));
94         }
95
96         /**
97          * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
98          */
99         public byte[] get_broadcaster_delayed_payment_key() {
100                 byte[] ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr);
101                 return ret;
102         }
103
104         /**
105          * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
106          */
107         public void set_broadcaster_delayed_payment_key(byte[] val) {
108                 bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this.ptr, InternalUtils.check_arr_len(val, 33));
109         }
110
111         /**
112          * Constructs a new TxCreationKeys given each field
113          */
114         public static TxCreationKeys of(byte[] per_commitment_point_arg, byte[] revocation_key_arg, byte[] broadcaster_htlc_key_arg, byte[] countersignatory_htlc_key_arg, byte[] broadcaster_delayed_payment_key_arg) {
115                 long ret = bindings.TxCreationKeys_new(InternalUtils.check_arr_len(per_commitment_point_arg, 33), InternalUtils.check_arr_len(revocation_key_arg, 33), InternalUtils.check_arr_len(broadcaster_htlc_key_arg, 33), InternalUtils.check_arr_len(countersignatory_htlc_key_arg, 33), InternalUtils.check_arr_len(broadcaster_delayed_payment_key_arg, 33));
116                 if (ret >= 0 && ret <= 4096) { return null; }
117                 TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TxCreationKeys(null, ret); }
118                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
119                 return ret_hu_conv;
120         }
121
122         long clone_ptr() {
123                 long ret = bindings.TxCreationKeys_clone_ptr(this.ptr);
124                 return ret;
125         }
126
127         /**
128          * Creates a copy of the TxCreationKeys
129          */
130         public TxCreationKeys clone() {
131                 long ret = bindings.TxCreationKeys_clone(this.ptr);
132                 if (ret >= 0 && ret <= 4096) { return null; }
133                 TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TxCreationKeys(null, ret); }
134                 ret_hu_conv.ptrs_to.add(this);
135                 return ret_hu_conv;
136         }
137
138         /**
139          * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
140          */
141         public byte[] write() {
142                 byte[] ret = bindings.TxCreationKeys_write(this.ptr);
143                 return ret;
144         }
145
146         /**
147          * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
148          */
149         public static Result_TxCreationKeysDecodeErrorZ read(byte[] ser) {
150                 long ret = bindings.TxCreationKeys_read(ser);
151                 if (ret >= 0 && ret <= 4096) { return null; }
152                 Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
153                 return ret_hu_conv;
154         }
155
156         /**
157          * Create per-state keys from channel base points and the per-commitment point.
158          * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
159          */
160         public static Result_TxCreationKeysErrorZ derive_new(byte[] per_commitment_point, byte[] broadcaster_delayed_payment_base, byte[] broadcaster_htlc_base, byte[] countersignatory_revocation_base, byte[] countersignatory_htlc_base) {
161                 long ret = bindings.TxCreationKeys_derive_new(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(broadcaster_delayed_payment_base, 33), InternalUtils.check_arr_len(broadcaster_htlc_base, 33), InternalUtils.check_arr_len(countersignatory_revocation_base, 33), InternalUtils.check_arr_len(countersignatory_htlc_base, 33));
162                 if (ret >= 0 && ret <= 4096) { return null; }
163                 Result_TxCreationKeysErrorZ ret_hu_conv = Result_TxCreationKeysErrorZ.constr_from_ptr(ret);
164                 return ret_hu_conv;
165         }
166
167         /**
168          * Generate per-state keys from channel static keys.
169          * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
170          */
171         public static Result_TxCreationKeysErrorZ from_channel_static_keys(byte[] per_commitment_point, ChannelPublicKeys broadcaster_keys, ChannelPublicKeys countersignatory_keys) {
172                 long ret = bindings.TxCreationKeys_from_channel_static_keys(InternalUtils.check_arr_len(per_commitment_point, 33), broadcaster_keys == null ? 0 : broadcaster_keys.ptr & ~1, countersignatory_keys == null ? 0 : countersignatory_keys.ptr & ~1);
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 Result_TxCreationKeysErrorZ ret_hu_conv = Result_TxCreationKeysErrorZ.constr_from_ptr(ret);
175                 ret_hu_conv.ptrs_to.add(broadcaster_keys);
176                 ret_hu_conv.ptrs_to.add(countersignatory_keys);
177                 return ret_hu_conv;
178         }
179
180 }