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