1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * One counterparty's public keys which do not change over the life of a channel.
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 {
20 if (ptr != 0) { bindings.ChannelPublicKeys_free(ptr); }
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.
27 public byte[] get_funding_pubkey() {
28 byte[] ret = bindings.ChannelPublicKeys_get_funding_pubkey(this.ptr);
29 Reference.reachabilityFence(this);
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.
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);
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
49 public byte[] get_revocation_basepoint() {
50 byte[] ret = bindings.ChannelPublicKeys_get_revocation_basepoint(this.ptr);
51 Reference.reachabilityFence(this);
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
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);
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.
72 public byte[] get_payment_point() {
73 byte[] ret = bindings.ChannelPublicKeys_get_payment_point(this.ptr);
74 Reference.reachabilityFence(this);
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.
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);
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).
94 public byte[] get_delayed_payment_basepoint() {
95 byte[] ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this.ptr);
96 Reference.reachabilityFence(this);
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).
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);
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.
115 public byte[] get_htlc_basepoint() {
116 byte[] ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this.ptr);
117 Reference.reachabilityFence(this);
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.
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);
132 * Constructs a new ChannelPublicKeys given each field
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); };
148 long ret = bindings.ChannelPublicKeys_clone_ptr(this.ptr);
149 Reference.reachabilityFence(this);
154 * Creates a copy of the ChannelPublicKeys
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); };
166 * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read
168 public byte[] write() {
169 byte[] ret = bindings.ChannelPublicKeys_write(this.ptr);
170 Reference.reachabilityFence(this);
175 * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write
177 public static Result_ChannelPublicKeysDecodeErrorZ read(byte[] ser) {
178 long ret = bindings.ChannelPublicKeys_read(ser);
179 Reference.reachabilityFence(ser);
180 if (ret >= 0 && ret <= 4096) { return null; }
181 Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);