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
8
9 /**
10  * A reference to a transaction output.
11  * 
12  * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
13  * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
14  */
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class OutPoint extends CommonBase {
17         OutPoint(Object _dummy, long ptr) { super(ptr); }
18         @Override @SuppressWarnings("deprecation")
19         protected void finalize() throws Throwable {
20                 super.finalize();
21                 if (ptr != 0) { bindings.OutPoint_free(ptr); }
22         }
23
24         /**
25          * The referenced transaction's txid.
26          */
27         public byte[] get_txid() {
28                 byte[] ret = bindings.OutPoint_get_txid(this.ptr);
29                 return ret;
30         }
31
32         /**
33          * The referenced transaction's txid.
34          */
35         public void set_txid(byte[] val) {
36                 bindings.OutPoint_set_txid(this.ptr, val);
37         }
38
39         /**
40          * The index of the referenced output in its transaction's vout.
41          */
42         public short get_index() {
43                 short ret = bindings.OutPoint_get_index(this.ptr);
44                 return ret;
45         }
46
47         /**
48          * The index of the referenced output in its transaction's vout.
49          */
50         public void set_index(short val) {
51                 bindings.OutPoint_set_index(this.ptr, val);
52         }
53
54         /**
55          * Constructs a new OutPoint given each field
56          */
57         public static OutPoint of(byte[] txid_arg, short index_arg) {
58                 long ret = bindings.OutPoint_new(txid_arg, index_arg);
59                 if (ret < 1024) { return null; }
60                 OutPoint ret_hu_conv = new OutPoint(null, ret);
61                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
62                 return ret_hu_conv;
63         }
64
65         /**
66          * Creates a copy of the OutPoint
67          */
68         public OutPoint clone() {
69                 long ret = bindings.OutPoint_clone(this.ptr);
70                 if (ret < 1024) { return null; }
71                 OutPoint ret_hu_conv = new OutPoint(null, ret);
72                 ret_hu_conv.ptrs_to.add(this);
73                 return ret_hu_conv;
74         }
75
76         /**
77          * Checks if two OutPoints contain equal inner contents.
78          * This ignores pointers and is_owned flags and looks at the values in fields.
79          * Two objects with NULL inner values will be considered "equal" here.
80          */
81         public boolean eq(OutPoint b) {
82                 boolean ret = bindings.OutPoint_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
83                 this.ptrs_to.add(b);
84                 return ret;
85         }
86
87         /**
88          * Checks if two OutPoints contain equal inner contents.
89          */
90         public long hash() {
91                 long ret = bindings.OutPoint_hash(this.ptr);
92                 return ret;
93         }
94
95         /**
96          * Convert an `OutPoint` to a lightning channel id.
97          */
98         public byte[] to_channel_id() {
99                 byte[] ret = bindings.OutPoint_to_channel_id(this.ptr);
100                 return ret;
101         }
102
103         /**
104          * Serialize the OutPoint object into a byte array which can be read by OutPoint_read
105          */
106         public byte[] write() {
107                 byte[] ret = bindings.OutPoint_write(this.ptr);
108                 return ret;
109         }
110
111         /**
112          * Read a OutPoint from a byte array, created by OutPoint_write
113          */
114         public static Result_OutPointDecodeErrorZ read(byte[] ser) {
115                 long ret = bindings.OutPoint_read(ser);
116                 if (ret < 1024) { return null; }
117                 Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
118                 return ret_hu_conv;
119         }
120
121 }