Update auto-updated Java files
[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                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new 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.StaticPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * The output which is referenced by the given outpoint
47          */
48         public void set_output(TxOut val) {
49                 bindings.StaticPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
50                 Reference.reachabilityFence(this);
51                 Reference.reachabilityFence(val);
52         }
53
54         /**
55          * Arbitrary identification information returned by a call to
56          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
57          * the channel to spend the output.
58          */
59         public byte[] get_channel_keys_id() {
60                 byte[] ret = bindings.StaticPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
61                 Reference.reachabilityFence(this);
62                 return ret;
63         }
64
65         /**
66          * Arbitrary identification information returned by a call to
67          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
68          * the channel to spend the output.
69          */
70         public void set_channel_keys_id(byte[] val) {
71                 bindings.StaticPaymentOutputDescriptor_set_channel_keys_id(this.ptr, InternalUtils.check_arr_len(val, 32));
72                 Reference.reachabilityFence(this);
73                 Reference.reachabilityFence(val);
74         }
75
76         /**
77          * The value of the channel which this transactions spends.
78          */
79         public long get_channel_value_satoshis() {
80                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
81                 Reference.reachabilityFence(this);
82                 return ret;
83         }
84
85         /**
86          * The value of the channel which this transactions spends.
87          */
88         public void set_channel_value_satoshis(long val) {
89                 bindings.StaticPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
90                 Reference.reachabilityFence(this);
91                 Reference.reachabilityFence(val);
92         }
93
94         /**
95          * Constructs a new StaticPaymentOutputDescriptor given each field
96          */
97         public static StaticPaymentOutputDescriptor of(OutPoint outpoint_arg, TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
98                 long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, output_arg.ptr, InternalUtils.check_arr_len(channel_keys_id_arg, 32), channel_value_satoshis_arg);
99                 Reference.reachabilityFence(outpoint_arg);
100                 Reference.reachabilityFence(output_arg);
101                 Reference.reachabilityFence(channel_keys_id_arg);
102                 Reference.reachabilityFence(channel_value_satoshis_arg);
103                 if (ret >= 0 && ret <= 4096) { return null; }
104                 StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret); }
105                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
106                 return ret_hu_conv;
107         }
108
109         long clone_ptr() {
110                 long ret = bindings.StaticPaymentOutputDescriptor_clone_ptr(this.ptr);
111                 Reference.reachabilityFence(this);
112                 return ret;
113         }
114
115         /**
116          * Creates a copy of the StaticPaymentOutputDescriptor
117          */
118         public StaticPaymentOutputDescriptor clone() {
119                 long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
120                 Reference.reachabilityFence(this);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 StaticPaymentOutputDescriptor ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret); }
123                 ret_hu_conv.ptrs_to.add(this);
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
129          */
130         public byte[] write() {
131                 byte[] ret = bindings.StaticPaymentOutputDescriptor_write(this.ptr);
132                 Reference.reachabilityFence(this);
133                 return ret;
134         }
135
136         /**
137          * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
138          */
139         public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
140                 long ret = bindings.StaticPaymentOutputDescriptor_read(ser);
141                 Reference.reachabilityFence(ser);
142                 if (ret >= 0 && ret <= 4096) { return null; }
143                 Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
144                 return ret_hu_conv;
145         }
146
147 }