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 * Information needed to build and sign a holder's commitment transaction.
13 * The transaction is only signed once we are ready to broadcast.
15 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
16 public class HolderCommitmentTransaction extends CommonBase {
17 HolderCommitmentTransaction(Object _dummy, long ptr) { super(ptr); }
18 @Override @SuppressWarnings("deprecation")
19 protected void finalize() throws Throwable {
21 if (ptr != 0) { bindings.HolderCommitmentTransaction_free(ptr); }
25 * Our counterparty's signature for the transaction
27 public byte[] get_counterparty_sig() {
28 byte[] ret = bindings.HolderCommitmentTransaction_get_counterparty_sig(this.ptr);
33 * Our counterparty's signature for the transaction
35 public void set_counterparty_sig(byte[] val) {
36 bindings.HolderCommitmentTransaction_set_counterparty_sig(this.ptr, val);
40 * All non-dust counterparty HTLC signatures, in the order they appear in the transaction
42 public void set_counterparty_htlc_sigs(byte[][] val) {
43 bindings.HolderCommitmentTransaction_set_counterparty_htlc_sigs(this.ptr, val);
47 * Creates a copy of the HolderCommitmentTransaction
49 public HolderCommitmentTransaction clone() {
50 long ret = bindings.HolderCommitmentTransaction_clone(this.ptr);
51 if (ret < 1024) { return null; }
52 HolderCommitmentTransaction ret_hu_conv = new HolderCommitmentTransaction(null, ret);
53 ret_hu_conv.ptrs_to.add(this);
58 * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read
60 public byte[] write() {
61 byte[] ret = bindings.HolderCommitmentTransaction_write(this.ptr);
66 * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write
68 public static Result_HolderCommitmentTransactionDecodeErrorZ read(byte[] ser) {
69 long ret = bindings.HolderCommitmentTransaction_read(ser);
70 if (ret < 1024) { return null; }
71 Result_HolderCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_HolderCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
76 * Create a new holder transaction with the given counterparty signatures.
77 * The funding keys are used to figure out which signature should go first when building the transaction for broadcast.
79 public static HolderCommitmentTransaction of(CommitmentTransaction commitment_tx, byte[] counterparty_sig, byte[][] counterparty_htlc_sigs, byte[] holder_funding_key, byte[] counterparty_funding_key) {
80 long ret = bindings.HolderCommitmentTransaction_new(commitment_tx == null ? 0 : commitment_tx.ptr & ~1, counterparty_sig, counterparty_htlc_sigs, holder_funding_key, counterparty_funding_key);
81 if (ret < 1024) { return null; }
82 HolderCommitmentTransaction ret_hu_conv = new HolderCommitmentTransaction(null, ret);
83 ret_hu_conv.ptrs_to.add(ret_hu_conv);
84 ret_hu_conv.ptrs_to.add(commitment_tx);