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 RevocationBasepoint get_revocation_basepoint() {
50 long ret = bindings.ChannelPublicKeys_get_revocation_basepoint(this.ptr);
51 Reference.reachabilityFence(this);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.RevocationBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationBasepoint(null, ret); }
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
59 * The base point which is used (with derive_public_revocation_key) to derive per-commitment
60 * revocation keys. This is combined with the per-commitment-secret generated by the
61 * counterparty to create a secret which the counterparty can reveal to revoke previous
64 public void set_revocation_basepoint(org.ldk.structs.RevocationBasepoint val) {
65 bindings.ChannelPublicKeys_set_revocation_basepoint(this.ptr, val == null ? 0 : val.ptr);
66 Reference.reachabilityFence(this);
67 Reference.reachabilityFence(val);
68 if (this != null) { this.ptrs_to.add(val); };
72 * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
73 * spendable primary channel balance on the broadcaster's commitment transaction. This key is
74 * static across every commitment transaction.
76 public byte[] get_payment_point() {
77 byte[] ret = bindings.ChannelPublicKeys_get_payment_point(this.ptr);
78 Reference.reachabilityFence(this);
83 * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
84 * spendable primary channel balance on the broadcaster's commitment transaction. This key is
85 * static across every commitment transaction.
87 public void set_payment_point(byte[] val) {
88 bindings.ChannelPublicKeys_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
89 Reference.reachabilityFence(this);
90 Reference.reachabilityFence(val);
94 * The base point which is used (with derive_public_key) to derive a per-commitment payment
95 * public key which receives non-HTLC-encumbered funds which are only available for spending
96 * after some delay (or can be claimed via the revocation path).
98 public DelayedPaymentBasepoint get_delayed_payment_basepoint() {
99 long ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this.ptr);
100 Reference.reachabilityFence(this);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 org.ldk.structs.DelayedPaymentBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentBasepoint(null, ret); }
103 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
108 * The base point which is used (with derive_public_key) to derive a per-commitment payment
109 * public key which receives non-HTLC-encumbered funds which are only available for spending
110 * after some delay (or can be claimed via the revocation path).
112 public void set_delayed_payment_basepoint(org.ldk.structs.DelayedPaymentBasepoint val) {
113 bindings.ChannelPublicKeys_set_delayed_payment_basepoint(this.ptr, val == null ? 0 : val.ptr);
114 Reference.reachabilityFence(this);
115 Reference.reachabilityFence(val);
116 if (this != null) { this.ptrs_to.add(val); };
120 * The base point which is used (with derive_public_key) to derive a per-commitment public key
121 * which is used to encumber HTLC-in-flight outputs.
123 public HtlcBasepoint get_htlc_basepoint() {
124 long ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this.ptr);
125 Reference.reachabilityFence(this);
126 if (ret >= 0 && ret <= 4096) { return null; }
127 org.ldk.structs.HtlcBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcBasepoint(null, ret); }
128 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
133 * The base point which is used (with derive_public_key) to derive a per-commitment public key
134 * which is used to encumber HTLC-in-flight outputs.
136 public void set_htlc_basepoint(org.ldk.structs.HtlcBasepoint val) {
137 bindings.ChannelPublicKeys_set_htlc_basepoint(this.ptr, val == null ? 0 : val.ptr);
138 Reference.reachabilityFence(this);
139 Reference.reachabilityFence(val);
140 if (this != null) { this.ptrs_to.add(val); };
144 * Constructs a new ChannelPublicKeys given each field
146 public static ChannelPublicKeys of(byte[] funding_pubkey_arg, org.ldk.structs.RevocationBasepoint revocation_basepoint_arg, byte[] payment_point_arg, org.ldk.structs.DelayedPaymentBasepoint delayed_payment_basepoint_arg, org.ldk.structs.HtlcBasepoint htlc_basepoint_arg) {
147 long ret = bindings.ChannelPublicKeys_new(InternalUtils.check_arr_len(funding_pubkey_arg, 33), revocation_basepoint_arg == null ? 0 : revocation_basepoint_arg.ptr, InternalUtils.check_arr_len(payment_point_arg, 33), delayed_payment_basepoint_arg == null ? 0 : delayed_payment_basepoint_arg.ptr, htlc_basepoint_arg == null ? 0 : htlc_basepoint_arg.ptr);
148 Reference.reachabilityFence(funding_pubkey_arg);
149 Reference.reachabilityFence(revocation_basepoint_arg);
150 Reference.reachabilityFence(payment_point_arg);
151 Reference.reachabilityFence(delayed_payment_basepoint_arg);
152 Reference.reachabilityFence(htlc_basepoint_arg);
153 if (ret >= 0 && ret <= 4096) { return null; }
154 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(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_basepoint_arg); };
157 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(delayed_payment_basepoint_arg); };
158 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(htlc_basepoint_arg); };
163 long ret = bindings.ChannelPublicKeys_clone_ptr(this.ptr);
164 Reference.reachabilityFence(this);
169 * Creates a copy of the ChannelPublicKeys
171 public ChannelPublicKeys clone() {
172 long ret = bindings.ChannelPublicKeys_clone(this.ptr);
173 Reference.reachabilityFence(this);
174 if (ret >= 0 && ret <= 4096) { return null; }
175 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
176 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
181 * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys.
184 long ret = bindings.ChannelPublicKeys_hash(this.ptr);
185 Reference.reachabilityFence(this);
189 @Override public int hashCode() {
190 return (int)this.hash();
193 * Checks if two ChannelPublicKeyss contain equal inner contents.
194 * This ignores pointers and is_owned flags and looks at the values in fields.
195 * Two objects with NULL inner values will be considered "equal" here.
197 public boolean eq(org.ldk.structs.ChannelPublicKeys b) {
198 boolean ret = bindings.ChannelPublicKeys_eq(this.ptr, b == null ? 0 : b.ptr);
199 Reference.reachabilityFence(this);
200 Reference.reachabilityFence(b);
201 if (this != null) { this.ptrs_to.add(b); };
205 @Override public boolean equals(Object o) {
206 if (!(o instanceof ChannelPublicKeys)) return false;
207 return this.eq((ChannelPublicKeys)o);
210 * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read
212 public byte[] write() {
213 byte[] ret = bindings.ChannelPublicKeys_write(this.ptr);
214 Reference.reachabilityFence(this);
219 * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write
221 public static Result_ChannelPublicKeysDecodeErrorZ read(byte[] ser) {
222 long ret = bindings.ChannelPublicKeys_read(ser);
223 Reference.reachabilityFence(ser);
224 if (ret >= 0 && ret <= 4096) { return null; }
225 Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);