]> git.bitcoin.ninja Git - ldk-java/blob - c_sharp/src/org/ldk/structs/ChannelPublicKeys.cs
Merge pull request #146 from TheBlueMatt/main
[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 RevocationBasepoint 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                 org.ldk.structs.RevocationBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.RevocationBasepoint(null, ret); }
51                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
52                 return ret_hu_conv;
53         }
54
55         /**
56          * The base point which is used (with derive_public_revocation_key) to derive per-commitment
57          * revocation keys. This is combined with the per-commitment-secret generated by the
58          * counterparty to create a secret which the counterparty can reveal to revoke previous
59          * states.
60          */
61         public void set_revocation_basepoint(org.ldk.structs.RevocationBasepoint val) {
62                 bindings.ChannelPublicKeys_set_revocation_basepoint(this.ptr, val == null ? 0 : val.ptr);
63                 GC.KeepAlive(this);
64                 GC.KeepAlive(val);
65                 if (this != null) { this.ptrs_to.AddLast(val); };
66         }
67
68         /**
69          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
70          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
71          * static across every commitment transaction.
72          */
73         public byte[] get_payment_point() {
74                 long ret = bindings.ChannelPublicKeys_get_payment_point(this.ptr);
75                 GC.KeepAlive(this);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
78                 return ret_conv;
79         }
80
81         /**
82          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
83          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
84          * static across every commitment transaction.
85          */
86         public void set_payment_point(byte[] val) {
87                 bindings.ChannelPublicKeys_set_payment_point(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 33)));
88                 GC.KeepAlive(this);
89                 GC.KeepAlive(val);
90         }
91
92         /**
93          * The base point which is used (with derive_public_key) to derive a per-commitment payment
94          * public key which receives non-HTLC-encumbered funds which are only available for spending
95          * after some delay (or can be claimed via the revocation path).
96          */
97         public DelayedPaymentBasepoint get_delayed_payment_basepoint() {
98                 long ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this.ptr);
99                 GC.KeepAlive(this);
100                 if (ret >= 0 && ret <= 4096) { return null; }
101                 org.ldk.structs.DelayedPaymentBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentBasepoint(null, ret); }
102                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
103                 return ret_hu_conv;
104         }
105
106         /**
107          * The base point which is used (with derive_public_key) to derive a per-commitment payment
108          * public key which receives non-HTLC-encumbered funds which are only available for spending
109          * after some delay (or can be claimed via the revocation path).
110          */
111         public void set_delayed_payment_basepoint(org.ldk.structs.DelayedPaymentBasepoint val) {
112                 bindings.ChannelPublicKeys_set_delayed_payment_basepoint(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          * The base point which is used (with derive_public_key) to derive a per-commitment public key
120          * which is used to encumber HTLC-in-flight outputs.
121          */
122         public HtlcBasepoint get_htlc_basepoint() {
123                 long ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this.ptr);
124                 GC.KeepAlive(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 org.ldk.structs.HtlcBasepoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HtlcBasepoint(null, ret); }
127                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
128                 return ret_hu_conv;
129         }
130
131         /**
132          * The base point which is used (with derive_public_key) to derive a per-commitment public key
133          * which is used to encumber HTLC-in-flight outputs.
134          */
135         public void set_htlc_basepoint(org.ldk.structs.HtlcBasepoint val) {
136                 bindings.ChannelPublicKeys_set_htlc_basepoint(this.ptr, val == null ? 0 : val.ptr);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(val);
139                 if (this != null) { this.ptrs_to.AddLast(val); };
140         }
141
142         /**
143          * Constructs a new ChannelPublicKeys given each field
144          */
145         public static ChannelPublicKeys of(byte[] funding_pubkey_arg, org.ldk.structs.RevocationBasepoint revocation_basepoint_arg, byte[] payment_point_arg, org.ldk.structs.DelayedPaymentBasepoint delayed_payment_basepoint_arg, org.ldk.structs.HtlcBasepoint htlc_basepoint_arg) {
146                 long ret = bindings.ChannelPublicKeys_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_pubkey_arg, 33)), revocation_basepoint_arg == null ? 0 : revocation_basepoint_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_point_arg, 33)), delayed_payment_basepoint_arg == null ? 0 : delayed_payment_basepoint_arg.ptr, htlc_basepoint_arg == null ? 0 : htlc_basepoint_arg.ptr);
147                 GC.KeepAlive(funding_pubkey_arg);
148                 GC.KeepAlive(revocation_basepoint_arg);
149                 GC.KeepAlive(payment_point_arg);
150                 GC.KeepAlive(delayed_payment_basepoint_arg);
151                 GC.KeepAlive(htlc_basepoint_arg);
152                 if (ret >= 0 && ret <= 4096) { return null; }
153                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
154                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
155                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(revocation_basepoint_arg); };
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(delayed_payment_basepoint_arg); };
157                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(htlc_basepoint_arg); };
158                 return ret_hu_conv;
159         }
160
161         internal long clone_ptr() {
162                 long ret = bindings.ChannelPublicKeys_clone_ptr(this.ptr);
163                 GC.KeepAlive(this);
164                 return ret;
165         }
166
167         /**
168          * Creates a copy of the ChannelPublicKeys
169          */
170         public ChannelPublicKeys clone() {
171                 long ret = bindings.ChannelPublicKeys_clone(this.ptr);
172                 GC.KeepAlive(this);
173                 if (ret >= 0 && ret <= 4096) { return null; }
174                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
175                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
176                 return ret_hu_conv;
177         }
178
179         /**
180          * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys.
181          */
182         public long hash() {
183                 long ret = bindings.ChannelPublicKeys_hash(this.ptr);
184                 GC.KeepAlive(this);
185                 return ret;
186         }
187
188         public override int GetHashCode() {
189                 return (int)this.hash();
190         }
191         /**
192          * Checks if two ChannelPublicKeyss contain equal inner contents.
193          * This ignores pointers and is_owned flags and looks at the values in fields.
194          * Two objects with NULL inner values will be considered "equal" here.
195          */
196         public bool eq(org.ldk.structs.ChannelPublicKeys b) {
197                 bool ret = bindings.ChannelPublicKeys_eq(this.ptr, b == null ? 0 : b.ptr);
198                 GC.KeepAlive(this);
199                 GC.KeepAlive(b);
200                 if (this != null) { this.ptrs_to.AddLast(b); };
201                 return ret;
202         }
203
204         public override bool Equals(object o) {
205                 if (!(o is ChannelPublicKeys)) return false;
206                 return this.eq((ChannelPublicKeys)o);
207         }
208         /**
209          * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read
210          */
211         public byte[] write() {
212                 long ret = bindings.ChannelPublicKeys_write(this.ptr);
213                 GC.KeepAlive(this);
214                 if (ret >= 0 && ret <= 4096) { return null; }
215                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
216                 return ret_conv;
217         }
218
219         /**
220          * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write
221          */
222         public static Result_ChannelPublicKeysDecodeErrorZ read(byte[] ser) {
223                 long ret = bindings.ChannelPublicKeys_read(InternalUtils.encodeUint8Array(ser));
224                 GC.KeepAlive(ser);
225                 if (ret >= 0 && ret <= 4096) { return null; }
226                 Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
227                 return ret_hu_conv;
228         }
229
230 }
231 } } }