bb45b88bff8f30be0d4b8e3a395f0da9781a2893
[ldk-java] / src / main / java / org / ldk / structs / FundingCreated.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  * A funding_created message to be sent or received from a peer
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class FundingCreated extends CommonBase {
16         FundingCreated(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.FundingCreated_free(ptr); }
21         }
22
23         /**
24          * A temporary channel ID, until the funding is established
25          */
26         public byte[] get_temporary_channel_id() {
27                 byte[] ret = bindings.FundingCreated_get_temporary_channel_id(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * A temporary channel ID, until the funding is established
34          */
35         public void set_temporary_channel_id(byte[] val) {
36                 bindings.FundingCreated_set_temporary_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The funding transaction ID
43          */
44         public byte[] get_funding_txid() {
45                 byte[] ret = bindings.FundingCreated_get_funding_txid(this.ptr);
46                 Reference.reachabilityFence(this);
47                 return ret;
48         }
49
50         /**
51          * The funding transaction ID
52          */
53         public void set_funding_txid(byte[] val) {
54                 bindings.FundingCreated_set_funding_txid(this.ptr, InternalUtils.check_arr_len(val, 32));
55                 Reference.reachabilityFence(this);
56                 Reference.reachabilityFence(val);
57         }
58
59         /**
60          * The specific output index funding this channel
61          */
62         public short get_funding_output_index() {
63                 short ret = bindings.FundingCreated_get_funding_output_index(this.ptr);
64                 Reference.reachabilityFence(this);
65                 return ret;
66         }
67
68         /**
69          * The specific output index funding this channel
70          */
71         public void set_funding_output_index(short val) {
72                 bindings.FundingCreated_set_funding_output_index(this.ptr, val);
73                 Reference.reachabilityFence(this);
74                 Reference.reachabilityFence(val);
75         }
76
77         /**
78          * The signature of the channel initiator (funder) on the initial commitment transaction
79          */
80         public byte[] get_signature() {
81                 byte[] ret = bindings.FundingCreated_get_signature(this.ptr);
82                 Reference.reachabilityFence(this);
83                 return ret;
84         }
85
86         /**
87          * The signature of the channel initiator (funder) on the initial commitment transaction
88          */
89         public void set_signature(byte[] val) {
90                 bindings.FundingCreated_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
91                 Reference.reachabilityFence(this);
92                 Reference.reachabilityFence(val);
93         }
94
95         /**
96          * Constructs a new FundingCreated given each field
97          */
98         public static FundingCreated of(byte[] temporary_channel_id_arg, byte[] funding_txid_arg, short funding_output_index_arg, byte[] signature_arg) {
99                 long ret = bindings.FundingCreated_new(InternalUtils.check_arr_len(temporary_channel_id_arg, 32), InternalUtils.check_arr_len(funding_txid_arg, 32), funding_output_index_arg, InternalUtils.check_arr_len(signature_arg, 64));
100                 Reference.reachabilityFence(temporary_channel_id_arg);
101                 Reference.reachabilityFence(funding_txid_arg);
102                 Reference.reachabilityFence(funding_output_index_arg);
103                 Reference.reachabilityFence(signature_arg);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 org.ldk.structs.FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingCreated(null, ret); }
106                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
107                 return ret_hu_conv;
108         }
109
110         long clone_ptr() {
111                 long ret = bindings.FundingCreated_clone_ptr(this.ptr);
112                 Reference.reachabilityFence(this);
113                 return ret;
114         }
115
116         /**
117          * Creates a copy of the FundingCreated
118          */
119         public FundingCreated clone() {
120                 long ret = bindings.FundingCreated_clone(this.ptr);
121                 Reference.reachabilityFence(this);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 org.ldk.structs.FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingCreated(null, ret); }
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
125                 return ret_hu_conv;
126         }
127
128         /**
129          * Checks if two FundingCreateds contain equal inner contents.
130          * This ignores pointers and is_owned flags and looks at the values in fields.
131          * Two objects with NULL inner values will be considered "equal" here.
132          */
133         public boolean eq(FundingCreated b) {
134                 boolean ret = bindings.FundingCreated_eq(this.ptr, b == null ? 0 : b.ptr);
135                 Reference.reachabilityFence(this);
136                 Reference.reachabilityFence(b);
137                 if (this != null) { this.ptrs_to.add(b); };
138                 return ret;
139         }
140
141         @Override public boolean equals(Object o) {
142                 if (!(o instanceof FundingCreated)) return false;
143                 return this.eq((FundingCreated)o);
144         }
145         /**
146          * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
147          */
148         public byte[] write() {
149                 byte[] ret = bindings.FundingCreated_write(this.ptr);
150                 Reference.reachabilityFence(this);
151                 return ret;
152         }
153
154         /**
155          * Read a FundingCreated from a byte array, created by FundingCreated_write
156          */
157         public static Result_FundingCreatedDecodeErrorZ read(byte[] ser) {
158                 long ret = bindings.FundingCreated_read(ser);
159                 Reference.reachabilityFence(ser);
160                 if (ret >= 0 && ret <= 4096) { return null; }
161                 Result_FundingCreatedDecodeErrorZ ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);
162                 return ret_hu_conv;
163         }
164
165 }