Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / OutPoint.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * A reference to a transaction output.
12  * 
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.
15  */
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 {
21                 super.finalize();
22                 if (ptr != 0) { bindings.OutPoint_free(ptr); }
23         }
24
25         /**
26          * The referenced transaction's txid.
27          */
28         public byte[] get_txid() {
29                 byte[] ret = bindings.OutPoint_get_txid(this.ptr);
30                 return ret;
31         }
32
33         /**
34          * The referenced transaction's txid.
35          */
36         public void set_txid(byte[] val) {
37                 bindings.OutPoint_set_txid(this.ptr, InternalUtils.check_arr_len(val, 32));
38         }
39
40         /**
41          * The index of the referenced output in its transaction's vout.
42          */
43         public short get_index() {
44                 short ret = bindings.OutPoint_get_index(this.ptr);
45                 return ret;
46         }
47
48         /**
49          * The index of the referenced output in its transaction's vout.
50          */
51         public void set_index(short val) {
52                 bindings.OutPoint_set_index(this.ptr, val);
53         }
54
55         /**
56          * Constructs a new OutPoint given each field
57          */
58         public static OutPoint of(byte[] txid_arg, short index_arg) {
59                 long ret = bindings.OutPoint_new(InternalUtils.check_arr_len(txid_arg, 32), index_arg);
60                 if (ret >= 0 && ret <= 4096) { return null; }
61                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
62                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
63                 return ret_hu_conv;
64         }
65
66         long clone_ptr() {
67                 long ret = bindings.OutPoint_clone_ptr(this.ptr);
68                 return ret;
69         }
70
71         /**
72          * Creates a copy of the OutPoint
73          */
74         public OutPoint clone() {
75                 long ret = bindings.OutPoint_clone(this.ptr);
76                 if (ret >= 0 && ret <= 4096) { return null; }
77                 OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new OutPoint(null, ret); }
78                 ret_hu_conv.ptrs_to.add(this);
79                 return ret_hu_conv;
80         }
81
82         /**
83          * Checks if two OutPoints contain equal inner contents.
84          * This ignores pointers and is_owned flags and looks at the values in fields.
85          * Two objects with NULL inner values will be considered "equal" here.
86          */
87         public boolean eq(OutPoint b) {
88                 boolean ret = bindings.OutPoint_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
89                 this.ptrs_to.add(b);
90                 return ret;
91         }
92
93         /**
94          * Checks if two OutPoints contain equal inner contents.
95          */
96         public long hash() {
97                 long ret = bindings.OutPoint_hash(this.ptr);
98                 return ret;
99         }
100
101         /**
102          * Convert an `OutPoint` to a lightning channel id.
103          */
104         public byte[] to_channel_id() {
105                 byte[] ret = bindings.OutPoint_to_channel_id(this.ptr);
106                 return ret;
107         }
108
109         /**
110          * Serialize the OutPoint object into a byte array which can be read by OutPoint_read
111          */
112         public byte[] write() {
113                 byte[] ret = bindings.OutPoint_write(this.ptr);
114                 return ret;
115         }
116
117         /**
118          * Read a OutPoint from a byte array, created by OutPoint_write
119          */
120         public static Result_OutPointDecodeErrorZ read(byte[] ser) {
121                 long ret = bindings.OutPoint_read(ser);
122                 if (ret >= 0 && ret <= 4096) { return null; }
123                 Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
124                 return ret_hu_conv;
125         }
126
127 }