1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * A reference to a transaction output.
13 * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
14 * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class OutPoint extends CommonBase {
18 OutPoint(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.OutPoint_free(ptr); }
26 * The referenced transaction's txid.
28 public byte[] get_txid() {
29 byte[] ret = bindings.OutPoint_get_txid(this.ptr);
34 * The referenced transaction's txid.
36 public void set_txid(byte[] val) {
37 bindings.OutPoint_set_txid(this.ptr, val);
41 * The index of the referenced output in its transaction's vout.
43 public short get_index() {
44 short ret = bindings.OutPoint_get_index(this.ptr);
49 * The index of the referenced output in its transaction's vout.
51 public void set_index(short val) {
52 bindings.OutPoint_set_index(this.ptr, val);
56 * Constructs a new OutPoint given each field
58 public static OutPoint of(byte[] txid_arg, short index_arg) {
59 long ret = bindings.OutPoint_new(txid_arg, index_arg);
60 if (ret < 1024) { return null; }
61 OutPoint ret_hu_conv = new OutPoint(null, ret);
62 ret_hu_conv.ptrs_to.add(ret_hu_conv);
67 * Creates a copy of the OutPoint
69 public OutPoint clone() {
70 long ret = bindings.OutPoint_clone(this.ptr);
71 if (ret < 1024) { return null; }
72 OutPoint ret_hu_conv = new OutPoint(null, ret);
73 ret_hu_conv.ptrs_to.add(this);
78 * Checks if two OutPoints contain equal inner contents.
79 * This ignores pointers and is_owned flags and looks at the values in fields.
80 * Two objects with NULL inner values will be considered "equal" here.
82 public boolean eq(OutPoint b) {
83 boolean ret = bindings.OutPoint_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
89 * Checks if two OutPoints contain equal inner contents.
92 long ret = bindings.OutPoint_hash(this.ptr);
97 * Convert an `OutPoint` to a lightning channel id.
99 public byte[] to_channel_id() {
100 byte[] ret = bindings.OutPoint_to_channel_id(this.ptr);
105 * Serialize the OutPoint object into a byte array which can be read by OutPoint_read
107 public byte[] write() {
108 byte[] ret = bindings.OutPoint_write(this.ptr);
113 * Read a OutPoint from a byte array, created by OutPoint_write
115 public static Result_OutPointDecodeErrorZ read(byte[] ser) {
116 long ret = bindings.OutPoint_read(ser);
117 if (ret < 1024) { return null; }
118 Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);