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 RevocationKey get_revocation_key() {
54 long ret = bindings.TxCreationKeys_get_revocation_key(this.ptr);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 org.ldk.structs.RevocationKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationKey(null, ret); }
58 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
63 * The revocation key which is used to allow the broadcaster of the commitment
64 * transaction to provide their counterparty the ability to punish them if they broadcast
67 public void set_revocation_key(org.ldk.structs.RevocationKey val) {
68 bindings.TxCreationKeys_set_revocation_key(this.ptr, val == null ? 0 : val.ptr);
71 if (this != null) { this.ptrs_to.AddLast(val); };
75 * Broadcaster's HTLC Key
77 public HtlcKey get_broadcaster_htlc_key() {
78 long ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 org.ldk.structs.HtlcKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcKey(null, ret); }
82 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87 * Broadcaster's HTLC Key
89 public void set_broadcaster_htlc_key(org.ldk.structs.HtlcKey val) {
90 bindings.TxCreationKeys_set_broadcaster_htlc_key(this.ptr, val == null ? 0 : val.ptr);
93 if (this != null) { this.ptrs_to.AddLast(val); };
97 * Countersignatory's HTLC Key
99 public HtlcKey get_countersignatory_htlc_key() {
100 long ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr);
102 if (ret >= 0 && ret <= 4096) { return null; }
103 org.ldk.structs.HtlcKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcKey(null, ret); }
104 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
109 * Countersignatory's HTLC Key
111 public void set_countersignatory_htlc_key(org.ldk.structs.HtlcKey val) {
112 bindings.TxCreationKeys_set_countersignatory_htlc_key(this.ptr, val == null ? 0 : val.ptr);
115 if (this != null) { this.ptrs_to.AddLast(val); };
119 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
121 public DelayedPaymentKey get_broadcaster_delayed_payment_key() {
122 long ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 org.ldk.structs.DelayedPaymentKey ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentKey(null, ret); }
126 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
131 * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
133 public void set_broadcaster_delayed_payment_key(org.ldk.structs.DelayedPaymentKey val) {
134 bindings.TxCreationKeys_set_broadcaster_delayed_payment_key(this.ptr, val == null ? 0 : val.ptr);
137 if (this != null) { this.ptrs_to.AddLast(val); };
141 * Constructs a new TxCreationKeys given each field
143 public static TxCreationKeys of(byte[] per_commitment_point_arg, org.ldk.structs.RevocationKey revocation_key_arg, org.ldk.structs.HtlcKey broadcaster_htlc_key_arg, org.ldk.structs.HtlcKey countersignatory_htlc_key_arg, org.ldk.structs.DelayedPaymentKey broadcaster_delayed_payment_key_arg) {
144 long ret = bindings.TxCreationKeys_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point_arg, 33)), revocation_key_arg == null ? 0 : revocation_key_arg.ptr, broadcaster_htlc_key_arg == null ? 0 : broadcaster_htlc_key_arg.ptr, countersignatory_htlc_key_arg == null ? 0 : countersignatory_htlc_key_arg.ptr, broadcaster_delayed_payment_key_arg == null ? 0 : broadcaster_delayed_payment_key_arg.ptr);
145 GC.KeepAlive(per_commitment_point_arg);
146 GC.KeepAlive(revocation_key_arg);
147 GC.KeepAlive(broadcaster_htlc_key_arg);
148 GC.KeepAlive(countersignatory_htlc_key_arg);
149 GC.KeepAlive(broadcaster_delayed_payment_key_arg);
150 if (ret >= 0 && ret <= 4096) { return null; }
151 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
152 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
153 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(revocation_key_arg); };
154 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(broadcaster_htlc_key_arg); };
155 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_htlc_key_arg); };
156 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(broadcaster_delayed_payment_key_arg); };
161 * Checks if two TxCreationKeyss contain equal inner contents.
162 * This ignores pointers and is_owned flags and looks at the values in fields.
163 * Two objects with NULL inner values will be considered "equal" here.
165 public bool eq(org.ldk.structs.TxCreationKeys b) {
166 bool ret = bindings.TxCreationKeys_eq(this.ptr, b == null ? 0 : b.ptr);
169 if (this != null) { this.ptrs_to.AddLast(b); };
173 public override bool Equals(object o) {
174 if (!(o is TxCreationKeys)) return false;
175 return this.eq((TxCreationKeys)o);
177 internal long clone_ptr() {
178 long ret = bindings.TxCreationKeys_clone_ptr(this.ptr);
184 * Creates a copy of the TxCreationKeys
186 public TxCreationKeys clone() {
187 long ret = bindings.TxCreationKeys_clone(this.ptr);
189 if (ret >= 0 && ret <= 4096) { return null; }
190 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
191 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
196 * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
198 public byte[] write() {
199 long ret = bindings.TxCreationKeys_write(this.ptr);
201 if (ret >= 0 && ret <= 4096) { return null; }
202 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
207 * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
209 public static Result_TxCreationKeysDecodeErrorZ read(byte[] ser) {
210 long ret = bindings.TxCreationKeys_read(InternalUtils.encodeUint8Array(ser));
212 if (ret >= 0 && ret <= 4096) { return null; }
213 Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
218 * Create per-state keys from channel base points and the per-commitment point.
219 * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
221 public static TxCreationKeys derive_new(byte[] per_commitment_point, org.ldk.structs.DelayedPaymentBasepoint broadcaster_delayed_payment_base, org.ldk.structs.HtlcBasepoint broadcaster_htlc_base, org.ldk.structs.RevocationBasepoint countersignatory_revocation_base, org.ldk.structs.HtlcBasepoint countersignatory_htlc_base) {
222 long ret = bindings.TxCreationKeys_derive_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(per_commitment_point, 33)), broadcaster_delayed_payment_base == null ? 0 : broadcaster_delayed_payment_base.ptr, broadcaster_htlc_base == null ? 0 : broadcaster_htlc_base.ptr, countersignatory_revocation_base == null ? 0 : countersignatory_revocation_base.ptr, countersignatory_htlc_base == null ? 0 : countersignatory_htlc_base.ptr);
223 GC.KeepAlive(per_commitment_point);
224 GC.KeepAlive(broadcaster_delayed_payment_base);
225 GC.KeepAlive(broadcaster_htlc_base);
226 GC.KeepAlive(countersignatory_revocation_base);
227 GC.KeepAlive(countersignatory_htlc_base);
228 if (ret >= 0 && ret <= 4096) { return null; }
229 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
230 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
231 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(broadcaster_delayed_payment_base); };
232 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(broadcaster_htlc_base); };
233 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_revocation_base); };
234 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_htlc_base); };
239 * Generate per-state keys from channel static keys.
240 * Key set is asymmetric and can't be used as part of counter-signatory set of transactions.
242 public static TxCreationKeys from_channel_static_keys(byte[] per_commitment_point, org.ldk.structs.ChannelPublicKeys broadcaster_keys, org.ldk.structs.ChannelPublicKeys countersignatory_keys) {
243 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);
244 GC.KeepAlive(per_commitment_point);
245 GC.KeepAlive(broadcaster_keys);
246 GC.KeepAlive(countersignatory_keys);
247 if (ret >= 0 && ret <= 4096) { return null; }
248 org.ldk.structs.TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxCreationKeys(null, ret); }
249 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
250 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(broadcaster_keys); };
251 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(countersignatory_keys); };