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