[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / c_sharp / src / org / ldk / structs / TxSignatures.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 tx_signatures message containing the sender's signatures for a transaction constructed with
11  * interactive transaction construction.
12  */
13 public class TxSignatures : CommonBase {
14         internal TxSignatures(object _dummy, long ptr) : base(ptr) { }
15         ~TxSignatures() {
16                 if (ptr != 0) { bindings.TxSignatures_free(ptr); }
17         }
18
19         /**
20          * The channel ID
21          */
22         public ChannelId get_channel_id() {
23                 long ret = bindings.TxSignatures_get_channel_id(this.ptr);
24                 GC.KeepAlive(this);
25                 if (ret >= 0 && ret <= 4096) { return null; }
26                 org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); }
27                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
28                 return ret_hu_conv;
29         }
30
31         /**
32          * The channel ID
33          */
34         public void set_channel_id(org.ldk.structs.ChannelId val) {
35                 bindings.TxSignatures_set_channel_id(this.ptr, val.ptr);
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38                 if (this != null) { this.ptrs_to.AddLast(val); };
39         }
40
41         /**
42          * The TXID
43          */
44         public byte[] get_tx_hash() {
45                 long ret = bindings.TxSignatures_get_tx_hash(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
49                 return ret_conv;
50         }
51
52         /**
53          * The TXID
54          */
55         public void set_tx_hash(byte[] val) {
56                 bindings.TxSignatures_set_tx_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
57                 GC.KeepAlive(this);
58                 GC.KeepAlive(val);
59         }
60
61         /**
62          * The list of witnesses
63          * 
64          * Returns a copy of the field.
65          */
66         public byte[][] get_witnesses() {
67                 long ret = bindings.TxSignatures_get_witnesses(this.ptr);
68                 GC.KeepAlive(this);
69                 if (ret >= 0 && ret <= 4096) { return null; }
70                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
71                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
72                 for (int i = 0; i < ret_conv_8_len; i++) {
73                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
74                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
75                         ret_conv_8_arr[i] = ret_conv_8_conv;
76                 }
77                 bindings.free_buffer(ret);
78                 return ret_conv_8_arr;
79         }
80
81         /**
82          * The list of witnesses
83          */
84         public void set_witnesses(byte[][] val) {
85                 bindings.TxSignatures_set_witnesses(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(val_conv_8))));
86                 GC.KeepAlive(this);
87                 GC.KeepAlive(val);
88         }
89
90         /**
91          * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
92          */
93         public Option_ECDSASignatureZ get_funding_outpoint_sig() {
94                 long ret = bindings.TxSignatures_get_funding_outpoint_sig(this.ptr);
95                 GC.KeepAlive(this);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.Option_ECDSASignatureZ ret_hu_conv = org.ldk.structs.Option_ECDSASignatureZ.constr_from_ptr(ret);
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
99                 return ret_hu_conv;
100         }
101
102         /**
103          * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers
104          */
105         public void set_funding_outpoint_sig(org.ldk.structs.Option_ECDSASignatureZ val) {
106                 bindings.TxSignatures_set_funding_outpoint_sig(this.ptr, val.ptr);
107                 GC.KeepAlive(this);
108                 GC.KeepAlive(val);
109                 if (this != null) { this.ptrs_to.AddLast(val); };
110         }
111
112         /**
113          * Constructs a new TxSignatures given each field
114          */
115         public static TxSignatures of(org.ldk.structs.ChannelId channel_id_arg, byte[] tx_hash_arg, byte[][] witnesses_arg, org.ldk.structs.Option_ECDSASignatureZ funding_outpoint_sig_arg) {
116                 long ret = bindings.TxSignatures_new(channel_id_arg.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(tx_hash_arg, 32)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(witnesses_arg, witnesses_arg_conv_8 => InternalUtils.encodeUint8Array(witnesses_arg_conv_8))), funding_outpoint_sig_arg.ptr);
117                 GC.KeepAlive(channel_id_arg);
118                 GC.KeepAlive(tx_hash_arg);
119                 GC.KeepAlive(witnesses_arg);
120                 GC.KeepAlive(funding_outpoint_sig_arg);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 org.ldk.structs.TxSignatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxSignatures(null, ret); }
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
124                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(channel_id_arg); };
125                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(funding_outpoint_sig_arg); };
126                 return ret_hu_conv;
127         }
128
129         internal long clone_ptr() {
130                 long ret = bindings.TxSignatures_clone_ptr(this.ptr);
131                 GC.KeepAlive(this);
132                 return ret;
133         }
134
135         /**
136          * Creates a copy of the TxSignatures
137          */
138         public TxSignatures clone() {
139                 long ret = bindings.TxSignatures_clone(this.ptr);
140                 GC.KeepAlive(this);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 org.ldk.structs.TxSignatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxSignatures(null, ret); }
143                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
144                 return ret_hu_conv;
145         }
146
147         /**
148          * Generates a non-cryptographic 64-bit hash of the TxSignatures.
149          */
150         public long hash() {
151                 long ret = bindings.TxSignatures_hash(this.ptr);
152                 GC.KeepAlive(this);
153                 return ret;
154         }
155
156         public override int GetHashCode() {
157                 return (int)this.hash();
158         }
159         /**
160          * Checks if two TxSignaturess contain equal inner contents.
161          * This ignores pointers and is_owned flags and looks at the values in fields.
162          * Two objects with NULL inner values will be considered "equal" here.
163          */
164         public bool eq(org.ldk.structs.TxSignatures b) {
165                 bool ret = bindings.TxSignatures_eq(this.ptr, b.ptr);
166                 GC.KeepAlive(this);
167                 GC.KeepAlive(b);
168                 if (this != null) { this.ptrs_to.AddLast(b); };
169                 return ret;
170         }
171
172         public override bool Equals(object o) {
173                 if (!(o is TxSignatures)) return false;
174                 return this.eq((TxSignatures)o);
175         }
176         /**
177          * Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
178          */
179         public byte[] write() {
180                 long ret = bindings.TxSignatures_write(this.ptr);
181                 GC.KeepAlive(this);
182                 if (ret >= 0 && ret <= 4096) { return null; }
183                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
184                 return ret_conv;
185         }
186
187         /**
188          * Read a TxSignatures from a byte array, created by TxSignatures_write
189          */
190         public static Result_TxSignaturesDecodeErrorZ read(byte[] ser) {
191                 long ret = bindings.TxSignatures_read(InternalUtils.encodeUint8Array(ser));
192                 GC.KeepAlive(ser);
193                 if (ret >= 0 && ret <= 4096) { return null; }
194                 Result_TxSignaturesDecodeErrorZ ret_hu_conv = Result_TxSignaturesDecodeErrorZ.constr_from_ptr(ret);
195                 return ret_hu_conv;
196         }
197
198 }
199 } } }