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, val);
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, txid_arg);
63 if (ret < 1024) { return null; }
64 BuiltCommitmentTransaction ret_hu_conv = new BuiltCommitmentTransaction(null, ret);
65 ret_hu_conv.ptrs_to.add(ret_hu_conv);
70 * Creates a copy of the BuiltCommitmentTransaction
72 public BuiltCommitmentTransaction clone() {
73 long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
74 if (ret < 1024) { return null; }
75 BuiltCommitmentTransaction ret_hu_conv = new BuiltCommitmentTransaction(null, ret);
76 ret_hu_conv.ptrs_to.add(this);
81 * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
83 public byte[] write() {
84 byte[] ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
89 * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
91 public static Result_BuiltCommitmentTransactionDecodeErrorZ read(byte[] ser) {
92 long ret = bindings.BuiltCommitmentTransaction_read(ser);
93 if (ret < 1024) { return null; }
94 Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
99 * Get the SIGHASH_ALL sighash value of the transaction.
101 * This can be used to verify a signature.
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);
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.
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);