Merge pull request #33 from TheBlueMatt/main
[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 javax.annotation.Nullable;
8
9
10 /**
11  * Information about a spendable output to our \"payment key\". See
12  * SpendableOutputDescriptor::StaticPaymentOutput for more details on how to spend this.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class StaticPaymentOutputDescriptor extends CommonBase {
16         StaticPaymentOutputDescriptor(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.StaticPaymentOutputDescriptor_free(ptr); }
21         }
22
23         /**
24          * The outpoint which is spendable
25          */
26         public OutPoint get_outpoint() {
27                 long ret = bindings.StaticPaymentOutputDescriptor_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.StaticPaymentOutputDescriptor_set_outpoint(this.ptr, val == null ? 0 : val.ptr & ~1);
39                 this.ptrs_to.add(val);
40         }
41
42         /**
43          * The output which is referenced by the given outpoint
44          */
45         public void set_output(TxOut val) {
46                 bindings.StaticPaymentOutputDescriptor_set_output(this.ptr, val.ptr);
47         }
48
49         /**
50          * Arbitrary identification information returned by a call to
51          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
52          * the channel to spend the output.
53          */
54         public byte[] get_channel_keys_id() {
55                 byte[] ret = bindings.StaticPaymentOutputDescriptor_get_channel_keys_id(this.ptr);
56                 return ret;
57         }
58
59         /**
60          * Arbitrary identification information returned by a call to
61          * `Sign::channel_keys_id()`. This may be useful in re-deriving keys used in
62          * the channel to spend the output.
63          */
64         public void set_channel_keys_id(byte[] val) {
65                 bindings.StaticPaymentOutputDescriptor_set_channel_keys_id(this.ptr, val);
66         }
67
68         /**
69          * The value of the channel which this transactions spends.
70          */
71         public long get_channel_value_satoshis() {
72                 long ret = bindings.StaticPaymentOutputDescriptor_get_channel_value_satoshis(this.ptr);
73                 return ret;
74         }
75
76         /**
77          * The value of the channel which this transactions spends.
78          */
79         public void set_channel_value_satoshis(long val) {
80                 bindings.StaticPaymentOutputDescriptor_set_channel_value_satoshis(this.ptr, val);
81         }
82
83         /**
84          * Constructs a new StaticPaymentOutputDescriptor given each field
85          */
86         public static StaticPaymentOutputDescriptor of(OutPoint outpoint_arg, TxOut output_arg, byte[] channel_keys_id_arg, long channel_value_satoshis_arg) {
87                 long ret = bindings.StaticPaymentOutputDescriptor_new(outpoint_arg == null ? 0 : outpoint_arg.ptr & ~1, output_arg.ptr, channel_keys_id_arg, channel_value_satoshis_arg);
88                 if (ret < 1024) { return null; }
89                 StaticPaymentOutputDescriptor ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret);
90                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
91                 ret_hu_conv.ptrs_to.add(outpoint_arg);
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Creates a copy of the StaticPaymentOutputDescriptor
97          */
98         public StaticPaymentOutputDescriptor clone() {
99                 long ret = bindings.StaticPaymentOutputDescriptor_clone(this.ptr);
100                 if (ret < 1024) { return null; }
101                 StaticPaymentOutputDescriptor ret_hu_conv = new StaticPaymentOutputDescriptor(null, ret);
102                 ret_hu_conv.ptrs_to.add(this);
103                 return ret_hu_conv;
104         }
105
106         /**
107          * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read
108          */
109         public byte[] write() {
110                 byte[] ret = bindings.StaticPaymentOutputDescriptor_write(this.ptr);
111                 return ret;
112         }
113
114         /**
115          * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write
116          */
117         public static Result_StaticPaymentOutputDescriptorDecodeErrorZ read(byte[] ser) {
118                 long ret = bindings.StaticPaymentOutputDescriptor_read(ser);
119                 if (ret < 1024) { return null; }
120                 Result_StaticPaymentOutputDescriptorDecodeErrorZ ret_hu_conv = Result_StaticPaymentOutputDescriptorDecodeErrorZ.constr_from_ptr(ret);
121                 return ret_hu_conv;
122         }
123
124 }