[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / StaticPaymentOutputDescriptor.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  * Information about a spendable output to our \"payment key\".
11  * 
12  * See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this.
13  */
14 public class StaticPaymentOutputDescriptor : CommonBase {
15         internal StaticPaymentOutputDescriptor(object _dummy, long ptr) : base(ptr) { }
16         ~StaticPaymentOutputDescriptor() {
17                 if (ptr != 0) { bindings.StaticPaymentOutputDescriptor_free(ptr); }
18         }
19
20         /**
21          * The outpoint which is spendable.
22          */
23         public OutPoint get_outpoint() {
24                 long ret = bindings.StaticPaymentOutputDescriptor_get_outpoint(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
28                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
29                 return ret_hu_conv;
30         }
31
32         /**
33          * The outpoint which is spendable.
34          */
35         public void set_outpoint(org.ldk.structs.OutPoint val) {
36                 bindings.StaticPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39                 if (this != null) { this.ptrs_to.AddLast(val); };
40         }
41
42         /**
43          * The output which is referenced by the given outpoint.
44          */
45         public TxOut get_output() {
46                 long ret = bindings.StaticPaymentOutputDescriptor_get_output(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 TxOut ret_conv = new TxOut(null, ret);
50                 return ret_conv;
51         }
52
53         /**
54          * The output which is referenced by the given outpoint.
55          */
56         public void set_output(org.ldk.structs.TxOut val) {
57                 bindings.StaticPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
58                 GC.KeepAlive(this);
59                 GC.KeepAlive(val);
60         }
61
62         /**
63          * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
64          * This may be useful in re-deriving keys used in the channel to spend the output.
65          */
66         public byte[] get_channel_keys_id() {
67                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
68                 GC.KeepAlive(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
71                 return ret_conv;
72         }
73
74         /**
75          * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`].
76          * This may be useful in re-deriving keys used in the channel to spend the output.
77          */
78         public void set_channel_keys_id(byte[] val) {
79                 bindings.StaticPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
80                 GC.KeepAlive(this);
81                 GC.KeepAlive(val);
82         }
83
84         /**
85          * The value of the channel which this transactions spends.
86          */
87         public long get_channel_value_satoshis() {
88                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
89                 GC.KeepAlive(this);
90                 return ret;
91         }
92
93         /**
94          * The value of the channel which this transactions spends.
95          */
96         public void set_channel_value_satoshis(long val) {
97                 bindings.StaticPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
98                 GC.KeepAlive(this);
99                 GC.KeepAlive(val);
100         }
101
102         /**
103          * The necessary channel parameters that need to be provided to the re-derived signer through
104          * [`ChannelSigner::provide_channel_parameters`].
105          * 
106          * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later.
107          * 
108          * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
109          */
110         public ChannelTransactionParameters get_channel_transaction_parameters() {
111                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_transaction_parameters(this.ptr);
112                 GC.KeepAlive(this);
113                 if (ret >= 0 && ret <= 4096) { return null; }
114                 org.ldk.structs.ChannelTransactionParameters ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelTransactionParameters(null, ret); }
115                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
116                 return ret_hu_conv;
117         }
118
119         /**
120          * The necessary channel parameters that need to be provided to the re-derived signer through
121          * [`ChannelSigner::provide_channel_parameters`].
122          * 
123          * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later.
124          * 
125          * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
126          */
127         public void set_channel_transaction_parameters(org.ldk.structs.ChannelTransactionParameters val) {
128                 bindings.StaticPaymentOutputDescriptor_set_channel_transaction_parameters(this.ptr, val == null ? 0 : val.ptr);
129                 GC.KeepAlive(this);
130                 GC.KeepAlive(val);
131                 if (this != null) { this.ptrs_to.AddLast(val); };
132         }
133
134         /**
135          * Constructs a new StaticPaymentOutputDescriptor given each field
136          * 
137          * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
138          */
139         public static StaticPaymentOutputDescriptor of(org.ldk.structs.OutPoint outpoint_arg, org.ldk.structs.TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg, org.ldk.structs.ChannelTransactionParameters channel_transaction_parameters_arg) {
140                 long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr, output_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_keys_id_arg, 32)), channel_value_satoshis_arg, channel_transaction_parameters_arg == null ? 0 : channel_transaction_parameters_arg.ptr);
141                 GC.KeepAlive(outpoint_arg);
142                 GC.KeepAlive(output_arg);
143                 GC.KeepAlive(channel_keys_id_arg);
144                 GC.KeepAlive(channel_value_satoshis_arg);
145                 GC.KeepAlive(channel_transaction_parameters_arg);
146                 if (ret >= 0 && ret <= 4096) { return null; }
147                 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
148                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
149                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(outpoint_arg); };
150                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_transaction_parameters_arg); };
151                 return ret_hu_conv;
152         }
153
154         internal long clone_ptr() {
155                 long ret = bindings.StaticPaymentOutputDescriptor_clone_ptr(this.ptr);
156                 GC.KeepAlive(this);
157                 return ret;
158         }
159
160         /**
161          * Creates a copy of the StaticPaymentOutputDescriptor
162          */
163         public StaticPaymentOutputDescriptor clone() {
164                 long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
165                 GC.KeepAlive(this);
166                 if (ret >= 0 && ret <= 4096) { return null; }
167                 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
168                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
169                 return ret_hu_conv;
170         }
171
172         /**
173          * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor.
174          */
175         public long hash() {
176                 long ret = bindings.StaticPaymentOutputDescriptor_hash(this.ptr);
177                 GC.KeepAlive(this);
178                 return ret;
179         }
180
181         public override int GetHashCode() {
182                 return (int)this.hash();
183         }
184         /**
185          * Checks if two StaticPaymentOutputDescriptors contain equal inner contents.
186          * This ignores pointers and is_owned flags and looks at the values in fields.
187          * Two objects with NULL inner values will be considered "equal" here.
188          */
189         public bool eq(org.ldk.structs.StaticPaymentOutputDescriptor b) {
190                 bool ret = bindings.StaticPaymentOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
191                 GC.KeepAlive(this);
192                 GC.KeepAlive(b);
193                 if (this != null) { this.ptrs_to.AddLast(b); };
194                 return ret;
195         }
196
197         public override bool Equals(object o) {
198                 if (!(o is StaticPaymentOutputDescriptor)) return false;
199                 return this.eq((StaticPaymentOutputDescriptor)o);
200         }
201         /**
202          * Returns the `witness_script` of the spendable output.
203          * 
204          * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that
205          * originated from an anchor outputs channel, as they take the form of a P2WSH script.
206          */
207         public Option_CVec_u8ZZ witness_script() {
208                 long ret = bindings.StaticPaymentOutputDescriptor_witness_script(this.ptr);
209                 GC.KeepAlive(this);
210                 if (ret >= 0 && ret <= 4096) { return null; }
211                 org.ldk.structs.Option_CVec_u8ZZ ret_hu_conv = org.ldk.structs.Option_CVec_u8ZZ.constr_from_ptr(ret);
212                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
213                 return ret_hu_conv;
214         }
215
216         /**
217          * The maximum length a well-formed witness spending one of these should have.
218          * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte
219          * shorter.
220          */
221         public long max_witness_length() {
222                 long ret = bindings.StaticPaymentOutputDescriptor_max_witness_length(this.ptr);
223                 GC.KeepAlive(this);
224                 return ret;
225         }
226
227         /**
228          * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
229          */
230         public byte[] write() {
231                 long ret = bindings.StaticPaymentOutputDescriptor_write(this.ptr);
232                 GC.KeepAlive(this);
233                 if (ret >= 0 && ret <= 4096) { return null; }
234                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
235                 return ret_conv;
236         }
237
238         /**
239          * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
240          */
241         public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
242                 long ret = bindings.StaticPaymentOutputDescriptor_read(InternalUtils.encodeUint8Array(ser));
243                 GC.KeepAlive(ser);
244                 if (ret >= 0 && ret <= 4096) { return null; }
245                 Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
246                 return ret_hu_conv;
247         }
248
249 }
250 } } }