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 * An stfu (quiescence) message to be sent by or received from the stfu initiator.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class Stfu extends CommonBase {
16 Stfu(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.Stfu_free(ptr); }
24 * The channel ID where quiescence is intended
26 public byte[] get_channel_id() {
27 byte[] ret = bindings.Stfu_get_channel_id(this.ptr);
28 Reference.reachabilityFence(this);
33 * The channel ID where quiescence is intended
35 public void set_channel_id(byte[] val) {
36 bindings.Stfu_set_channel_id(this.ptr, InternalUtils.check_arr_len(val, 32));
37 Reference.reachabilityFence(this);
38 Reference.reachabilityFence(val);
42 * Initiator flag, 1 if initiating, 0 if replying to an stfu.
44 public byte get_initiator() {
45 byte ret = bindings.Stfu_get_initiator(this.ptr);
46 Reference.reachabilityFence(this);
51 * Initiator flag, 1 if initiating, 0 if replying to an stfu.
53 public void set_initiator(byte val) {
54 bindings.Stfu_set_initiator(this.ptr, val);
55 Reference.reachabilityFence(this);
56 Reference.reachabilityFence(val);
60 * Constructs a new Stfu given each field
62 public static Stfu of(byte[] channel_id_arg, byte initiator_arg) {
63 long ret = bindings.Stfu_new(InternalUtils.check_arr_len(channel_id_arg, 32), initiator_arg);
64 Reference.reachabilityFence(channel_id_arg);
65 Reference.reachabilityFence(initiator_arg);
66 if (ret >= 0 && ret <= 4096) { return null; }
67 org.ldk.structs.Stfu ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Stfu(null, ret); }
68 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
73 long ret = bindings.Stfu_clone_ptr(this.ptr);
74 Reference.reachabilityFence(this);
79 * Creates a copy of the Stfu
82 long ret = bindings.Stfu_clone(this.ptr);
83 Reference.reachabilityFence(this);
84 if (ret >= 0 && ret <= 4096) { return null; }
85 org.ldk.structs.Stfu ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Stfu(null, ret); }
86 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
91 * Checks if two Stfus contain equal inner contents.
92 * This ignores pointers and is_owned flags and looks at the values in fields.
93 * Two objects with NULL inner values will be considered "equal" here.
95 public boolean eq(org.ldk.structs.Stfu b) {
96 boolean ret = bindings.Stfu_eq(this.ptr, b == null ? 0 : b.ptr);
97 Reference.reachabilityFence(this);
98 Reference.reachabilityFence(b);
99 if (this != null) { this.ptrs_to.add(b); };
103 @Override public boolean equals(Object o) {
104 if (!(o instanceof Stfu)) return false;
105 return this.eq((Stfu)o);
108 * Serialize the Stfu object into a byte array which can be read by Stfu_read
110 public byte[] write() {
111 byte[] ret = bindings.Stfu_write(this.ptr);
112 Reference.reachabilityFence(this);
117 * Read a Stfu from a byte array, created by Stfu_write
119 public static Result_StfuDecodeErrorZ read(byte[] ser) {
120 long ret = bindings.Stfu_read(ser);
121 Reference.reachabilityFence(ser);
122 if (ret >= 0 && ret <= 4096) { return null; }
123 Result_StfuDecodeErrorZ ret_hu_conv = Result_StfuDecodeErrorZ.constr_from_ptr(ret);