[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / HolderCommitmentTransaction.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  * Information needed to build and sign a holder's commitment transaction.
11  * 
12  * The transaction is only signed once we are ready to broadcast.
13  */
14 public class HolderCommitmentTransaction : CommonBase {
15         internal HolderCommitmentTransaction(object _dummy, long ptr) : base(ptr) { }
16         ~HolderCommitmentTransaction() {
17                 if (ptr != 0) { bindings.HolderCommitmentTransaction_free(ptr); }
18         }
19
20         /**
21          * Our counterparty's signature for the transaction
22          */
23         public byte[] get_counterparty_sig() {
24                 long ret = bindings.HolderCommitmentTransaction_get_counterparty_sig(this.ptr);
25                 GC.KeepAlive(this);
26                 if (ret >= 0 && ret <= 4096) { return null; }
27                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
28                 return ret_conv;
29         }
30
31         /**
32          * Our counterparty's signature for the transaction
33          */
34         public void set_counterparty_sig(byte[] val) {
35                 bindings.HolderCommitmentTransaction_set_counterparty_sig(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
36                 GC.KeepAlive(this);
37                 GC.KeepAlive(val);
38         }
39
40         /**
41          * All non-dust counterparty HTLC signatures, in the order they appear in the transaction
42          * 
43          * Returns a copy of the field.
44          */
45         public byte[][] get_counterparty_htlc_sigs() {
46                 long ret = bindings.HolderCommitmentTransaction_get_counterparty_htlc_sigs(this.ptr);
47                 GC.KeepAlive(this);
48                 if (ret >= 0 && ret <= 4096) { return null; }
49                 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
50                 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
51                 for (int i = 0; i < ret_conv_8_len; i++) {
52                         long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
53                         byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
54                         ret_conv_8_arr[i] = ret_conv_8_conv;
55                 }
56                 bindings.free_buffer(ret);
57                 return ret_conv_8_arr;
58         }
59
60         /**
61          * All non-dust counterparty HTLC signatures, in the order they appear in the transaction
62          */
63         public void set_counterparty_htlc_sigs(byte[][] val) {
64                 bindings.HolderCommitmentTransaction_set_counterparty_htlc_sigs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val_conv_8, 64)))));
65                 GC.KeepAlive(this);
66                 GC.KeepAlive(val);
67         }
68
69         internal long clone_ptr() {
70                 long ret = bindings.HolderCommitmentTransaction_clone_ptr(this.ptr);
71                 GC.KeepAlive(this);
72                 return ret;
73         }
74
75         /**
76          * Creates a copy of the HolderCommitmentTransaction
77          */
78         public HolderCommitmentTransaction clone() {
79                 long ret = bindings.HolderCommitmentTransaction_clone(this.ptr);
80                 GC.KeepAlive(this);
81                 if (ret >= 0 && ret <= 4096) { return null; }
82                 org.ldk.structs.HolderCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, ret); }
83                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
84                 return ret_hu_conv;
85         }
86
87         /**
88          * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read
89          */
90         public byte[] write() {
91                 long ret = bindings.HolderCommitmentTransaction_write(this.ptr);
92                 GC.KeepAlive(this);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
95                 return ret_conv;
96         }
97
98         /**
99          * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write
100          */
101         public static Result_HolderCommitmentTransactionDecodeErrorZ read(byte[] ser) {
102                 long ret = bindings.HolderCommitmentTransaction_read(InternalUtils.encodeUint8Array(ser));
103                 GC.KeepAlive(ser);
104                 if (ret >= 0 && ret <= 4096) { return null; }
105                 Result_HolderCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_HolderCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
106                 return ret_hu_conv;
107         }
108
109         /**
110          * Create a new holder transaction with the given counterparty signatures.
111          * The funding keys are used to figure out which signature should go first when building the transaction for broadcast.
112          */
113         public static HolderCommitmentTransaction of(org.ldk.structs.CommitmentTransaction commitment_tx, byte[] counterparty_sig, byte[][] counterparty_htlc_sigs, byte[] holder_funding_key, byte[] counterparty_funding_key) {
114                 long ret = bindings.HolderCommitmentTransaction_new(commitment_tx == null ? 0 : commitment_tx.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_sig, 64)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(counterparty_htlc_sigs, counterparty_htlc_sigs_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_htlc_sigs_conv_8, 64)))), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(holder_funding_key, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_funding_key, 33)));
115                 GC.KeepAlive(commitment_tx);
116                 GC.KeepAlive(counterparty_sig);
117                 GC.KeepAlive(counterparty_htlc_sigs);
118                 GC.KeepAlive(holder_funding_key);
119                 GC.KeepAlive(counterparty_funding_key);
120                 if (ret >= 0 && ret <= 4096) { return null; }
121                 org.ldk.structs.HolderCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, ret); }
122                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(commitment_tx); };
124                 return ret_hu_conv;
125         }
126
127 }
128 } } }