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