Merge pull request #141 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                 byte[] ret = bindings.ChannelPublicKeys_get_funding_pubkey(this.ptr);
24                 GC.KeepAlive(this);
25                 return ret;
26         }
27
28         /**
29          * The public key which is used to sign all commitment transactions, as it appears in the
30          * on-chain channel lock-in 2-of-2 multisig output.
31          */
32         public void set_funding_pubkey(byte[] val) {
33                 bindings.ChannelPublicKeys_set_funding_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * The base point which is used (with derive_public_revocation_key) to derive per-commitment
40          * revocation keys. This is combined with the per-commitment-secret generated by the
41          * counterparty to create a secret which the counterparty can reveal to revoke previous
42          * states.
43          */
44         public byte[] get_revocation_basepoint() {
45                 byte[] ret = bindings.ChannelPublicKeys_get_revocation_basepoint(this.ptr);
46                 GC.KeepAlive(this);
47                 return ret;
48         }
49
50         /**
51          * The base point which is used (with derive_public_revocation_key) to derive per-commitment
52          * revocation keys. This is combined with the per-commitment-secret generated by the
53          * counterparty to create a secret which the counterparty can reveal to revoke previous
54          * states.
55          */
56         public void set_revocation_basepoint(byte[] val) {
57                 bindings.ChannelPublicKeys_set_revocation_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
64          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
65          * static across every commitment transaction.
66          */
67         public byte[] get_payment_point() {
68                 byte[] ret = bindings.ChannelPublicKeys_get_payment_point(this.ptr);
69                 GC.KeepAlive(this);
70                 return ret;
71         }
72
73         /**
74          * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
75          * spendable primary channel balance on the broadcaster's commitment transaction. This key is
76          * static across every commitment transaction.
77          */
78         public void set_payment_point(byte[] val) {
79                 bindings.ChannelPublicKeys_set_payment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
80                 GC.KeepAlive(this);
81                 GC.KeepAlive(val);
82         }
83
84         /**
85          * The base point which is used (with derive_public_key) to derive a per-commitment payment
86          * public key which receives non-HTLC-encumbered funds which are only available for spending
87          * after some delay (or can be claimed via the revocation path).
88          */
89         public byte[] get_delayed_payment_basepoint() {
90                 byte[] ret = bindings.ChannelPublicKeys_get_delayed_payment_basepoint(this.ptr);
91                 GC.KeepAlive(this);
92                 return ret;
93         }
94
95         /**
96          * The base point which is used (with derive_public_key) to derive a per-commitment payment
97          * public key which receives non-HTLC-encumbered funds which are only available for spending
98          * after some delay (or can be claimed via the revocation path).
99          */
100         public void set_delayed_payment_basepoint(byte[] val) {
101                 bindings.ChannelPublicKeys_set_delayed_payment_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
102                 GC.KeepAlive(this);
103                 GC.KeepAlive(val);
104         }
105
106         /**
107          * The base point which is used (with derive_public_key) to derive a per-commitment public key
108          * which is used to encumber HTLC-in-flight outputs.
109          */
110         public byte[] get_htlc_basepoint() {
111                 byte[] ret = bindings.ChannelPublicKeys_get_htlc_basepoint(this.ptr);
112                 GC.KeepAlive(this);
113                 return ret;
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 void set_htlc_basepoint(byte[] val) {
121                 bindings.ChannelPublicKeys_set_htlc_basepoint(this.ptr, InternalUtils.check_arr_len(val, 33));
122                 GC.KeepAlive(this);
123                 GC.KeepAlive(val);
124         }
125
126         /**
127          * Constructs a new ChannelPublicKeys given each field
128          */
129         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) {
130                 long ret = bindings.ChannelPublicKeys_new(InternalUtils.check_arr_len(funding_pubkey_arg, 33), InternalUtils.check_arr_len(revocation_basepoint_arg, 33), InternalUtils.check_arr_len(payment_point_arg, 33), InternalUtils.check_arr_len(delayed_payment_basepoint_arg, 33), InternalUtils.check_arr_len(htlc_basepoint_arg, 33));
131                 GC.KeepAlive(funding_pubkey_arg);
132                 GC.KeepAlive(revocation_basepoint_arg);
133                 GC.KeepAlive(payment_point_arg);
134                 GC.KeepAlive(delayed_payment_basepoint_arg);
135                 GC.KeepAlive(htlc_basepoint_arg);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
138                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
139                 return ret_hu_conv;
140         }
141
142         internal long clone_ptr() {
143                 long ret = bindings.ChannelPublicKeys_clone_ptr(this.ptr);
144                 GC.KeepAlive(this);
145                 return ret;
146         }
147
148         /**
149          * Creates a copy of the ChannelPublicKeys
150          */
151         public ChannelPublicKeys clone() {
152                 long ret = bindings.ChannelPublicKeys_clone(this.ptr);
153                 GC.KeepAlive(this);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 org.ldk.structs.ChannelPublicKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelPublicKeys(null, ret); }
156                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
157                 return ret_hu_conv;
158         }
159
160         /**
161          * Checks if two ChannelPublicKeyss 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.ChannelPublicKeys b) {
166                 bool ret = bindings.ChannelPublicKeys_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 ChannelPublicKeys)) return false;
175                 return this.eq((ChannelPublicKeys)o);
176         }
177         /**
178          * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read
179          */
180         public byte[] write() {
181                 byte[] ret = bindings.ChannelPublicKeys_write(this.ptr);
182                 GC.KeepAlive(this);
183                 return ret;
184         }
185
186         /**
187          * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write
188          */
189         public static Result_ChannelPublicKeysDecodeErrorZ read(byte[] ser) {
190                 long ret = bindings.ChannelPublicKeys_read(ser);
191                 GC.KeepAlive(ser);
192                 if (ret >= 0 && ret <= 4096) { return null; }
193                 Result_ChannelPublicKeysDecodeErrorZ ret_hu_conv = Result_ChannelPublicKeysDecodeErrorZ.constr_from_ptr(ret);
194                 return ret_hu_conv;
195         }
196
197 }
198 } } }