1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * A pre-built Bitcoin commitment transaction and its txid.
12 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
13 public class BuiltCommitmentTransaction extends CommonBase {
14 BuiltCommitmentTransaction(Object _dummy, long ptr) { super(ptr); }
15 @Override @SuppressWarnings("deprecation")
16 protected void finalize() throws Throwable {
18 if (ptr != 0) { bindings.BuiltCommitmentTransaction_free(ptr); }
22 * The commitment transaction
24 public byte[] get_transaction() {
25 byte[] ret = bindings.BuiltCommitmentTransaction_get_transaction(this.ptr);
30 * The commitment transaction
32 public void set_transaction(byte[] val) {
33 bindings.BuiltCommitmentTransaction_set_transaction(this.ptr, val);
37 * The txid for the commitment transaction.
39 * This is provided as a performance optimization, instead of calling transaction.txid()
42 public byte[] get_txid() {
43 byte[] ret = bindings.BuiltCommitmentTransaction_get_txid(this.ptr);
48 * The txid for the commitment transaction.
50 * This is provided as a performance optimization, instead of calling transaction.txid()
53 public void set_txid(byte[] val) {
54 bindings.BuiltCommitmentTransaction_set_txid(this.ptr, val);
58 * Constructs a new BuiltCommitmentTransaction given each field
60 public static BuiltCommitmentTransaction constructor_new(byte[] transaction_arg, byte[] txid_arg) {
61 long ret = bindings.BuiltCommitmentTransaction_new(transaction_arg, txid_arg);
62 BuiltCommitmentTransaction ret_hu_conv = new BuiltCommitmentTransaction(null, ret);
63 ret_hu_conv.ptrs_to.add(ret_hu_conv);
68 * Creates a copy of the BuiltCommitmentTransaction
70 public BuiltCommitmentTransaction clone() {
71 long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
72 BuiltCommitmentTransaction ret_hu_conv = new BuiltCommitmentTransaction(null, ret);
73 ret_hu_conv.ptrs_to.add(this);
78 * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
80 public byte[] write() {
81 byte[] ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
86 * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
88 public static Result_BuiltCommitmentTransactionDecodeErrorZ constructor_read(byte[] ser) {
89 long ret = bindings.BuiltCommitmentTransaction_read(ser);
90 Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
95 * Get the SIGHASH_ALL sighash value of the transaction.
97 * This can be used to verify a signature.
99 public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) {
100 byte[] ret = bindings.BuiltCommitmentTransaction_get_sighash_all(this.ptr, funding_redeemscript, channel_value_satoshis);
105 * Sign a transaction, either because we are counter-signing the counterparty's transaction or
106 * because we are about to broadcast a holder transaction.
108 public byte[] sign(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) {
109 byte[] ret = bindings.BuiltCommitmentTransaction_sign(this.ptr, funding_key, funding_redeemscript, channel_value_satoshis);