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