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 * Generates a non-cryptographic 64-bit hash of the TransactionU16LenLimited.
48 long ret = bindings.TransactionU16LenLimited_hash(this.ptr);
49 Reference.reachabilityFence(this);
53 @Override public int hashCode() {
54 return (int)this.hash();
57 * Checks if two TransactionU16LenLimiteds contain equal inner contents.
58 * This ignores pointers and is_owned flags and looks at the values in fields.
59 * Two objects with NULL inner values will be considered "equal" here.
61 public boolean eq(org.ldk.structs.TransactionU16LenLimited b) {
62 boolean ret = bindings.TransactionU16LenLimited_eq(this.ptr, b.ptr);
63 Reference.reachabilityFence(this);
64 Reference.reachabilityFence(b);
65 if (this != null) { this.ptrs_to.add(b); };
69 @Override public boolean equals(Object o) {
70 if (!(o instanceof TransactionU16LenLimited)) return false;
71 return this.eq((TransactionU16LenLimited)o);
74 * Constructs a new `TransactionU16LenLimited` from a `Transaction` only if it's consensus-
75 * serialized length is <= u16::MAX.
77 public static Result_TransactionU16LenLimitedNoneZ of(byte[] transaction) {
78 long ret = bindings.TransactionU16LenLimited_new(transaction);
79 Reference.reachabilityFence(transaction);
80 if (ret >= 0 && ret <= 4096) { return null; }
81 Result_TransactionU16LenLimitedNoneZ ret_hu_conv = Result_TransactionU16LenLimitedNoneZ.constr_from_ptr(ret);
86 * Consumes this `TransactionU16LenLimited` and returns its contained `Transaction`.
88 public byte[] into_transaction() {
89 byte[] ret = bindings.TransactionU16LenLimited_into_transaction(this.ptr);
90 Reference.reachabilityFence(this);
91 if (this != null) { this.ptrs_to.add(this); };
96 * Returns a reference to the contained `Transaction`
98 public byte[] as_transaction() {
99 byte[] ret = bindings.TransactionU16LenLimited_as_transaction(this.ptr);
100 Reference.reachabilityFence(this);
105 * Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read
107 public byte[] write() {
108 byte[] ret = bindings.TransactionU16LenLimited_write(this.ptr);
109 Reference.reachabilityFence(this);
114 * Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write
116 public static Result_TransactionU16LenLimitedDecodeErrorZ read(byte[] ser) {
117 long ret = bindings.TransactionU16LenLimited_read(ser);
118 Reference.reachabilityFence(ser);
119 if (ret >= 0 && ret <= 4096) { return null; }
120 Result_TransactionU16LenLimitedDecodeErrorZ ret_hu_conv = Result_TransactionU16LenLimitedDecodeErrorZ.constr_from_ptr(ret);