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 wrapper for a `Transaction` which can only be constructed with [`TransactionU16LenLimited::new`]
13 * if the `Transaction`'s consensus-serialized length is <= u16::MAX.
15 * Use [`TransactionU16LenLimited::into_transaction`] to convert into the contained `Transaction`.
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class TransactionU16LenLimited extends CommonBase {
19 TransactionU16LenLimited(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.TransactionU16LenLimited_free(ptr); }
27 long ret = bindings.TransactionU16LenLimited_clone_ptr(this.ptr);
28 Reference.reachabilityFence(this);
33 * Creates a copy of the TransactionU16LenLimited
35 public TransactionU16LenLimited clone() {
36 long ret = bindings.TransactionU16LenLimited_clone(this.ptr);
37 Reference.reachabilityFence(this);
38 if (ret >= 0 && ret <= 4096) { return null; }
39 org.ldk.structs.TransactionU16LenLimited ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TransactionU16LenLimited(null, ret); }
40 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
45 * Checks if two TransactionU16LenLimiteds contain equal inner contents.
46 * This ignores pointers and is_owned flags and looks at the values in fields.
47 * Two objects with NULL inner values will be considered "equal" here.
49 public boolean eq(org.ldk.structs.TransactionU16LenLimited b) {
50 boolean ret = bindings.TransactionU16LenLimited_eq(this.ptr, b == null ? 0 : b.ptr);
51 Reference.reachabilityFence(this);
52 Reference.reachabilityFence(b);
53 if (this != null) { this.ptrs_to.add(b); };
57 @Override public boolean equals(Object o) {
58 if (!(o instanceof TransactionU16LenLimited)) return false;
59 return this.eq((TransactionU16LenLimited)o);
62 * Constructs a new `TransactionU16LenLimited` from a `Transaction` only if it's consensus-
63 * serialized length is <= u16::MAX.
65 public static Result_TransactionU16LenLimitedNoneZ of(byte[] transaction) {
66 long ret = bindings.TransactionU16LenLimited_new(transaction);
67 Reference.reachabilityFence(transaction);
68 if (ret >= 0 && ret <= 4096) { return null; }
69 Result_TransactionU16LenLimitedNoneZ ret_hu_conv = Result_TransactionU16LenLimitedNoneZ.constr_from_ptr(ret);
74 * Consumes this `TransactionU16LenLimited` and returns its contained `Transaction`.
76 public byte[] into_transaction() {
77 byte[] ret = bindings.TransactionU16LenLimited_into_transaction(this.ptr);
78 Reference.reachabilityFence(this);
79 if (this != null) { this.ptrs_to.add(this); };
84 * Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read
86 public byte[] write() {
87 byte[] ret = bindings.TransactionU16LenLimited_write(this.ptr);
88 Reference.reachabilityFence(this);
93 * Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write
95 public static Result_TransactionU16LenLimitedDecodeErrorZ read(byte[] ser) {
96 long ret = bindings.TransactionU16LenLimited_read(ser);
97 Reference.reachabilityFence(ser);
98 if (ret >= 0 && ret <= 4096) { return null; }
99 Result_TransactionU16LenLimitedDecodeErrorZ ret_hu_conv = Result_TransactionU16LenLimitedDecodeErrorZ.constr_from_ptr(ret);