Merge pull request #33 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 javax.annotation.Nullable;
8
9
10 /**
11  * Information about a spendable output to a P2WSH script. See
12  * SpendableOutputDescriptor::DelayedPaymentOutput for more details on how to spend this.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class DelayedPaymentOutputDescriptor extends CommonBase {
16         DelayedPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.DelayedPaymentOutputDescriptor_free(ptr); }
21         }
22
23         /**
24          * The outpoint which is spendable
25          */
26         public OutPoint get_outpoint() {
27                 long ret = bindings.DelayedPaymentOutputDescriptor_get_outpoint(this.ptr);
28                 if (ret < 1024) { return null; }
29                 OutPoint ret_hu_conv = new OutPoint(null, ret);
30                 ret_hu_conv.ptrs_to.add(this);
31                 return ret_hu_conv;
32         }
33
34         /**
35          * The outpoint which is spendable
36          */
37         public void set_outpoint(OutPoint val) {
38                 bindings.DelayedPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
39                 this.ptrs_to.add(val);
40         }
41
42         /**
43          * Per commitment point to derive delayed_payment_key by key holder
44          */
45         public byte[] get_per_commitment_point() {
46                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_per_commitment_point(this.ptr);
47                 return ret;
48         }
49
50         /**
51          * Per commitment point to derive delayed_payment_key by key holder
52          */
53         public void set_per_commitment_point(byte[] val) {
54                 bindings.DelayedPaymentOutputDescriptor_set_per_commitment_point(this.ptr, val);
55         }
56
57         /**
58          * The nSequence value which must be set in the spending input to satisfy the OP_CSV in
59          * the witness_script.
60          */
61         public short get_to_self_delay() {
62                 short ret = bindings.DelayedPaymentOutputDescriptor_get_to_self_delay(this.ptr);
63                 return ret;
64         }
65
66         /**
67          * The nSequence value which must be set in the spending input to satisfy the OP_CSV in
68          * the witness_script.
69          */
70         public void set_to_self_delay(short val) {
71                 bindings.DelayedPaymentOutputDescriptor_set_to_self_delay(this.ptr, val);
72         }
73
74         /**
75          * The output which is referenced by the given outpoint
76          */
77         public void set_output(TxOut val) {
78                 bindings.DelayedPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
79         }
80
81         /**
82          * The revocation point specific to the commitment transaction which was broadcast. Used to
83          * derive the witnessScript for this output.
84          */
85         public byte[] get_revocation_pubkey() {
86                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_revocation_pubkey(this.ptr);
87                 return ret;
88         }
89
90         /**
91          * The revocation point specific to the commitment transaction which was broadcast. Used to
92          * derive the witnessScript for this output.
93          */
94         public void set_revocation_pubkey(byte[] val) {
95                 bindings.DelayedPaymentOutputDescriptor_set_revocation_pubkey(this.ptr, val);
96         }
97
98         /**
99          * Arbitrary identification information returned by a call to
100          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
101          * the channel to spend the output.
102          */
103         public byte[] get_channel_keys_id() {
104                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
105                 return ret;
106         }
107
108         /**
109          * Arbitrary identification information returned by a call to
110          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
111          * the channel to spend the output.
112          */
113         public void set_channel_keys_id(byte[] val) {
114                 bindings.DelayedPaymentOutputDescriptor_set_channel_keys_id(this.ptr, val);
115         }
116
117         /**
118          * The value of the channel which this output originated from, possibly indirectly.
119          */
120         public long get_channel_value_satoshis() {
121                 long ret = bindings.DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
122                 return ret;
123         }
124
125         /**
126          * The value of the channel which this output originated from, possibly indirectly.
127          */
128         public void set_channel_value_satoshis(long val) {
129                 bindings.DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
130         }
131
132         /**
133          * Constructs a new DelayedPaymentOutputDescriptor given each field
134          */
135         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) {
136                 long ret = bindings.DelayedPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, per_commitment_point_arg, to_self_delay_arg, output_arg.ptr, revocation_pubkey_arg, channel_keys_id_arg, channel_value_satoshis_arg);
137                 if (ret < 1024) { return null; }
138                 DelayedPaymentOutputDescriptor ret_hu_conv = new DelayedPaymentOutputDescriptor(null, ret);
139                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
140                 ret_hu_conv.ptrs_to.add(outpoint_arg);
141                 return ret_hu_conv;
142         }
143
144         /**
145          * Creates a copy of the DelayedPaymentOutputDescriptor
146          */
147         public DelayedPaymentOutputDescriptor clone() {
148                 long ret = bindings.DelayedPaymentOutputDescriptor_clone(this.ptr);
149                 if (ret < 1024) { return null; }
150                 DelayedPaymentOutputDescriptor ret_hu_conv = new DelayedPaymentOutputDescriptor(null, ret);
151                 ret_hu_conv.ptrs_to.add(this);
152                 return ret_hu_conv;
153         }
154
155         /**
156          * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read
157          */
158         public byte[] write() {
159                 byte[] ret = bindings.DelayedPaymentOutputDescriptor_write(this.ptr);
160                 return ret;
161         }
162
163         /**
164          * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write
165          */
166         public static Result_DelayedPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
167                 long ret = bindings.DelayedPaymentOutputDescriptor_read(ser);
168                 if (ret < 1024) { return null; }
169                 Result_DelayedPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_DelayedPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
170                 return ret_hu_conv;
171         }
172
173 }