1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A [`funding_created`] message to be sent to or received from a peer.
14 * Used in V1 channel establishment
16 * [`funding_created`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_created-message
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 {
24 if (ptr != 0) { bindings.FundingCreated_free(ptr); }
28 * A temporary channel ID, until the funding is established
30 public ChannelId get_temporary_channel_id() {
31 long ret = bindings.FundingCreated_get_temporary_channel_id(this.ptr);
32 Reference.reachabilityFence(this);
33 if (ret >= 0 && ret <= 4096) { return null; }
34 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
35 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
40 * A temporary channel ID, until the funding is established
42 public void set_temporary_channel_id(org.ldk.structs.ChannelId val) {
43 bindings.FundingCreated_set_temporary_channel_id(this.ptr, val.ptr);
44 Reference.reachabilityFence(this);
45 Reference.reachabilityFence(val);
46 if (this != null) { this.ptrs_to.add(val); };
50 * The funding transaction ID
52 public byte[] get_funding_txid() {
53 byte[] ret = bindings.FundingCreated_get_funding_txid(this.ptr);
54 Reference.reachabilityFence(this);
59 * The funding transaction ID
61 public void set_funding_txid(byte[] val) {
62 bindings.FundingCreated_set_funding_txid(this.ptr, InternalUtils.check_arr_len(val, 32));
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(val);
68 * The specific output index funding this channel
70 public short get_funding_output_index() {
71 short ret = bindings.FundingCreated_get_funding_output_index(this.ptr);
72 Reference.reachabilityFence(this);
77 * The specific output index funding this channel
79 public void set_funding_output_index(short val) {
80 bindings.FundingCreated_set_funding_output_index(this.ptr, val);
81 Reference.reachabilityFence(this);
82 Reference.reachabilityFence(val);
86 * The signature of the channel initiator (funder) on the initial commitment transaction
88 public byte[] get_signature() {
89 byte[] ret = bindings.FundingCreated_get_signature(this.ptr);
90 Reference.reachabilityFence(this);
95 * The signature of the channel initiator (funder) on the initial commitment transaction
97 public void set_signature(byte[] val) {
98 bindings.FundingCreated_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
99 Reference.reachabilityFence(this);
100 Reference.reachabilityFence(val);
104 * Constructs a new FundingCreated given each field
106 public static FundingCreated of(org.ldk.structs.ChannelId temporary_channel_id_arg, byte[] funding_txid_arg, short funding_output_index_arg, byte[] signature_arg) {
107 long ret = bindings.FundingCreated_new(temporary_channel_id_arg.ptr, InternalUtils.check_arr_len(funding_txid_arg, 32), funding_output_index_arg, InternalUtils.check_arr_len(signature_arg, 64));
108 Reference.reachabilityFence(temporary_channel_id_arg);
109 Reference.reachabilityFence(funding_txid_arg);
110 Reference.reachabilityFence(funding_output_index_arg);
111 Reference.reachabilityFence(signature_arg);
112 if (ret >= 0 && ret <= 4096) { return null; }
113 org.ldk.structs.FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingCreated(null, ret); }
114 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
115 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(temporary_channel_id_arg); };
120 long ret = bindings.FundingCreated_clone_ptr(this.ptr);
121 Reference.reachabilityFence(this);
126 * Creates a copy of the FundingCreated
128 public FundingCreated clone() {
129 long ret = bindings.FundingCreated_clone(this.ptr);
130 Reference.reachabilityFence(this);
131 if (ret >= 0 && ret <= 4096) { return null; }
132 org.ldk.structs.FundingCreated ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingCreated(null, ret); }
133 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
138 * Generates a non-cryptographic 64-bit hash of the FundingCreated.
141 long ret = bindings.FundingCreated_hash(this.ptr);
142 Reference.reachabilityFence(this);
146 @Override public int hashCode() {
147 return (int)this.hash();
150 * Checks if two FundingCreateds contain equal inner contents.
151 * This ignores pointers and is_owned flags and looks at the values in fields.
152 * Two objects with NULL inner values will be considered "equal" here.
154 public boolean eq(org.ldk.structs.FundingCreated b) {
155 boolean ret = bindings.FundingCreated_eq(this.ptr, b.ptr);
156 Reference.reachabilityFence(this);
157 Reference.reachabilityFence(b);
158 if (this != null) { this.ptrs_to.add(b); };
162 @Override public boolean equals(Object o) {
163 if (!(o instanceof FundingCreated)) return false;
164 return this.eq((FundingCreated)o);
167 * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
169 public byte[] write() {
170 byte[] ret = bindings.FundingCreated_write(this.ptr);
171 Reference.reachabilityFence(this);
176 * Read a FundingCreated from a byte array, created by FundingCreated_write
178 public static Result_FundingCreatedDecodeErrorZ read(byte[] ser) {
179 long ret = bindings.FundingCreated_read(ser);
180 Reference.reachabilityFence(ser);
181 if (ret >= 0 && ret <= 4096) { return null; }
182 Result_FundingCreatedDecodeErrorZ ret_hu_conv = Result_FundingCreatedDecodeErrorZ.constr_from_ptr(ret);