Merge pull request #56 from TheBlueMatt/main
[ldk-java] / src / main / java / org / ldk / structs / FundingLocked.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  * A funding_locked message to be sent or received from a peer
12  */
13 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
14 public class FundingLocked extends CommonBase {
15         FundingLocked(Object _dummy, long ptr) { super(ptr); }
16         @Override @SuppressWarnings("deprecation")
17         protected void finalize() throws Throwable {
18                 super.finalize();
19                 if (ptr != 0) { bindings.FundingLocked_free(ptr); }
20         }
21
22         /**
23          * The channel ID
24          */
25         public byte[] get_channel_id() {
26                 byte[] ret = bindings.FundingLocked_get_channel_id(this.ptr);
27                 return ret;
28         }
29
30         /**
31          * The channel ID
32          */
33         public void set_channel_id(byte[] val) {
34                 bindings.FundingLocked_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
35         }
36
37         /**
38          * The per-commitment point of the second commitment transaction
39          */
40         public byte[] get_next_per_commitment_point() {
41                 byte[] ret = bindings.FundingLocked_get_next_per_commitment_point(this.ptr);
42                 return ret;
43         }
44
45         /**
46          * The per-commitment point of the second commitment transaction
47          */
48         public void set_next_per_commitment_point(byte[] val) {
49                 bindings.FundingLocked_set_next_per_commitment_point(this.ptr, InternalUtils.check_arr_len(val, 33));
50         }
51
52         /**
53          * Constructs a new FundingLocked given each field
54          */
55         public static FundingLocked of(byte[] channel_id_arg, byte[] next_per_commitment_point_arg) {
56                 long ret = bindings.FundingLocked_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(next_per_commitment_point_arg, 33));
57                 if (ret >= 0 && ret <= 4096) { return null; }
58                 FundingLocked ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingLocked(null, ret); }
59                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
60                 return ret_hu_conv;
61         }
62
63         long clone_ptr() {
64                 long ret = bindings.FundingLocked_clone_ptr(this.ptr);
65                 return ret;
66         }
67
68         /**
69          * Creates a copy of the FundingLocked
70          */
71         public FundingLocked clone() {
72                 long ret = bindings.FundingLocked_clone(this.ptr);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 FundingLocked ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FundingLocked(null, ret); }
75                 ret_hu_conv.ptrs_to.add(this);
76                 return ret_hu_conv;
77         }
78
79         /**
80          * Serialize the FundingLocked object into a byte array which can be read by FundingLocked_read
81          */
82         public byte[] write() {
83                 byte[] ret = bindings.FundingLocked_write(this.ptr);
84                 return ret;
85         }
86
87         /**
88          * Read a FundingLocked from a byte array, created by FundingLocked_write
89          */
90         public static Result_FundingLockedDecodeErrorZ read(byte[] ser) {
91                 long ret = bindings.FundingLocked_read(ser);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 Result_FundingLockedDecodeErrorZ ret_hu_conv = Result_FundingLockedDecodeErrorZ.constr_from_ptr(ret);
94                 return ret_hu_conv;
95         }
96
97 }