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 ChannelId get_channel_id() {
29 long ret = bindings.ClosingSigned_get_channel_id(this.ptr);
30 Reference.reachabilityFence(this);
31 if (ret >= 0 && ret <= 4096) { return null; }
32 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
33 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
40 public void set_channel_id(org.ldk.structs.ChannelId val) {
41 bindings.ClosingSigned_set_channel_id(this.ptr, val.ptr);
42 Reference.reachabilityFence(this);
43 Reference.reachabilityFence(val);
44 if (this != null) { this.ptrs_to.add(val); };
48 * The proposed total fee for the closing transaction
50 public long get_fee_satoshis() {
51 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
52 Reference.reachabilityFence(this);
57 * The proposed total fee for the closing transaction
59 public void set_fee_satoshis(long val) {
60 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
61 Reference.reachabilityFence(this);
62 Reference.reachabilityFence(val);
66 * A signature on the closing transaction
68 public byte[] get_signature() {
69 byte[] ret = bindings.ClosingSigned_get_signature(this.ptr);
70 Reference.reachabilityFence(this);
75 * A signature on the closing transaction
77 public void set_signature(byte[] val) {
78 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
79 Reference.reachabilityFence(this);
80 Reference.reachabilityFence(val);
84 * The minimum and maximum fees which the sender is willing to accept, provided only by new
87 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
90 public ClosingSignedFeeRange get_fee_range() {
91 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
92 Reference.reachabilityFence(this);
93 if (ret >= 0 && ret <= 4096) { return null; }
94 org.ldk.structs.ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSignedFeeRange(null, ret); }
95 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
100 * The minimum and maximum fees which the sender is willing to accept, provided only by new
103 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
105 public void set_fee_range(@Nullable org.ldk.structs.ClosingSignedFeeRange val) {
106 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr);
107 Reference.reachabilityFence(this);
108 Reference.reachabilityFence(val);
109 if (this != null) { this.ptrs_to.add(val); };
113 * Constructs a new ClosingSigned given each field
115 * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None
117 public static ClosingSigned of(org.ldk.structs.ChannelId channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, @Nullable org.ldk.structs.ClosingSignedFeeRange fee_range_arg) {
118 long ret = bindings.ClosingSigned_new(channel_id_arg.ptr, fee_satoshis_arg, InternalUtils.check_arr_len(signature_arg, 64), fee_range_arg == null ? 0 : fee_range_arg.ptr);
119 Reference.reachabilityFence(channel_id_arg);
120 Reference.reachabilityFence(fee_satoshis_arg);
121 Reference.reachabilityFence(signature_arg);
122 Reference.reachabilityFence(fee_range_arg);
123 if (ret >= 0 && ret <= 4096) { return null; }
124 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
125 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
126 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(channel_id_arg); };
127 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(fee_range_arg); };
132 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
133 Reference.reachabilityFence(this);
138 * Creates a copy of the ClosingSigned
140 public ClosingSigned clone() {
141 long ret = bindings.ClosingSigned_clone(this.ptr);
142 Reference.reachabilityFence(this);
143 if (ret >= 0 && ret <= 4096) { return null; }
144 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
145 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
150 * Generates a non-cryptographic 64-bit hash of the ClosingSigned.
153 long ret = bindings.ClosingSigned_hash(this.ptr);
154 Reference.reachabilityFence(this);
158 @Override public int hashCode() {
159 return (int)this.hash();
162 * Checks if two ClosingSigneds contain equal inner contents.
163 * This ignores pointers and is_owned flags and looks at the values in fields.
164 * Two objects with NULL inner values will be considered "equal" here.
166 public boolean eq(org.ldk.structs.ClosingSigned b) {
167 boolean ret = bindings.ClosingSigned_eq(this.ptr, b.ptr);
168 Reference.reachabilityFence(this);
169 Reference.reachabilityFence(b);
170 if (this != null) { this.ptrs_to.add(b); };
174 @Override public boolean equals(Object o) {
175 if (!(o instanceof ClosingSigned)) return false;
176 return this.eq((ClosingSigned)o);
179 * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
181 public byte[] write() {
182 byte[] ret = bindings.ClosingSigned_write(this.ptr);
183 Reference.reachabilityFence(this);
188 * Read a ClosingSigned from a byte array, created by ClosingSigned_write
190 public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
191 long ret = bindings.ClosingSigned_read(ser);
192 Reference.reachabilityFence(ser);
193 if (ret >= 0 && ret <= 4096) { return null; }
194 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);