[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / FundingSigned.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_signed`] message to be sent to or received from a peer.
13  * 
14  * Used in V1 channel establishment
15  * 
16  * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
17  */
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class FundingSigned extends CommonBase {
20         FundingSigned(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.FundingSigned_free(ptr); }
25         }
26
27         /**
28          * The channel ID
29          */
30         public byte[] get_channel_id() {
31                 byte[] ret = bindings.FundingSigned_get_channel_id(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * The channel ID
38          */
39         public void set_channel_id(byte[] val) {
40                 bindings.FundingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
41                 Reference.reachabilityFence(this);
42                 Reference.reachabilityFence(val);
43         }
44
45         /**
46          * The signature of the channel acceptor (fundee) on the initial commitment transaction
47          */
48         public byte[] get_signature() {
49                 byte[] ret = bindings.FundingSigned_get_signature(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * The signature of the channel acceptor (fundee) on the initial commitment transaction
56          */
57         public void set_signature(byte[] val) {
58                 bindings.FundingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
59                 Reference.reachabilityFence(this);
60                 Reference.reachabilityFence(val);
61         }
62
63         /**
64          * Constructs a new FundingSigned given each field
65          */
66         public static FundingSigned of(byte[] channel_id_arg, byte[] signature_arg) {
67                 long ret = bindings.FundingSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(signature_arg, 64));
68                 Reference.reachabilityFence(channel_id_arg);
69                 Reference.reachabilityFence(signature_arg);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
72                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
73                 return ret_hu_conv;
74         }
75
76         long clone_ptr() {
77                 long ret = bindings.FundingSigned_clone_ptr(this.ptr);
78                 Reference.reachabilityFence(this);
79                 return ret;
80         }
81
82         /**
83          * Creates a copy of the FundingSigned
84          */
85         public FundingSigned clone() {
86                 long ret = bindings.FundingSigned_clone(this.ptr);
87                 Reference.reachabilityFence(this);
88                 if (ret >= 0 && ret <= 4096) { return null; }
89                 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
90                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
91                 return ret_hu_conv;
92         }
93
94         /**
95          * Generates a non-cryptographic 64-bit hash of the FundingSigned.
96          */
97         public long hash() {
98                 long ret = bindings.FundingSigned_hash(this.ptr);
99                 Reference.reachabilityFence(this);
100                 return ret;
101         }
102
103         @Override public int hashCode() {
104                 return (int)this.hash();
105         }
106         /**
107          * Checks if two FundingSigneds contain equal inner contents.
108          * This ignores pointers and is_owned flags and looks at the values in fields.
109          * Two objects with NULL inner values will be considered "equal" here.
110          */
111         public boolean eq(org.ldk.structs.FundingSigned b) {
112                 boolean ret = bindings.FundingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
113                 Reference.reachabilityFence(this);
114                 Reference.reachabilityFence(b);
115                 if (this != null) { this.ptrs_to.add(b); };
116                 return ret;
117         }
118
119         @Override public boolean equals(Object o) {
120                 if (!(o instanceof FundingSigned)) return false;
121                 return this.eq((FundingSigned)o);
122         }
123         /**
124          * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
125          */
126         public byte[] write() {
127                 byte[] ret = bindings.FundingSigned_write(this.ptr);
128                 Reference.reachabilityFence(this);
129                 return ret;
130         }
131
132         /**
133          * Read a FundingSigned from a byte array, created by FundingSigned_write
134          */
135         public static Result_FundingSignedDecodeErrorZ read(byte[] ser) {
136                 long ret = bindings.FundingSigned_read(ser);
137                 Reference.reachabilityFence(ser);
138                 if (ret >= 0 && ret <= 4096) { return null; }
139                 Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);
140                 return ret_hu_conv;
141         }
142
143 }