Update auto-updated Java files
[ldk-java] / src / main / java / org / ldk / structs / BuiltCommitmentTransaction.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * A pre-built Bitcoin commitment transaction and its txid.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class BuiltCommitmentTransaction extends CommonBase {
16         BuiltCommitmentTransaction(Object _dummy, long ptr) { super(ptr); }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 super.finalize();
20                 if (ptr != 0) { bindings.BuiltCommitmentTransaction_free(ptr); }
21         }
22
23         /**
24          * The commitment transaction
25          */
26         public byte[] get_transaction() {
27                 byte[] ret = bindings.BuiltCommitmentTransaction_get_transaction(this.ptr);
28                 Reference.reachabilityFence(this);
29                 return ret;
30         }
31
32         /**
33          * The commitment transaction
34          */
35         public void set_transaction(byte[] val) {
36                 bindings.BuiltCommitmentTransaction_set_transaction(this.ptr, val);
37                 Reference.reachabilityFence(this);
38                 Reference.reachabilityFence(val);
39         }
40
41         /**
42          * The txid for the commitment transaction.
43          * 
44          * This is provided as a performance optimization, instead of calling transaction.txid()
45          * multiple times.
46          */
47         public byte[] get_txid() {
48                 byte[] ret = bindings.BuiltCommitmentTransaction_get_txid(this.ptr);
49                 Reference.reachabilityFence(this);
50                 return ret;
51         }
52
53         /**
54          * The txid for the commitment transaction.
55          * 
56          * This is provided as a performance optimization, instead of calling transaction.txid()
57          * multiple times.
58          */
59         public void set_txid(byte[] val) {
60                 bindings.BuiltCommitmentTransaction_set_txid(this.ptr, InternalUtils.check_arr_len(val, 32));
61                 Reference.reachabilityFence(this);
62                 Reference.reachabilityFence(val);
63         }
64
65         /**
66          * Constructs a new BuiltCommitmentTransaction given each field
67          */
68         public static BuiltCommitmentTransaction of(byte[] transaction_arg, byte[] txid_arg) {
69                 long ret = bindings.BuiltCommitmentTransaction_new(transaction_arg, InternalUtils.check_arr_len(txid_arg, 32));
70                 Reference.reachabilityFence(transaction_arg);
71                 Reference.reachabilityFence(txid_arg);
72                 if (ret >= 0 && ret <= 4096) { return null; }
73                 BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BuiltCommitmentTransaction(null, ret); }
74                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
75                 return ret_hu_conv;
76         }
77
78         long clone_ptr() {
79                 long ret = bindings.BuiltCommitmentTransaction_clone_ptr(this.ptr);
80                 Reference.reachabilityFence(this);
81                 return ret;
82         }
83
84         /**
85          * Creates a copy of the BuiltCommitmentTransaction
86          */
87         public BuiltCommitmentTransaction clone() {
88                 long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
89                 Reference.reachabilityFence(this);
90                 if (ret >= 0 && ret <= 4096) { return null; }
91                 BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BuiltCommitmentTransaction(null, ret); }
92                 ret_hu_conv.ptrs_to.add(this);
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
98          */
99         public byte[] write() {
100                 byte[] ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
101                 Reference.reachabilityFence(this);
102                 return ret;
103         }
104
105         /**
106          * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
107          */
108         public static Result_BuiltCommitmentTransactionDecodeErrorZ read(byte[] ser) {
109                 long ret = bindings.BuiltCommitmentTransaction_read(ser);
110                 Reference.reachabilityFence(ser);
111                 if (ret >= 0 && ret <= 4096) { return null; }
112                 Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
113                 return ret_hu_conv;
114         }
115
116         /**
117          * Get the SIGHASH_ALL sighash value of the transaction.
118          * 
119          * This can be used to verify a signature.
120          */
121         public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) {
122                 byte[] ret = bindings.BuiltCommitmentTransaction_get_sighash_all(this.ptr, funding_redeemscript, channel_value_satoshis);
123                 Reference.reachabilityFence(this);
124                 Reference.reachabilityFence(funding_redeemscript);
125                 Reference.reachabilityFence(channel_value_satoshis);
126                 return ret;
127         }
128
129         /**
130          * Sign a transaction, either because we are counter-signing the counterparty's transaction or
131          * because we are about to broadcast a holder transaction.
132          */
133         public byte[] sign(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) {
134                 byte[] ret = bindings.BuiltCommitmentTransaction_sign(this.ptr, InternalUtils.check_arr_len(funding_key, 32), funding_redeemscript, channel_value_satoshis);
135                 Reference.reachabilityFence(this);
136                 Reference.reachabilityFence(funding_key);
137                 Reference.reachabilityFence(funding_redeemscript);
138                 Reference.reachabilityFence(channel_value_satoshis);
139                 return ret;
140         }
141
142 }