[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / OutPoint.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
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 public class OutPoint : CommonBase {
16         internal OutPoint(object _dummy, long ptr) : base(ptr) { }
17         ~OutPoint() {
18                 if (ptr != 0) { bindings.OutPoint_free(ptr); }
19         }
20
21         /**
22          * The referenced transaction's txid.
23          */
24         public byte[] get_txid() {
25                 long ret = bindings.OutPoint_get_txid(this.ptr);
26                 GC.KeepAlive(this);
27                 if (ret >= 0 && ret <= 4096) { return null; }
28                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
29                 return ret_conv;
30         }
31
32         /**
33          * The referenced transaction's txid.
34          */
35         public void set_txid(byte[] val) {
36                 bindings.OutPoint_set_txid(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
37                 GC.KeepAlive(this);
38                 GC.KeepAlive(val);
39         }
40
41         /**
42          * The index of the referenced output in its transaction's vout.
43          */
44         public short get_index() {
45                 short ret = bindings.OutPoint_get_index(this.ptr);
46                 GC.KeepAlive(this);
47                 return ret;
48         }
49
50         /**
51          * The index of the referenced output in its transaction's vout.
52          */
53         public void set_index(short val) {
54                 bindings.OutPoint_set_index(this.ptr, val);
55                 GC.KeepAlive(this);
56                 GC.KeepAlive(val);
57         }
58
59         /**
60          * Constructs a new OutPoint given each field
61          */
62         public static OutPoint of(byte[] txid_arg, short index_arg) {
63                 long ret = bindings.OutPoint_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(txid_arg, 32)), index_arg);
64                 GC.KeepAlive(txid_arg);
65                 GC.KeepAlive(index_arg);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
68                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
69                 return ret_hu_conv;
70         }
71
72         internal long clone_ptr() {
73                 long ret = bindings.OutPoint_clone_ptr(this.ptr);
74                 GC.KeepAlive(this);
75                 return ret;
76         }
77
78         /**
79          * Creates a copy of the OutPoint
80          */
81         public OutPoint clone() {
82                 long ret = bindings.OutPoint_clone(this.ptr);
83                 GC.KeepAlive(this);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 org.ldk.structs.OutPoint ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OutPoint(null, ret); }
86                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
87                 return ret_hu_conv;
88         }
89
90         /**
91          * Checks if two OutPoints contain equal inner contents.
92          * This ignores pointers and is_owned flags and looks at the values in fields.
93          * Two objects with NULL inner values will be considered "equal" here.
94          */
95         public bool eq(org.ldk.structs.OutPoint b) {
96                 bool ret = bindings.OutPoint_eq(this.ptr, b == null ? 0 : b.ptr);
97                 GC.KeepAlive(this);
98                 GC.KeepAlive(b);
99                 if (this != null) { this.ptrs_to.AddLast(b); };
100                 return ret;
101         }
102
103         public override bool Equals(object o) {
104                 if (!(o is OutPoint)) return false;
105                 return this.eq((OutPoint)o);
106         }
107         /**
108          * Generates a non-cryptographic 64-bit hash of the OutPoint.
109          */
110         public long hash() {
111                 long ret = bindings.OutPoint_hash(this.ptr);
112                 GC.KeepAlive(this);
113                 return ret;
114         }
115
116         public override int GetHashCode() {
117                 return (int)this.hash();
118         }
119         /**
120          * Convert an `OutPoint` to a lightning channel id.
121          */
122         public byte[] to_channel_id() {
123                 long ret = bindings.OutPoint_to_channel_id(this.ptr);
124                 GC.KeepAlive(this);
125                 if (ret >= 0 && ret <= 4096) { return null; }
126                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
127                 return ret_conv;
128         }
129
130         /**
131          * Serialize the OutPoint object into a byte array which can be read by OutPoint_read
132          */
133         public byte[] write() {
134                 long ret = bindings.OutPoint_write(this.ptr);
135                 GC.KeepAlive(this);
136                 if (ret >= 0 && ret <= 4096) { return null; }
137                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
138                 return ret_conv;
139         }
140
141         /**
142          * Read a OutPoint from a byte array, created by OutPoint_write
143          */
144         public static Result_OutPointDecodeErrorZ read(byte[] ser) {
145                 long ret = bindings.OutPoint_read(InternalUtils.encodeUint8Array(ser));
146                 GC.KeepAlive(ser);
147                 if (ret >= 0 && ret <= 4096) { return null; }
148                 Result_OutPointDecodeErrorZ ret_hu_conv = Result_OutPointDecodeErrorZ.constr_from_ptr(ret);
149                 return ret_hu_conv;
150         }
151
152 }
153 } } }