[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / TxCreationKeys.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
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.
12  * 
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
15  * transaction.
16  * 
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.
21  */
22 public class TxCreationKeys : CommonBase {
23         internal TxCreationKeys(object _dummy, long ptr) : base(ptr) { }
24         ~TxCreationKeys() {
25                 if (ptr != 0) { bindings.TxCreationKeys_free(ptr); }
26         }
27
28         /**
29          * The broadcaster's per-commitment public key which was used to derive the other keys.
30          */
31         public byte[] get_per_commitment_point() {
32                 long ret = bindings.TxCreationKeys_get_per_commitment_point(this.ptr);
33                 GC.KeepAlive(this);
34                 if (ret >= 0 && ret <= 4096) { return null; }
35                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
36                 return ret_conv;
37         }
38
39         /**
40          * The broadcaster's per-commitment public key which was used to derive the other keys.
41          */
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)));
44                 GC.KeepAlive(this);
45                 GC.KeepAlive(val);
46         }
47
48         /**
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
51          * an old state.
52          */
53         public RevocationKey get_revocation_key() {
54                 long ret = bindings.TxCreationKeys_get_revocation_key(this.ptr);
55                 GC.KeepAlive(this);
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); };
59                 return ret_hu_conv;
60         }
61
62         /**
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
65          * an old state.
66          */
67         public void set_revocation_key(org.ldk.structs.RevocationKey val) {
68                 bindings.TxCreationKeys_set_revocation_key(this.ptr, val == null ? 0 : val.ptr);
69                 GC.KeepAlive(this);
70                 GC.KeepAlive(val);
71                 if (this != null) { this.ptrs_to.AddLast(val); };
72         }
73
74         /**
75          * Broadcaster's HTLC Key
76          */
77         public HtlcKey get_broadcaster_htlc_key() {
78                 long ret = bindings.TxCreationKeys_get_broadcaster_htlc_key(this.ptr);
79                 GC.KeepAlive(this);
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); };
83                 return ret_hu_conv;
84         }
85
86         /**
87          * Broadcaster's HTLC Key
88          */
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);
91                 GC.KeepAlive(this);
92                 GC.KeepAlive(val);
93                 if (this != null) { this.ptrs_to.AddLast(val); };
94         }
95
96         /**
97          * Countersignatory's HTLC Key
98          */
99         public HtlcKey get_countersignatory_htlc_key() {
100                 long ret = bindings.TxCreationKeys_get_countersignatory_htlc_key(this.ptr);
101                 GC.KeepAlive(this);
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); };
105                 return ret_hu_conv;
106         }
107
108         /**
109          * Countersignatory's HTLC Key
110          */
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);
113                 GC.KeepAlive(this);
114                 GC.KeepAlive(val);
115                 if (this != null) { this.ptrs_to.AddLast(val); };
116         }
117
118         /**
119          * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
120          */
121         public DelayedPaymentKey get_broadcaster_delayed_payment_key() {
122                 long ret = bindings.TxCreationKeys_get_broadcaster_delayed_payment_key(this.ptr);
123                 GC.KeepAlive(this);
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); };
127                 return ret_hu_conv;
128         }
129
130         /**
131          * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay)
132          */
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);
135                 GC.KeepAlive(this);
136                 GC.KeepAlive(val);
137                 if (this != null) { this.ptrs_to.AddLast(val); };
138         }
139
140         /**
141          * Constructs a new TxCreationKeys given each field
142          */
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); };
157                 return ret_hu_conv;
158         }
159
160         /**
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.
164          */
165         public bool eq(org.ldk.structs.TxCreationKeys b) {
166                 bool ret = bindings.TxCreationKeys_eq(this.ptr, b == null ? 0 : b.ptr);
167                 GC.KeepAlive(this);
168                 GC.KeepAlive(b);
169                 if (this != null) { this.ptrs_to.AddLast(b); };
170                 return ret;
171         }
172
173         public override bool Equals(object o) {
174                 if (!(o is TxCreationKeys)) return false;
175                 return this.eq((TxCreationKeys)o);
176         }
177         internal long clone_ptr() {
178                 long ret = bindings.TxCreationKeys_clone_ptr(this.ptr);
179                 GC.KeepAlive(this);
180                 return ret;
181         }
182
183         /**
184          * Creates a copy of the TxCreationKeys
185          */
186         public TxCreationKeys clone() {
187                 long ret = bindings.TxCreationKeys_clone(this.ptr);
188                 GC.KeepAlive(this);
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); };
192                 return ret_hu_conv;
193         }
194
195         /**
196          * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read
197          */
198         public byte[] write() {
199                 long ret = bindings.TxCreationKeys_write(this.ptr);
200                 GC.KeepAlive(this);
201                 if (ret >= 0 && ret <= 4096) { return null; }
202                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
203                 return ret_conv;
204         }
205
206         /**
207          * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write
208          */
209         public static Result_TxCreationKeysDecodeErrorZ read(byte[] ser) {
210                 long ret = bindings.TxCreationKeys_read(InternalUtils.encodeUint8Array(ser));
211                 GC.KeepAlive(ser);
212                 if (ret >= 0 && ret <= 4096) { return null; }
213                 Result_TxCreationKeysDecodeErrorZ ret_hu_conv = Result_TxCreationKeysDecodeErrorZ.constr_from_ptr(ret);
214                 return ret_hu_conv;
215         }
216
217         /**
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.
220          */
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); };
235                 return ret_hu_conv;
236         }
237
238         /**
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.
241          */
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); };
252                 return ret_hu_conv;
253         }
254
255 }
256 } } }