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 or received from a peer
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ClosingSigned extends CommonBase {
16 ClosingSigned(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.ClosingSigned_free(ptr); }
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.ClosingSigned_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
35 public void set_channel_id(byte[] val) {
36 bindings.ClosingSigned_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * The proposed total fee for the closing transaction
44 public long get_fee_satoshis() {
45 long ret = bindings.ClosingSigned_get_fee_satoshis(this.ptr);
46 Reference.reachabilityFence(this);
51 * The proposed total fee for the closing transaction
53 public void set_fee_satoshis(long val) {
54 bindings.ClosingSigned_set_fee_satoshis(this.ptr, val);
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * A signature on the closing transaction
62 public byte[] get_signature() {
63 byte[] ret = bindings.ClosingSigned_get_signature(this.ptr);
64 Reference.reachabilityFence(this);
69 * A signature on the closing transaction
71 public void set_signature(byte[] val) {
72 bindings.ClosingSigned_set_signature(this.ptr, InternalUtils.check_arr_len(val, 64));
73 Reference.reachabilityFence(this);
74 Reference.reachabilityFence(val);
78 * The minimum and maximum fees which the sender is willing to accept, provided only by new
81 * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
84 public ClosingSignedFeeRange get_fee_range() {
85 long ret = bindings.ClosingSigned_get_fee_range(this.ptr);
86 Reference.reachabilityFence(this);
87 if (ret >= 0 && ret <= 4096) { return null; }
88 org.ldk.structs.ClosingSignedFeeRange ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSignedFeeRange(null, ret); }
89 ret_hu_conv.ptrs_to.add(this);
94 * The minimum and maximum fees which the sender is willing to accept, provided only by new
97 * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None
99 public void set_fee_range(@Nullable ClosingSignedFeeRange val) {
100 bindings.ClosingSigned_set_fee_range(this.ptr, val == null ? 0 : val.ptr & ~1);
101 Reference.reachabilityFence(this);
102 Reference.reachabilityFence(val);
106 * Constructs a new ClosingSigned given each field
108 public static ClosingSigned of(byte[] channel_id_arg, long fee_satoshis_arg, byte[] signature_arg, ClosingSignedFeeRange fee_range_arg) {
109 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 & ~1);
110 Reference.reachabilityFence(channel_id_arg);
111 Reference.reachabilityFence(fee_satoshis_arg);
112 Reference.reachabilityFence(signature_arg);
113 Reference.reachabilityFence(fee_range_arg);
114 if (ret >= 0 && ret <= 4096) { return null; }
115 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
116 ret_hu_conv.ptrs_to.add(ret_hu_conv);
121 long ret = bindings.ClosingSigned_clone_ptr(this.ptr);
122 Reference.reachabilityFence(this);
127 * Creates a copy of the ClosingSigned
129 public ClosingSigned clone() {
130 long ret = bindings.ClosingSigned_clone(this.ptr);
131 Reference.reachabilityFence(this);
132 if (ret >= 0 && ret <= 4096) { return null; }
133 org.ldk.structs.ClosingSigned ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingSigned(null, ret); }
134 ret_hu_conv.ptrs_to.add(this);
139 * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read
141 public byte[] write() {
142 byte[] ret = bindings.ClosingSigned_write(this.ptr);
143 Reference.reachabilityFence(this);
148 * Read a ClosingSigned from a byte array, created by ClosingSigned_write
150 public static Result_ClosingSignedDecodeErrorZ read(byte[] ser) {
151 long ret = bindings.ClosingSigned_read(ser);
152 Reference.reachabilityFence(ser);
153 if (ret >= 0 && ret <= 4096) { return null; }
154 Result_ClosingSignedDecodeErrorZ ret_hu_conv = Result_ClosingSignedDecodeErrorZ.constr_from_ptr(ret);