[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / BuiltCommitmentTransaction.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 pre-built Bitcoin commitment transaction and its txid.
11  */
12 public class BuiltCommitmentTransaction : CommonBase {
13         internal BuiltCommitmentTransaction(object _dummy, long ptr) : base(ptr) { }
14         ~BuiltCommitmentTransaction() {
15                 if (ptr != 0) { bindings.BuiltCommitmentTransaction_free(ptr); }
16         }
17
18         /**
19          * The commitment transaction
20          */
21         public byte[] get_transaction() {
22                 long ret = bindings.BuiltCommitmentTransaction_get_transaction(this.ptr);
23                 GC.KeepAlive(this);
24                 if (ret >= 0 && ret <= 4096) { return null; }
25                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
26                 return ret_conv;
27         }
28
29         /**
30          * The commitment transaction
31          */
32         public void set_transaction(byte[] val) {
33                 bindings.BuiltCommitmentTransaction_set_transaction(this.ptr, InternalUtils.encodeUint8Array(val));
34                 GC.KeepAlive(this);
35                 GC.KeepAlive(val);
36         }
37
38         /**
39          * The txid for the commitment transaction.
40          * 
41          * This is provided as a performance optimization, instead of calling transaction.txid()
42          * multiple times.
43          */
44         public byte[] get_txid() {
45                 long ret = bindings.BuiltCommitmentTransaction_get_txid(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 for the commitment transaction.
54          * 
55          * This is provided as a performance optimization, instead of calling transaction.txid()
56          * multiple times.
57          */
58         public void set_txid(byte[] val) {
59                 bindings.BuiltCommitmentTransaction_set_txid(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
60                 GC.KeepAlive(this);
61                 GC.KeepAlive(val);
62         }
63
64         /**
65          * Constructs a new BuiltCommitmentTransaction given each field
66          */
67         public static BuiltCommitmentTransaction of(byte[] transaction_arg, byte[] txid_arg) {
68                 long ret = bindings.BuiltCommitmentTransaction_new(InternalUtils.encodeUint8Array(transaction_arg), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(txid_arg, 32)));
69                 GC.KeepAlive(transaction_arg);
70                 GC.KeepAlive(txid_arg);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 org.ldk.structs.BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BuiltCommitmentTransaction(null, ret); }
73                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
74                 return ret_hu_conv;
75         }
76
77         internal long clone_ptr() {
78                 long ret = bindings.BuiltCommitmentTransaction_clone_ptr(this.ptr);
79                 GC.KeepAlive(this);
80                 return ret;
81         }
82
83         /**
84          * Creates a copy of the BuiltCommitmentTransaction
85          */
86         public BuiltCommitmentTransaction clone() {
87                 long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
88                 GC.KeepAlive(this);
89                 if (ret >= 0 && ret <= 4096) { return null; }
90                 org.ldk.structs.BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BuiltCommitmentTransaction(null, ret); }
91                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
92                 return ret_hu_conv;
93         }
94
95         /**
96          * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
97          */
98         public byte[] write() {
99                 long ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
100                 GC.KeepAlive(this);
101                 if (ret >= 0 && ret <= 4096) { return null; }
102                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
103                 return ret_conv;
104         }
105
106         /**
107          * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
108          */
109         public static Result_BuiltCommitmentTransactionDecodeErrorZ read(byte[] ser) {
110                 long ret = bindings.BuiltCommitmentTransaction_read(InternalUtils.encodeUint8Array(ser));
111                 GC.KeepAlive(ser);
112                 if (ret >= 0 && ret <= 4096) { return null; }
113                 Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
114                 return ret_hu_conv;
115         }
116
117         /**
118          * Get the SIGHASH_ALL sighash value of the transaction.
119          * 
120          * This can be used to verify a signature.
121          */
122         public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) {
123                 long ret = bindings.BuiltCommitmentTransaction_get_sighash_all(this.ptr, InternalUtils.encodeUint8Array(funding_redeemscript), channel_value_satoshis);
124                 GC.KeepAlive(this);
125                 GC.KeepAlive(funding_redeemscript);
126                 GC.KeepAlive(channel_value_satoshis);
127                 if (ret >= 0 && ret <= 4096) { return null; }
128                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
129                 return ret_conv;
130         }
131
132         /**
133          * Signs the counterparty's commitment transaction.
134          */
135         public byte[] sign_counterparty_commitment(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) {
136                 long ret = bindings.BuiltCommitmentTransaction_sign_counterparty_commitment(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_key, 32)), InternalUtils.encodeUint8Array(funding_redeemscript), channel_value_satoshis);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(funding_key);
139                 GC.KeepAlive(funding_redeemscript);
140                 GC.KeepAlive(channel_value_satoshis);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
143                 return ret_conv;
144         }
145
146         /**
147          * Signs the holder commitment transaction because we are about to broadcast it.
148          */
149         public byte[] sign_holder_commitment(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis, org.ldk.structs.EntropySource entropy_source) {
150                 long ret = bindings.BuiltCommitmentTransaction_sign_holder_commitment(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_key, 32)), InternalUtils.encodeUint8Array(funding_redeemscript), channel_value_satoshis, entropy_source.ptr);
151                 GC.KeepAlive(this);
152                 GC.KeepAlive(funding_key);
153                 GC.KeepAlive(funding_redeemscript);
154                 GC.KeepAlive(channel_value_satoshis);
155                 GC.KeepAlive(entropy_source);
156                 if (ret >= 0 && ret <= 4096) { return null; }
157                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
158                 if (this != null) { this.ptrs_to.AddLast(entropy_source); };
159                 return ret_conv;
160         }
161
162 }
163 } } }