[Java] Update auto-generated Java structs
[ldk-java] / src / main / java / org / ldk / structs / StaticPaymentOutputDescriptor.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 our \"payment key\". See
13  * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class StaticPaymentOutputDescriptor extends CommonBase {
17         StaticPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.StaticPaymentOutputDescriptor_free(ptr); }
22         }
23
24         /**
25          * The outpoint which is spendable
26          */
27         public OutPoint get_outpoint() {
28                 long ret = bindings.StaticPaymentOutputDescriptor_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                 if (ret_hu_conv != null) { 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.StaticPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43                 if (this != null) { this.ptrs_to.add(val); };
44         }
45
46         /**
47          * The output which is referenced by the given outpoint
48          * 
49          * Returns a copy of the field.
50          */
51         public TxOut get_output() {
52                 long ret = bindings.StaticPaymentOutputDescriptor_get_output(this.ptr);
53                 Reference.reachabilityFence(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 TxOut ret_conv = new TxOut(null, ret);
56                 return ret_conv;
57         }
58
59         /**
60          * The output which is referenced by the given outpoint
61          */
62         public void set_output(TxOut val) {
63                 bindings.StaticPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
64                 Reference.reachabilityFence(this);
65                 Reference.reachabilityFence(val);
66         }
67
68         /**
69          * Arbitrary identification information returned by a call to
70          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
71          * the channel to spend the output.
72          */
73         public byte[] get_channel_keys_id() {
74                 byte[] ret = bindings.StaticPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
75                 Reference.reachabilityFence(this);
76                 return ret;
77         }
78
79         /**
80          * Arbitrary identification information returned by a call to
81          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
82          * the channel to spend the output.
83          */
84         public void set_channel_keys_id(byte[] val) {
85                 bindings.StaticPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
86                 Reference.reachabilityFence(this);
87                 Reference.reachabilityFence(val);
88         }
89
90         /**
91          * The value of the channel which this transactions spends.
92          */
93         public long get_channel_value_satoshis() {
94                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
95                 Reference.reachabilityFence(this);
96                 return ret;
97         }
98
99         /**
100          * The value of the channel which this transactions spends.
101          */
102         public void set_channel_value_satoshis(long val) {
103                 bindings.StaticPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
104                 Reference.reachabilityFence(this);
105                 Reference.reachabilityFence(val);
106         }
107
108         /**
109          * Constructs a new StaticPaymentOutputDescriptor given each field
110          */
111         public static StaticPaymentOutputDescriptor of(OutPoint outpoint_arg, TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
112                 long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr, output_arg.ptr, InternalUtils.check_arr_len(channel_keys_id_arg, 32), channel_value_satoshis_arg);
113                 Reference.reachabilityFence(outpoint_arg);
114                 Reference.reachabilityFence(output_arg);
115                 Reference.reachabilityFence(channel_keys_id_arg);
116                 Reference.reachabilityFence(channel_value_satoshis_arg);
117                 if (ret >= 0 && ret <= 4096) { return null; }
118                 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
119                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
120                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint_arg); };
121                 return ret_hu_conv;
122         }
123
124         long clone_ptr() {
125                 long ret = bindings.StaticPaymentOutputDescriptor_clone_ptr(this.ptr);
126                 Reference.reachabilityFence(this);
127                 return ret;
128         }
129
130         /**
131          * Creates a copy of the StaticPaymentOutputDescriptor
132          */
133         public StaticPaymentOutputDescriptor clone() {
134                 long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
135                 Reference.reachabilityFence(this);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 org.ldk.structs.StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.StaticPaymentOutputDescriptor(null, ret); }
138                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
139                 return ret_hu_conv;
140         }
141
142         /**
143          * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
144          */
145         public byte[] write() {
146                 byte[] ret = bindings.StaticPaymentOutputDescriptor_write(this.ptr);
147                 Reference.reachabilityFence(this);
148                 return ret;
149         }
150
151         /**
152          * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
153          */
154         public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
155                 long ret = bindings.StaticPaymentOutputDescriptor_read(ser);
156                 Reference.reachabilityFence(ser);
157                 if (ret >= 0 && ret <= 4096) { return null; }
158                 Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
159                 return ret_hu_conv;
160         }
161
162 }