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 byte[] get_temporary_channel_id() {
31 byte[] ret = bindings.FundingCreated_get_temporary_channel_id(this.ptr);
32 Reference.reachabilityFence(this);
37 * A temporary channel ID, until the funding is established
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);
46 * The funding transaction ID
48 public byte[] get_funding_txid() {
49 byte[] ret = bindings.FundingCreated_get_funding_txid(this.ptr);
50 Reference.reachabilityFence(this);
55 * The funding transaction ID
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);
64 * The specific output index funding this channel
66 public short get_funding_output_index() {
67 short ret = bindings.FundingCreated_get_funding_output_index(this.ptr);
68 Reference.reachabilityFence(this);
73 * The specific output index funding this channel
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);
82 * The signature of the channel initiator (funder) on the initial commitment transaction
84 public byte[] get_signature() {
85 byte[] ret = bindings.FundingCreated_get_signature(this.ptr);
86 Reference.reachabilityFence(this);
91 * The signature of the channel initiator (funder) on the initial commitment transaction
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);
100 * Constructs a new FundingCreated given each field
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); };
115 long ret = bindings.FundingCreated_clone_ptr(this.ptr);
116 Reference.reachabilityFence(this);
121 * Creates a copy of the FundingCreated
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); };
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.
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); };
145 @Override public boolean equals(Object o) {
146 if (!(o instanceof FundingCreated)) return false;
147 return this.eq((FundingCreated)o);
150 * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read
152 public byte[] write() {
153 byte[] ret = bindings.FundingCreated_write(this.ptr);
154 Reference.reachabilityFence(this);
159 * Read a FundingCreated from a byte array, created by FundingCreated_write
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);