Merge pull request #113 from TheBlueMatt/main
[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. See
13  * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class DelayedPaymentOutputDescriptor extends CommonBase {
17         DelayedPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.DelayedPaymentOutputDescriptor_free(ptr); }
22         }
23
24         /**
25          * The outpoint which is spendable
26          */
27         public OutPoint get_outpoint() {
28                 long ret = bindings.DelayedPaymentOutputDescriptor_get_outpoint(this.ptr);
29                 Reference.reachabilityFence(this);
30                 if (ret >= 0 && ret <= 4096) { return null; }
31                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
32                 ret_hu_conv.ptrs_to.add(this);
33                 return ret_hu_conv;
34         }
35
36         /**
37          * The outpoint which is spendable
38          */
39         public void set_outpoint(OutPoint val) {
40                 bindings.DelayedPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * Per commitment point to derive delayed_payment_key by key holder
47          */
48         public byte[] get_per_commitment_point() {
49                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_per_commitment_point(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * Per commitment point to derive delayed_payment_key by key holder
56          */
57         public void set_per_commitment_point(byte[] val) {
58                 bindings.DelayedPaymentOutputDescriptor_set_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61         }
62
63         /**
64          * The nSequence value which must be set in the spending input to satisfy the OP_CSV in
65          * the witness_script.
66          */
67         public short get_to_self_delay() {
68                 short ret = bindings.DelayedPaymentOutputDescriptor_get_to_self_delay(this.ptr);
69                 Reference.reachabilityFence(this);
70                 return ret;
71         }
72
73         /**
74          * The nSequence value which must be set in the spending input to satisfy the OP_CSV in
75          * the witness_script.
76          */
77         public void set_to_self_delay(short val) {
78                 bindings.DelayedPaymentOutputDescriptor_set_to_self_delay(this.ptr, val);
79                 Reference.reachabilityFence(this);
80                 Reference.reachabilityFence(val);
81         }
82
83         /**
84          * The output which is referenced by the given outpoint
85          * 
86          * Returns a copy of the field.
87          */
88         public TxOut get_output() {
89                 long ret = bindings.DelayedPaymentOutputDescriptor_get_output(this.ptr);
90                 Reference.reachabilityFence(this);
91                 if (ret >= 0 && ret <= 4096) { return null; }
92                 TxOut ret_conv = new TxOut(null, ret);
93                 return ret_conv;
94         }
95
96         /**
97          * The output which is referenced by the given outpoint
98          */
99         public void set_output(TxOut val) {
100                 bindings.DelayedPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
101                 Reference.reachabilityFence(this);
102                 Reference.reachabilityFence(val);
103         }
104
105         /**
106          * The revocation point specific to the commitment transaction which was broadcast. Used to
107          * derive the witnessScript for this output.
108          */
109         public byte[] get_revocation_pubkey() {
110                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_revocation_pubkey(this.ptr);
111                 Reference.reachabilityFence(this);
112                 return ret;
113         }
114
115         /**
116          * The revocation point specific to the commitment transaction which was broadcast. Used to
117          * derive the witnessScript for this output.
118          */
119         public void set_revocation_pubkey(byte[] val) {
120                 bindings.DelayedPaymentOutputDescriptor_set_revocation_pubkey(this.ptr, InternalUtils.check_arr_len(val, 33));
121                 Reference.reachabilityFence(this);
122                 Reference.reachabilityFence(val);
123         }
124
125         /**
126          * Arbitrary identification information returned by a call to
127          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
128          * the channel to spend the output.
129          */
130         public byte[] get_channel_keys_id() {
131                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
132                 Reference.reachabilityFence(this);
133                 return ret;
134         }
135
136         /**
137          * Arbitrary identification information returned by a call to
138          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
139          * 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(OutPoint outpoint_arg, byte[] per_commitment_point_arg, short to_self_delay_arg, 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 & ~1, 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                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
180                 return ret_hu_conv;
181         }
182
183         long clone_ptr() {
184                 long ret = bindings.DelayedPaymentOutputDescriptor_clone_ptr(this.ptr);
185                 Reference.reachabilityFence(this);
186                 return ret;
187         }
188
189         /**
190          * Creates a copy of the DelayedPaymentOutputDescriptor
191          */
192         public DelayedPaymentOutputDescriptor clone() {
193                 long ret = bindings.DelayedPaymentOutputDescriptor_clone(this.ptr);
194                 Reference.reachabilityFence(this);
195                 if (ret >= 0 && ret <= 4096) { return null; }
196                 org.ldk.structs.DelayedPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.DelayedPaymentOutputDescriptor(null, ret); }
197                 ret_hu_conv.ptrs_to.add(this);
198                 return ret_hu_conv;
199         }
200
201         /**
202          * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read
203          */
204         public byte[] write() {
205                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_write(this.ptr);
206                 Reference.reachabilityFence(this);
207                 return ret;
208         }
209
210         /**
211          * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write
212          */
213         public static Result_DelayedPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
214                 long ret = bindings.DelayedPaymentOutputDescriptor_read(ser);
215                 Reference.reachabilityFence(ser);
216                 if (ret >= 0 && ret <= 4096) { return null; }
217                 Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
218                 return ret_hu_conv;
219         }
220
221 }