1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
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.
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
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.
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 {
28 if (ptr != 0) { bindings.TxCreationKeys_free(ptr); }
32 * The broadcaster's per-commitment public key which was used to derive the other keys.
34 public byte[] get_per_commitment_point() {
35 byte[] ret = bindings.TxCreationKeys_get_per_commitment_point(this.ptr);
40 * The broadcaster's per-commitment public key which was used to derive the other keys.
42 public void set_per_commitment_point(byte[] val) {
43 bindings.TxCreationKeys_set_per_commitment_point(this.ptr, val);
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
51 public byte[] get_revocation_key() {
52 byte[] ret = bindings.TxCreationKeys_get_revocation_key(this.ptr);
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
61 public void set_revocation_key(byte[] val) {
62 bindings.TxCreationKeys_set_revocation_key(this.ptr, val);
66 * Broadcaster's HTLC Key
68 public byte[] get_broadcaster_htlc_key() {
69 byte[] ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr);
74 * Broadcaster's HTLC Key
76 public void set_broadcaster_htlc_key(byte[] val) {
77 bindings.TxCreationKeys_set_broadcaster_htlc_key(this.ptr, val);
81 * Countersignatory's HTLC Key
83 public byte[] get_countersignatory_htlc_key() {
84 byte[] ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr);
89 * Countersignatory's HTLC Key
91 public void set_countersignatory_htlc_key(byte[] val) {
92 bindings.TxCreationKeys_set_countersignatory_htlc_key(this.ptr, val);
96 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
98 public byte[] get_broadcaster_delayed_payment_key() {
99 byte[] ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr);
104 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
106 public void set_broadcaster_delayed_payment_key(byte[] val) {
107 bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this.ptr, val);
111 * Constructs a new TxCreationKeys given each field
113 public static TxCreationKeys constructor_new(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);
121 * Creates a copy of the TxCreationKeys
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);
131 * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
133 public byte[] write() {
134 byte[] ret = bindings.TxCreationKeys_write(this.ptr);
139 * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
141 public static Result_TxCreationKeysDecodeErrorZ constructor_read(byte[] ser) {
142 long ret = bindings.TxCreationKeys_read(ser);
143 Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
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.
151 public static Result_TxCreationKeysErrorZ constructor_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);
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.
161 public static Result_TxCreationKeysErrorZ constructor_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);