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 byte[] ret = bindings.TxCreationKeys_get_per_commitment_point(this.ptr);
38 * The broadcaster's per-commitment public key which was used to derive the other keys.
40 public void set_per_commitment_point(byte[] val) {
41 bindings.TxCreationKeys_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
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);
58 * The revocation key which is used to allow the broadcaster of the commitment
59 * transaction to provide their counterparty the ability to punish them if they broadcast
62 public void set_revocation_key(byte[] val) {
63 bindings.TxCreationKeys_set_revocation_key(this.ptr, InternalUtils.check_arr_len(val, 33));
69 * Broadcaster's HTLC Key
71 public byte[] get_broadcaster_htlc_key() {
72 byte[] ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr);
78 * Broadcaster's HTLC Key
80 public void set_broadcaster_htlc_key(byte[] val) {
81 bindings.TxCreationKeys_set_broadcaster_htlc_key(this.ptr, InternalUtils.check_arr_len(val, 33));
87 * Countersignatory's HTLC Key
89 public byte[] get_countersignatory_htlc_key() {
90 byte[] ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr);
96 * Countersignatory's HTLC Key
98 public void set_countersignatory_htlc_key(byte[] val) {
99 bindings.TxCreationKeys_set_countersignatory_htlc_key(this.ptr, InternalUtils.check_arr_len(val, 33));
105 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
107 public byte[] get_broadcaster_delayed_payment_key() {
108 byte[] ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr);
114 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
116 public void set_broadcaster_delayed_payment_key(byte[] val) {
117 bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this.ptr, InternalUtils.check_arr_len(val, 33));
123 * Constructs a new TxCreationKeys given each field
125 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) {
126 long ret = bindings.TxCreationKeys_new(InternalUtils.check_arr_len(per_commitment_point_arg, 33), InternalUtils.check_arr_len(revocation_key_arg, 33), InternalUtils.check_arr_len(broadcaster_htlc_key_arg, 33), InternalUtils.check_arr_len(countersignatory_htlc_key_arg, 33), InternalUtils.check_arr_len(broadcaster_delayed_payment_key_arg, 33));
127 GC.KeepAlive(per_commitment_point_arg);
128 GC.KeepAlive(revocation_key_arg);
129 GC.KeepAlive(broadcaster_htlc_key_arg);
130 GC.KeepAlive(countersignatory_htlc_key_arg);
131 GC.KeepAlive(broadcaster_delayed_payment_key_arg);
132 if (ret >= 0 && ret <= 4096) { return null; }
133 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
134 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
139 * Checks if two TxCreationKeyss contain equal inner contents.
140 * This ignores pointers and is_owned flags and looks at the values in fields.
141 * Two objects with NULL inner values will be considered "equal" here.
143 public bool eq(org.ldk.structs.TxCreationKeys b) {
144 bool ret = bindings.TxCreationKeys_eq(this.ptr, b == null ? 0 : b.ptr);
147 if (this != null) { this.ptrs_to.AddLast(b); };
151 public override bool Equals(object o) {
152 if (!(o is TxCreationKeys)) return false;
153 return this.eq((TxCreationKeys)o);
155 internal long clone_ptr() {
156 long ret = bindings.TxCreationKeys_clone_ptr(this.ptr);
162 * Creates a copy of the TxCreationKeys
164 public TxCreationKeys clone() {
165 long ret = bindings.TxCreationKeys_clone(this.ptr);
167 if (ret >= 0 && ret <= 4096) { return null; }
168 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
169 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
174 * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
176 public byte[] write() {
177 byte[] ret = bindings.TxCreationKeys_write(this.ptr);
183 * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
185 public static Result_TxCreationKeysDecodeErrorZ read(byte[] ser) {
186 long ret = bindings.TxCreationKeys_read(ser);
188 if (ret >= 0 && ret <= 4096) { return null; }
189 Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
194 * Create per-state keys from channel base points and the per-commitment point.
195 * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
197 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) {
198 long ret = bindings.TxCreationKeys_derive_new(InternalUtils.check_arr_len(per_commitment_point, 33), InternalUtils.check_arr_len(broadcaster_delayed_payment_base, 33), InternalUtils.check_arr_len(broadcaster_htlc_base, 33), InternalUtils.check_arr_len(countersignatory_revocation_base, 33), InternalUtils.check_arr_len(countersignatory_htlc_base, 33));
199 GC.KeepAlive(per_commitment_point);
200 GC.KeepAlive(broadcaster_delayed_payment_base);
201 GC.KeepAlive(broadcaster_htlc_base);
202 GC.KeepAlive(countersignatory_revocation_base);
203 GC.KeepAlive(countersignatory_htlc_base);
204 if (ret >= 0 && ret <= 4096) { return null; }
205 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
206 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
211 * Generate per-state keys from channel static keys.
212 * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
214 public static TxCreationKeys from_channel_static_keys(byte[] per_commitment_point, org.ldk.structs.ChannelPublicKeys broadcaster_keys, org.ldk.structs.ChannelPublicKeys countersignatory_keys) {
215 long ret = bindings.TxCreationKeys_from_channel_static_keys(InternalUtils.check_arr_len(per_commitment_point, 33), broadcaster_keys == null ? 0 : broadcaster_keys.ptr, countersignatory_keys == null ? 0 : countersignatory_keys.ptr);
216 GC.KeepAlive(per_commitment_point);
217 GC.KeepAlive(broadcaster_keys);
218 GC.KeepAlive(countersignatory_keys);
219 if (ret >= 0 && ret <= 4096) { return null; }
220 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
221 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
222 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(broadcaster_keys); };
223 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_keys); };