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_signed`] message to be sent to or received from a peer.
14 * [`funding_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-funding_signed-message
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class FundingSigned extends CommonBase {
18 FundingSigned(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.FundingSigned_free(ptr); }
28 public byte[] get_channel_id() {
29 byte[] ret = bindings.FundingSigned_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.FundingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The signature of the channel acceptor (fundee) on the initial commitment transaction
46 public byte[] get_signature() {
47 byte[] ret = bindings.FundingSigned_get_signature(this.ptr);
48 Reference.reachabilityFence(this);
53 * The signature of the channel acceptor (fundee) on the initial commitment transaction
55 public void set_signature(byte[] val) {
56 bindings.FundingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * Constructs a new FundingSigned given each field
64 public static FundingSigned of(byte[] channel_id_arg, byte[] signature_arg) {
65 long ret = bindings.FundingSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), InternalUtils.check_arr_len(signature_arg, 64));
66 Reference.reachabilityFence(channel_id_arg);
67 Reference.reachabilityFence(signature_arg);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
75 long ret = bindings.FundingSigned_clone_ptr(this.ptr);
76 Reference.reachabilityFence(this);
81 * Creates a copy of the FundingSigned
83 public FundingSigned clone() {
84 long ret = bindings.FundingSigned_clone(this.ptr);
85 Reference.reachabilityFence(this);
86 if (ret >= 0 && ret <= 4096) { return null; }
87 org.ldk.structs.FundingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FundingSigned(null, ret); }
88 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
93 * Checks if two FundingSigneds contain equal inner contents.
94 * This ignores pointers and is_owned flags and looks at the values in fields.
95 * Two objects with NULL inner values will be considered "equal" here.
97 public boolean eq(org.ldk.structs.FundingSigned b) {
98 boolean ret = bindings.FundingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
99 Reference.reachabilityFence(this);
100 Reference.reachabilityFence(b);
101 if (this != null) { this.ptrs_to.add(b); };
105 @Override public boolean equals(Object o) {
106 if (!(o instanceof FundingSigned)) return false;
107 return this.eq((FundingSigned)o);
110 * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read
112 public byte[] write() {
113 byte[] ret = bindings.FundingSigned_write(this.ptr);
114 Reference.reachabilityFence(this);
119 * Read a FundingSigned from a byte array, created by FundingSigned_write
121 public static Result_FundingSignedDecodeErrorZ read(byte[] ser) {
122 long ret = bindings.FundingSigned_read(ser);
123 Reference.reachabilityFence(ser);
124 if (ret >= 0 && ret <= 4096) { return null; }
125 Result_FundingSignedDecodeErrorZ ret_hu_conv = Result_FundingSignedDecodeErrorZ.constr_from_ptr(ret);