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 [`closing_signed`] message to be sent to or received from a peer.
14 * [`closing_signed`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-negotiation-closing_signed
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class ClosingSigned extends CommonBase {
18 ClosingSigned(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.ClosingSigned_free(ptr); }
28 public byte[] get_channel_id() {
29 byte[] ret = bindings.ClosingSigned_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
37 public void set_channel_id(byte[] val) {
38 bindings.ClosingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
39 Reference.reachabilityFence(this);
40 Reference.reachabilityFence(val);
44 * The proposed total fee for the closing transaction
46 public long get_fee_satoshis() {
47 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
48 Reference.reachabilityFence(this);
53 * The proposed total fee for the closing transaction
55 public void set_fee_satoshis(long val) {
56 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
57 Reference.reachabilityFence(this);
58 Reference.reachabilityFence(val);
62 * A signature on the closing transaction
64 public byte[] get_signature() {
65 byte[] ret = bindings.ClosingSigned_get_signature(this.ptr);
66 Reference.reachabilityFence(this);
71 * A signature on the closing transaction
73 public void set_signature(byte[] val) {
74 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(val);
80 * The minimum and maximum fees which the sender is willing to accept, provided only by new
83 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
86 public ClosingSignedFeeRange get_fee_range() {
87 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
88 Reference.reachabilityFence(this);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSignedFeeRange(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
96 * The minimum and maximum fees which the sender is willing to accept, provided only by new
99 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
101 public void set_fee_range(@Nullable org.ldk.structs.ClosingSignedFeeRange val) {
102 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr);
103 Reference.reachabilityFence(this);
104 Reference.reachabilityFence(val);
105 if (this != null) { this.ptrs_to.add(val); };
109 * Constructs a new ClosingSigned given each field
111 public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, org.ldk.structs.ClosingSignedFeeRange fee_range_arg) {
112 long ret = bindings.ClosingSigned_new(InternalUtils.check_arr_len(channel_id_arg, 32), fee_satoshis_arg, InternalUtils.check_arr_len(signature_arg, 64), fee_range_arg == null ? 0 : fee_range_arg.ptr);
113 Reference.reachabilityFence(channel_id_arg);
114 Reference.reachabilityFence(fee_satoshis_arg);
115 Reference.reachabilityFence(signature_arg);
116 Reference.reachabilityFence(fee_range_arg);
117 if (ret >= 0 && ret <= 4096) { return null; }
118 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
119 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
120 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_range_arg); };
125 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
126 Reference.reachabilityFence(this);
131 * Creates a copy of the ClosingSigned
133 public ClosingSigned clone() {
134 long ret = bindings.ClosingSigned_clone(this.ptr);
135 Reference.reachabilityFence(this);
136 if (ret >= 0 && ret <= 4096) { return null; }
137 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
138 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
143 * Checks if two ClosingSigneds contain equal inner contents.
144 * This ignores pointers and is_owned flags and looks at the values in fields.
145 * Two objects with NULL inner values will be considered "equal" here.
147 public boolean eq(org.ldk.structs.ClosingSigned b) {
148 boolean ret = bindings.ClosingSigned_eq(this.ptr, b == null ? 0 : b.ptr);
149 Reference.reachabilityFence(this);
150 Reference.reachabilityFence(b);
151 if (this != null) { this.ptrs_to.add(b); };
155 @Override public boolean equals(Object o) {
156 if (!(o instanceof ClosingSigned)) return false;
157 return this.eq((ClosingSigned)o);
160 * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
162 public byte[] write() {
163 byte[] ret = bindings.ClosingSigned_write(this.ptr);
164 Reference.reachabilityFence(this);
169 * Read a ClosingSigned from a byte array, created by ClosingSigned_write
171 public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
172 long ret = bindings.ClosingSigned_read(ser);
173 Reference.reachabilityFence(ser);
174 if (ret >= 0 && ret <= 4096) { return null; }
175 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);