577104270bf02bbdda24067d1007dee91d3534a3
[ldk-java] / src / main / java / org / ldk / structs / DelayedPaymentOutputDescriptor.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Information about a spendable output to a P2WSH script.
13  * 
14  * See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class DelayedPaymentOutputDescriptor extends CommonBase {
18         DelayedPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.DelayedPaymentOutputDescriptor_free(ptr); }
23         }
24
25         /**
26          * The outpoint which is spendable.
27          */
28         public OutPoint get_outpoint() {
29                 long ret = bindings.DelayedPaymentOutputDescriptor_get_outpoint(this.ptr);
30                 Reference.reachabilityFence(this);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
33                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
34                 return ret_hu_conv;
35         }
36
37         /**
38          * The outpoint which is spendable.
39          */
40         public void set_outpoint(org.ldk.structs.OutPoint val) {
41                 bindings.DelayedPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
42                 Reference.reachabilityFence(this);
43                 Reference.reachabilityFence(val);
44                 if (this != null) { this.ptrs_to.add(val); };
45         }
46
47         /**
48          * Per commitment point to derive the delayed payment key by key holder.
49          */
50         public byte[] get_per_commitment_point() {
51                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_per_commitment_point(this.ptr);
52                 Reference.reachabilityFence(this);
53                 return ret;
54         }
55
56         /**
57          * Per commitment point to derive the delayed payment key by key holder.
58          */
59         public void set_per_commitment_point(byte[] val) {
60                 bindings.DelayedPaymentOutputDescriptor_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in
67          * the witness_script.
68          */
69         public short get_to_self_delay() {
70                 short ret = bindings.DelayedPaymentOutputDescriptor_get_to_self_delay(this.ptr);
71                 Reference.reachabilityFence(this);
72                 return ret;
73         }
74
75         /**
76          * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in
77          * the witness_script.
78          */
79         public void set_to_self_delay(short val) {
80                 bindings.DelayedPaymentOutputDescriptor_set_to_self_delay(this.ptr, val);
81                 Reference.reachabilityFence(this);
82                 Reference.reachabilityFence(val);
83         }
84
85         /**
86          * The output which is referenced by the given outpoint.
87          * 
88          * Returns a copy of the field.
89          */
90         public TxOut get_output() {
91                 long ret = bindings.DelayedPaymentOutputDescriptor_get_output(this.ptr);
92                 Reference.reachabilityFence(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 TxOut ret_conv = new TxOut(null, ret);
95                 return ret_conv;
96         }
97
98         /**
99          * The output which is referenced by the given outpoint.
100          */
101         public void set_output(org.ldk.structs.TxOut val) {
102                 bindings.DelayedPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
103                 Reference.reachabilityFence(this);
104                 Reference.reachabilityFence(val);
105         }
106
107         /**
108          * The revocation point specific to the commitment transaction which was broadcast. Used to
109          * derive the witnessScript for this output.
110          */
111         public byte[] get_revocation_pubkey() {
112                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_revocation_pubkey(this.ptr);
113                 Reference.reachabilityFence(this);
114                 return ret;
115         }
116
117         /**
118          * The revocation point specific to the commitment transaction which was broadcast. Used to
119          * derive the witnessScript for this output.
120          */
121         public void set_revocation_pubkey(byte[] val) {
122                 bindings.DelayedPaymentOutputDescriptor_set_revocation_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
123                 Reference.reachabilityFence(this);
124                 Reference.reachabilityFence(val);
125         }
126
127         /**
128          * Arbitrary identification information returned by a call to [`BaseSign::channel_keys_id`].
129          * This may be useful in re-deriving keys used in the channel to spend the output.
130          */
131         public byte[] get_channel_keys_id() {
132                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
133                 Reference.reachabilityFence(this);
134                 return ret;
135         }
136
137         /**
138          * Arbitrary identification information returned by a call to [`BaseSign::channel_keys_id`].
139          * This may be useful in re-deriving keys used in the channel to spend the output.
140          */
141         public void set_channel_keys_id(byte[] val) {
142                 bindings.DelayedPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
143                 Reference.reachabilityFence(this);
144                 Reference.reachabilityFence(val);
145         }
146
147         /**
148          * The value of the channel which this output originated from, possibly indirectly.
149          */
150         public long get_channel_value_satoshis() {
151                 long ret = bindings.DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
152                 Reference.reachabilityFence(this);
153                 return ret;
154         }
155
156         /**
157          * The value of the channel which this output originated from, possibly indirectly.
158          */
159         public void set_channel_value_satoshis(long val) {
160                 bindings.DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
161                 Reference.reachabilityFence(this);
162                 Reference.reachabilityFence(val);
163         }
164
165         /**
166          * Constructs a new DelayedPaymentOutputDescriptor given each field
167          */
168         public static DelayedPaymentOutputDescriptor of(org.ldk.structs.OutPoint outpoint_arg, byte[] per_commitment_point_arg, short to_self_delay_arg, org.ldk.structs.TxOut output_arg, byte[] revocation_pubkey_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
169                 long ret = bindings.DelayedPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr, InternalUtils.check_arr_len(per_commitment_point_arg, 33), to_self_delay_arg, output_arg.ptr, InternalUtils.check_arr_len(revocation_pubkey_arg, 33), InternalUtils.check_arr_len(channel_keys_id_arg, 32), channel_value_satoshis_arg);
170                 Reference.reachabilityFence(outpoint_arg);
171                 Reference.reachabilityFence(per_commitment_point_arg);
172                 Reference.reachabilityFence(to_self_delay_arg);
173                 Reference.reachabilityFence(output_arg);
174                 Reference.reachabilityFence(revocation_pubkey_arg);
175                 Reference.reachabilityFence(channel_keys_id_arg);
176                 Reference.reachabilityFence(channel_value_satoshis_arg);
177                 if (ret >= 0 && ret <= 4096) { return null; }
178                 org.ldk.structs.DelayedPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentOutputDescriptor(null, ret); }
179                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
180                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
181                 return ret_hu_conv;
182         }
183
184         long clone_ptr() {
185                 long ret = bindings.DelayedPaymentOutputDescriptor_clone_ptr(this.ptr);
186                 Reference.reachabilityFence(this);
187                 return ret;
188         }
189
190         /**
191          * Creates a copy of the DelayedPaymentOutputDescriptor
192          */
193         public DelayedPaymentOutputDescriptor clone() {
194                 long ret = bindings.DelayedPaymentOutputDescriptor_clone(this.ptr);
195                 Reference.reachabilityFence(this);
196                 if (ret >= 0 && ret <= 4096) { return null; }
197                 org.ldk.structs.DelayedPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentOutputDescriptor(null, ret); }
198                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
199                 return ret_hu_conv;
200         }
201
202         /**
203          * Checks if two DelayedPaymentOutputDescriptors contain equal inner contents.
204          * This ignores pointers and is_owned flags and looks at the values in fields.
205          * Two objects with NULL inner values will be considered "equal" here.
206          */
207         public boolean eq(org.ldk.structs.DelayedPaymentOutputDescriptor b) {
208                 boolean ret = bindings.DelayedPaymentOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
209                 Reference.reachabilityFence(this);
210                 Reference.reachabilityFence(b);
211                 if (this != null) { this.ptrs_to.add(b); };
212                 return ret;
213         }
214
215         @Override public boolean equals(Object o) {
216                 if (!(o instanceof DelayedPaymentOutputDescriptor)) return false;
217                 return this.eq((DelayedPaymentOutputDescriptor)o);
218         }
219         /**
220          * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read
221          */
222         public byte[] write() {
223                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_write(this.ptr);
224                 Reference.reachabilityFence(this);
225                 return ret;
226         }
227
228         /**
229          * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write
230          */
231         public static Result_DelayedPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
232                 long ret = bindings.DelayedPaymentOutputDescriptor_read(ser);
233                 Reference.reachabilityFence(ser);
234                 if (ret >= 0 && ret <= 4096) { return null; }
235                 Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
236                 return ret_hu_conv;
237         }
238
239 }