[C#] Check in initial 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                 byte[] ret = bindings.BuiltCommitmentTransaction_get_transaction(this.ptr);
23                 GC.KeepAlive(this);
24                 return ret;
25         }
26
27         /**
28          * The commitment transaction
29          */
30         public void set_transaction(byte[] val) {
31                 bindings.BuiltCommitmentTransaction_set_transaction(this.ptr, val);
32                 GC.KeepAlive(this);
33                 GC.KeepAlive(val);
34         }
35
36         /**
37          * The txid for the commitment transaction.
38          * 
39          * This is provided as a performance optimization, instead of calling transaction.txid()
40          * multiple times.
41          */
42         public byte[] get_txid() {
43                 byte[] ret = bindings.BuiltCommitmentTransaction_get_txid(this.ptr);
44                 GC.KeepAlive(this);
45                 return ret;
46         }
47
48         /**
49          * The txid for the commitment transaction.
50          * 
51          * This is provided as a performance optimization, instead of calling transaction.txid()
52          * multiple times.
53          */
54         public void set_txid(byte[] val) {
55                 bindings.BuiltCommitmentTransaction_set_txid(this.ptr, InternalUtils.check_arr_len(val, 32));
56                 GC.KeepAlive(this);
57                 GC.KeepAlive(val);
58         }
59
60         /**
61          * Constructs a new BuiltCommitmentTransaction given each field
62          */
63         public static BuiltCommitmentTransaction of(byte[] transaction_arg, byte[] txid_arg) {
64                 long ret = bindings.BuiltCommitmentTransaction_new(transaction_arg, InternalUtils.check_arr_len(txid_arg, 32));
65                 GC.KeepAlive(transaction_arg);
66                 GC.KeepAlive(txid_arg);
67                 if (ret >= 0 && ret <= 4096) { return null; }
68                 org.ldk.structs.BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BuiltCommitmentTransaction(null, ret); }
69                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
70                 return ret_hu_conv;
71         }
72
73         internal long clone_ptr() {
74                 long ret = bindings.BuiltCommitmentTransaction_clone_ptr(this.ptr);
75                 GC.KeepAlive(this);
76                 return ret;
77         }
78
79         /**
80          * Creates a copy of the BuiltCommitmentTransaction
81          */
82         public BuiltCommitmentTransaction clone() {
83                 long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
84                 GC.KeepAlive(this);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 org.ldk.structs.BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BuiltCommitmentTransaction(null, ret); }
87                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
88                 return ret_hu_conv;
89         }
90
91         /**
92          * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
93          */
94         public byte[] write() {
95                 byte[] ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
96                 GC.KeepAlive(this);
97                 return ret;
98         }
99
100         /**
101          * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
102          */
103         public static Result_BuiltCommitmentTransactionDecodeErrorZ read(byte[] ser) {
104                 long ret = bindings.BuiltCommitmentTransaction_read(ser);
105                 GC.KeepAlive(ser);
106                 if (ret >= 0 && ret <= 4096) { return null; }
107                 Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
108                 return ret_hu_conv;
109         }
110
111         /**
112          * Get the SIGHASH_ALL sighash value of the transaction.
113          * 
114          * This can be used to verify a signature.
115          */
116         public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) {
117                 byte[] ret = bindings.BuiltCommitmentTransaction_get_sighash_all(this.ptr, funding_redeemscript, channel_value_satoshis);
118                 GC.KeepAlive(this);
119                 GC.KeepAlive(funding_redeemscript);
120                 GC.KeepAlive(channel_value_satoshis);
121                 return ret;
122         }
123
124         /**
125          * Sign a transaction, either because we are counter-signing the counterparty's transaction or
126          * because we are about to broadcast a holder transaction.
127          */
128         public byte[] sign(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) {
129                 byte[] ret = bindings.BuiltCommitmentTransaction_sign(this.ptr, InternalUtils.check_arr_len(funding_key, 32), funding_redeemscript, channel_value_satoshis);
130                 GC.KeepAlive(this);
131                 GC.KeepAlive(funding_key);
132                 GC.KeepAlive(funding_redeemscript);
133                 GC.KeepAlive(channel_value_satoshis);
134                 return ret;
135         }
136
137 }
138 } } }