1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
11 * A pre-built Bitcoin commitment transaction and its txid.
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 {
19 if (ptr != 0) { bindings.BuiltCommitmentTransaction_free(ptr); }
23 * The commitment transaction
25 public byte[] get_transaction() {
26 byte[] ret = bindings.BuiltCommitmentTransaction_get_transaction(this.ptr);
31 * The commitment transaction
33 public void set_transaction(byte[] val) {
34 bindings.BuiltCommitmentTransaction_set_transaction(this.ptr, val);
38 * The txid for the commitment transaction.
40 * This is provided as a performance optimization, instead of calling transaction.txid()
43 public byte[] get_txid() {
44 byte[] ret = bindings.BuiltCommitmentTransaction_get_txid(this.ptr);
49 * The txid for the commitment transaction.
51 * This is provided as a performance optimization, instead of calling transaction.txid()
54 public void set_txid(byte[] val) {
55 bindings.BuiltCommitmentTransaction_set_txid(this.ptr, InternalUtils.check_arr_len(val, 32));
59 * Constructs a new BuiltCommitmentTransaction given each field
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);
70 long ret = bindings.BuiltCommitmentTransaction_clone_ptr(this.ptr);
75 * Creates a copy of the BuiltCommitmentTransaction
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);
86 * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
88 public byte[] write() {
89 byte[] ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
94 * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
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);
104 * Get the SIGHASH_ALL sighash value of the transaction.
106 * This can be used to verify a signature.
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);
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.
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);