347c8cf13781dfd9f6bdd6d3cdbad146003b7138
[ldk-java] / c_sharp / src / org / ldk / structs / ChannelPublicKeys.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  * One counterparty's public keys which do not change over the life of a channel.
11  */
12 public class ChannelPublicKeys : CommonBase {
13         internal ChannelPublicKeys(object _dummy, long ptr) : base(ptr) { }
14         ~ChannelPublicKeys() {
15                 if (ptr != 0) { bindings.ChannelPublicKeys_free(ptr); }
16         }
17
18         /**
19          * The public key which is used to sign all commitment transactions, as it appears in the
20          * on-chain channel lock-in 2-of-2 multisig output.
21          */
22         public byte[] get_funding_pubkey() {
23                 long ret = bindings.ChannelPublicKeys_get_funding_pubkey(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
27                 return ret_conv;
28         }
29
30         /**
31          * The public key which is used to sign all commitment transactions, as it appears in the
32          * on-chain channel lock-in 2-of-2 multisig output.
33          */
34         public void set_funding_pubkey(byte[] val) {
35                 bindings.ChannelPublicKeys_set_funding_pubkey(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * The base point which is used (with derive_public_revocation_key) to derive per-commitment
42          * revocation keys. This is combined with the per-commitment-secret generated by the
43          * counterparty to create a secret which the counterparty can reveal to revoke previous
44          * states.
45          */
46         public byte[] get_revocation_basepoint() {
47                 long ret = bindings.ChannelPublicKeys_get_revocation_basepoint(this.ptr);
48                 GC.KeepAlive(this);
49                 if (ret >= 0 && ret <= 4096) { return null; }
50                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
51                 return ret_conv;
52         }
53
54         /**
55          * The base point which is used (with derive_public_revocation_key) to derive per-commitment
56          * revocation keys. This is combined with the per-commitment-secret generated by the
57          * counterparty to create a secret which the counterparty can reveal to revoke previous
58          * states.
59          */
60         public void set_revocation_basepoint(byte[] val) {
61                 bindings.ChannelPublicKeys_set_revocation_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
62                 GC.KeepAlive(this);
63                 GC.KeepAlive(val);
64         }
65
66         /**
67          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
68          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
69          * static across every commitment transaction.
70          */
71         public byte[] get_payment_point() {
72                 long ret = bindings.ChannelPublicKeys_get_payment_point(this.ptr);
73                 GC.KeepAlive(this);
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
76                 return ret_conv;
77         }
78
79         /**
80          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
81          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
82          * static across every commitment transaction.
83          */
84         public void set_payment_point(byte[] val) {
85                 bindings.ChannelPublicKeys_set_payment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
86                 GC.KeepAlive(this);
87                 GC.KeepAlive(val);
88         }
89
90         /**
91          * The base point which is used (with derive_public_key) to derive a per-commitment payment
92          * public key which receives non-HTLC-encumbered funds which are only available for spending
93          * after some delay (or can be claimed via the revocation path).
94          */
95         public byte[] get_delayed_payment_basepoint() {
96                 long ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this.ptr);
97                 GC.KeepAlive(this);
98                 if (ret >= 0 && ret <= 4096) { return null; }
99                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
100                 return ret_conv;
101         }
102
103         /**
104          * The base point which is used (with derive_public_key) to derive a per-commitment payment
105          * public key which receives non-HTLC-encumbered funds which are only available for spending
106          * after some delay (or can be claimed via the revocation path).
107          */
108         public void set_delayed_payment_basepoint(byte[] val) {
109                 bindings.ChannelPublicKeys_set_delayed_payment_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
110                 GC.KeepAlive(this);
111                 GC.KeepAlive(val);
112         }
113
114         /**
115          * The base point which is used (with derive_public_key) to derive a per-commitment public key
116          * which is used to encumber HTLC-in-flight outputs.
117          */
118         public byte[] get_htlc_basepoint() {
119                 long ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this.ptr);
120                 GC.KeepAlive(this);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
123                 return ret_conv;
124         }
125
126         /**
127          * The base point which is used (with derive_public_key) to derive a per-commitment public key
128          * which is used to encumber HTLC-in-flight outputs.
129          */
130         public void set_htlc_basepoint(byte[] val) {
131                 bindings.ChannelPublicKeys_set_htlc_basepoint(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
132                 GC.KeepAlive(this);
133                 GC.KeepAlive(val);
134         }
135
136         /**
137          * Constructs a new ChannelPublicKeys given each field
138          */
139         public static ChannelPublicKeys of(byte[] funding_pubkey_arg, byte[] revocation_basepoint_arg, byte[] payment_point_arg, byte[] delayed_payment_basepoint_arg, byte[] htlc_basepoint_arg) {
140                 long ret = bindings.ChannelPublicKeys_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_pubkey_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(revocation_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_point_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_basepoint_arg, 33)));
141                 GC.KeepAlive(funding_pubkey_arg);
142                 GC.KeepAlive(revocation_basepoint_arg);
143                 GC.KeepAlive(payment_point_arg);
144                 GC.KeepAlive(delayed_payment_basepoint_arg);
145                 GC.KeepAlive(htlc_basepoint_arg);
146                 if (ret >= 0 && ret <= 4096) { return null; }
147                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
148                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
149                 return ret_hu_conv;
150         }
151
152         internal long clone_ptr() {
153                 long ret = bindings.ChannelPublicKeys_clone_ptr(this.ptr);
154                 GC.KeepAlive(this);
155                 return ret;
156         }
157
158         /**
159          * Creates a copy of the ChannelPublicKeys
160          */
161         public ChannelPublicKeys clone() {
162                 long ret = bindings.ChannelPublicKeys_clone(this.ptr);
163                 GC.KeepAlive(this);
164                 if (ret >= 0 && ret <= 4096) { return null; }
165                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
166                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
167                 return ret_hu_conv;
168         }
169
170         /**
171          * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys.
172          */
173         public long hash() {
174                 long ret = bindings.ChannelPublicKeys_hash(this.ptr);
175                 GC.KeepAlive(this);
176                 return ret;
177         }
178
179         public override int GetHashCode() {
180                 return (int)this.hash();
181         }
182         /**
183          * Checks if two ChannelPublicKeyss contain equal inner contents.
184          * This ignores pointers and is_owned flags and looks at the values in fields.
185          * Two objects with NULL inner values will be considered "equal" here.
186          */
187         public bool eq(org.ldk.structs.ChannelPublicKeys b) {
188                 bool ret = bindings.ChannelPublicKeys_eq(this.ptr, b == null ? 0 : b.ptr);
189                 GC.KeepAlive(this);
190                 GC.KeepAlive(b);
191                 if (this != null) { this.ptrs_to.AddLast(b); };
192                 return ret;
193         }
194
195         public override bool Equals(object o) {
196                 if (!(o is ChannelPublicKeys)) return false;
197                 return this.eq((ChannelPublicKeys)o);
198         }
199         /**
200          * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read
201          */
202         public byte[] write() {
203                 long ret = bindings.ChannelPublicKeys_write(this.ptr);
204                 GC.KeepAlive(this);
205                 if (ret >= 0 && ret <= 4096) { return null; }
206                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
207                 return ret_conv;
208         }
209
210         /**
211          * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write
212          */
213         public static Result_ChannelPublicKeysDecodeErrorZ read(byte[] ser) {
214                 long ret = bindings.ChannelPublicKeys_read(InternalUtils.encodeUint8Array(ser));
215                 GC.KeepAlive(ser);
216                 if (ret >= 0 && ret <= 4096) { return null; }
217                 Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
218                 return ret_hu_conv;
219         }
220
221 }
222 } } }