6 namespace org { namespace ldk { namespace structs {
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 public class TxCreationKeys : CommonBase {
23 internal TxCreationKeys(object _dummy, long ptr) : base(ptr) { }
25 if (ptr != 0) { bindings.TxCreationKeys_free(ptr); }
29 * The broadcaster's per-commitment public key which was used to derive the other keys.
31 public byte[] get_per_commitment_point() {
32 long ret = bindings.TxCreationKeys_get_per_commitment_point(this.ptr);
34 if (ret >= 0 && ret <= 4096) { return null; }
35 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
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, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
49 * The revocation key which is used to allow the broadcaster of the commitment
50 * transaction to provide their counterparty the ability to punish them if they broadcast
53 public byte[] get_revocation_key() {
54 long ret = bindings.TxCreationKeys_get_revocation_key(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
62 * The revocation key which is used to allow the broadcaster of the commitment
63 * transaction to provide their counterparty the ability to punish them if they broadcast
66 public void set_revocation_key(byte[] val) {
67 bindings.TxCreationKeys_set_revocation_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
73 * Broadcaster's HTLC Key
75 public byte[] get_broadcaster_htlc_key() {
76 long ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr);
78 if (ret >= 0 && ret <= 4096) { return null; }
79 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
84 * Broadcaster's HTLC Key
86 public void set_broadcaster_htlc_key(byte[] val) {
87 bindings.TxCreationKeys_set_broadcaster_htlc_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
93 * Countersignatory's HTLC Key
95 public byte[] get_countersignatory_htlc_key() {
96 long ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr);
98 if (ret >= 0 && ret <= 4096) { return null; }
99 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
104 * Countersignatory's HTLC Key
106 public void set_countersignatory_htlc_key(byte[] val) {
107 bindings.TxCreationKeys_set_countersignatory_htlc_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
113 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
115 public byte[] get_broadcaster_delayed_payment_key() {
116 long ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr);
118 if (ret >= 0 && ret <= 4096) { return null; }
119 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
124 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
126 public void set_broadcaster_delayed_payment_key(byte[] val) {
127 bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
133 * Constructs a new TxCreationKeys given each field
135 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) {
136 long ret = bindings.TxCreationKeys_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(revocation_key_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(broadcaster_htlc_key_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(countersignatory_htlc_key_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(broadcaster_delayed_payment_key_arg, 33)));
137 GC.KeepAlive(per_commitment_point_arg);
138 GC.KeepAlive(revocation_key_arg);
139 GC.KeepAlive(broadcaster_htlc_key_arg);
140 GC.KeepAlive(countersignatory_htlc_key_arg);
141 GC.KeepAlive(broadcaster_delayed_payment_key_arg);
142 if (ret >= 0 && ret <= 4096) { return null; }
143 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
144 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
149 * Checks if two TxCreationKeyss contain equal inner contents.
150 * This ignores pointers and is_owned flags and looks at the values in fields.
151 * Two objects with NULL inner values will be considered "equal" here.
153 public bool eq(org.ldk.structs.TxCreationKeys b) {
154 bool ret = bindings.TxCreationKeys_eq(this.ptr, b == null ? 0 : b.ptr);
157 if (this != null) { this.ptrs_to.AddLast(b); };
161 public override bool Equals(object o) {
162 if (!(o is TxCreationKeys)) return false;
163 return this.eq((TxCreationKeys)o);
165 internal long clone_ptr() {
166 long ret = bindings.TxCreationKeys_clone_ptr(this.ptr);
172 * Creates a copy of the TxCreationKeys
174 public TxCreationKeys clone() {
175 long ret = bindings.TxCreationKeys_clone(this.ptr);
177 if (ret >= 0 && ret <= 4096) { return null; }
178 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
179 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
184 * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
186 public byte[] write() {
187 long ret = bindings.TxCreationKeys_write(this.ptr);
189 if (ret >= 0 && ret <= 4096) { return null; }
190 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
195 * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
197 public static Result_TxCreationKeysDecodeErrorZ read(byte[] ser) {
198 long ret = bindings.TxCreationKeys_read(InternalUtils.encodeUint8Array(ser));
200 if (ret >= 0 && ret <= 4096) { return null; }
201 Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
206 * Create per-state keys from channel base points and the per-commitment point.
207 * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
209 public static TxCreationKeys derive_new(byte[] per_commitment_point, byte[] broadcaster_delayed_payment_base, byte[] broadcaster_htlc_base, byte[] countersignatory_revocation_base, byte[] countersignatory_htlc_base) {
210 long ret = bindings.TxCreationKeys_derive_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(broadcaster_delayed_payment_base, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(broadcaster_htlc_base, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(countersignatory_revocation_base, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(countersignatory_htlc_base, 33)));
211 GC.KeepAlive(per_commitment_point);
212 GC.KeepAlive(broadcaster_delayed_payment_base);
213 GC.KeepAlive(broadcaster_htlc_base);
214 GC.KeepAlive(countersignatory_revocation_base);
215 GC.KeepAlive(countersignatory_htlc_base);
216 if (ret >= 0 && ret <= 4096) { return null; }
217 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
218 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
223 * Generate per-state keys from channel static keys.
224 * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
226 public static TxCreationKeys from_channel_static_keys(byte[] per_commitment_point, org.ldk.structs.ChannelPublicKeys broadcaster_keys, org.ldk.structs.ChannelPublicKeys countersignatory_keys) {
227 long ret = bindings.TxCreationKeys_from_channel_static_keys(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point, 33)), broadcaster_keys == null ? 0 : broadcaster_keys.ptr, countersignatory_keys == null ? 0 : countersignatory_keys.ptr);
228 GC.KeepAlive(per_commitment_point);
229 GC.KeepAlive(broadcaster_keys);
230 GC.KeepAlive(countersignatory_keys);
231 if (ret >= 0 && ret <= 4096) { return null; }
232 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
233 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
234 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(broadcaster_keys); };
235 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_keys); };