Update auto-generated bindings to 0.0.103
[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, val);
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, txid_arg);
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         /**
70          * Creates a copy of the BuiltCommitmentTransaction
71          */
72         public BuiltCommitmentTransaction clone() {
73                 long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
74                 if (ret >= 0 && ret <= 4096) { return null; }
75                 BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BuiltCommitmentTransaction(null, ret); }
76                 ret_hu_conv.ptrs_to.add(this);
77                 return ret_hu_conv;
78         }
79
80         /**
81          * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
82          */
83         public byte[] write() {
84                 byte[] ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
85                 return ret;
86         }
87
88         /**
89          * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
90          */
91         public static Result_BuiltCommitmentTransactionDecodeErrorZ read(byte[] ser) {
92                 long ret = bindings.BuiltCommitmentTransaction_read(ser);
93                 if (ret >= 0 && ret <= 4096) { return null; }
94                 Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
95                 return ret_hu_conv;
96         }
97
98         /**
99          * Get the SIGHASH_ALL sighash value of the transaction.
100          * 
101          * This can be used to verify a signature.
102          */
103         public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) {
104                 byte[] ret = bindings.BuiltCommitmentTransaction_get_sighash_all(this.ptr, funding_redeemscript, channel_value_satoshis);
105                 return ret;
106         }
107
108         /**
109          * Sign a transaction, either because we are counter-signing the counterparty's transaction or
110          * because we are about to broadcast a holder transaction.
111          */
112         public byte[] sign(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) {
113                 byte[] ret = bindings.BuiltCommitmentTransaction_sign(this.ptr, funding_key, funding_redeemscript, channel_value_satoshis);
114                 return ret;
115         }
116
117 }