246ee29b976c186544c7b8cf1a5d1c839e3191c1
[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 byte[] 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                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
27                 return ret_conv;
28         }
29
30         /**
31          * The channel ID
32          */
33         public void set_channel_id(byte[] val) {
34                 bindings.TxSignatures_set_channel_id(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
35                 GC.KeepAlive(this);
36                 GC.KeepAlive(val);
37         }
38
39         /**
40          * The TXID
41          */
42         public byte[] get_tx_hash() {
43                 long ret = bindings.TxSignatures_get_tx_hash(this.ptr);
44                 GC.KeepAlive(this);
45                 if (ret >= 0 && ret <= 4096) { return null; }
46                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
47                 return ret_conv;
48         }
49
50         /**
51          * The TXID
52          */
53         public void set_tx_hash(byte[] val) {
54                 bindings.TxSignatures_set_tx_hash(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
55                 GC.KeepAlive(this);
56                 GC.KeepAlive(val);
57         }
58
59         /**
60          * The list of witnesses
61          * 
62          * Returns a copy of the field.
63          */
64         public byte[][] get_witnesses() {
65                 long ret = bindings.TxSignatures_get_witnesses(this.ptr);
66                 GC.KeepAlive(this);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
69                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
70                 for (int i = 0; i < ret_conv_8_len; i++) {
71                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
72                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
73                         ret_conv_8_arr[i] = ret_conv_8_conv;
74                 }
75                 bindings.free_buffer(ret);
76                 return ret_conv_8_arr;
77         }
78
79         /**
80          * The list of witnesses
81          */
82         public void set_witnesses(byte[][] val) {
83                 bindings.TxSignatures_set_witnesses(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(val_conv_8))));
84                 GC.KeepAlive(this);
85                 GC.KeepAlive(val);
86         }
87
88         /**
89          * Constructs a new TxSignatures given each field
90          */
91         public static TxSignatures of(byte[] channel_id_arg, byte[] tx_hash_arg, byte[][] witnesses_arg) {
92                 long ret = bindings.TxSignatures_new(InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(channel_id_arg, 32)), 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))));
93                 GC.KeepAlive(channel_id_arg);
94                 GC.KeepAlive(tx_hash_arg);
95                 GC.KeepAlive(witnesses_arg);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 org.ldk.structs.TxSignatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxSignatures(null, ret); }
98                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
99                 return ret_hu_conv;
100         }
101
102         internal long clone_ptr() {
103                 long ret = bindings.TxSignatures_clone_ptr(this.ptr);
104                 GC.KeepAlive(this);
105                 return ret;
106         }
107
108         /**
109          * Creates a copy of the TxSignatures
110          */
111         public TxSignatures clone() {
112                 long ret = bindings.TxSignatures_clone(this.ptr);
113                 GC.KeepAlive(this);
114                 if (ret >= 0 && ret <= 4096) { return null; }
115                 org.ldk.structs.TxSignatures ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TxSignatures(null, ret); }
116                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
117                 return ret_hu_conv;
118         }
119
120         /**
121          * Checks if two TxSignaturess contain equal inner contents.
122          * This ignores pointers and is_owned flags and looks at the values in fields.
123          * Two objects with NULL inner values will be considered "equal" here.
124          */
125         public bool eq(org.ldk.structs.TxSignatures b) {
126                 bool ret = bindings.TxSignatures_eq(this.ptr, b == null ? 0 : b.ptr);
127                 GC.KeepAlive(this);
128                 GC.KeepAlive(b);
129                 if (this != null) { this.ptrs_to.AddLast(b); };
130                 return ret;
131         }
132
133         public override bool Equals(object o) {
134                 if (!(o is TxSignatures)) return false;
135                 return this.eq((TxSignatures)o);
136         }
137         /**
138          * Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read
139          */
140         public byte[] write() {
141                 long ret = bindings.TxSignatures_write(this.ptr);
142                 GC.KeepAlive(this);
143                 if (ret >= 0 && ret <= 4096) { return null; }
144                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
145                 return ret_conv;
146         }
147
148         /**
149          * Read a TxSignatures from a byte array, created by TxSignatures_write
150          */
151         public static Result_TxSignaturesDecodeErrorZ read(byte[] ser) {
152                 long ret = bindings.TxSignatures_read(InternalUtils.encodeUint8Array(ser));
153                 GC.KeepAlive(ser);
154                 if (ret >= 0 && ret <= 4096) { return null; }
155                 Result_TxSignaturesDecodeErrorZ ret_hu_conv = Result_TxSignaturesDecodeErrorZ.constr_from_ptr(ret);
156                 return ret_hu_conv;
157         }
158
159 }
160 } } }