1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin
13 * transaction and the transaction creation keys) are trusted.
15 * See trust() and verify() functions on CommitmentTransaction.
17 * This structure implements Deref.
19 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
20 public class TrustedCommitmentTransaction extends CommonBase {
21 TrustedCommitmentTransaction(Object _dummy, long ptr) { super(ptr); }
22 @Override @SuppressWarnings("deprecation")
23 protected void finalize() throws Throwable {
25 if (ptr != 0) { bindings.TrustedCommitmentTransaction_free(ptr); }
29 * The transaction ID of the built Bitcoin transaction
31 public byte[] txid() {
32 byte[] ret = bindings.TrustedCommitmentTransaction_txid(this.ptr);
33 Reference.reachabilityFence(this);
38 * The pre-built Bitcoin commitment transaction
40 public BuiltCommitmentTransaction built_transaction() {
41 long ret = bindings.TrustedCommitmentTransaction_built_transaction(this.ptr);
42 Reference.reachabilityFence(this);
43 if (ret >= 0 && ret <= 4096) { return null; }
44 BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BuiltCommitmentTransaction(null, ret); }
45 ret_hu_conv.ptrs_to.add(this);
50 * The pre-calculated transaction creation public keys.
52 public TxCreationKeys keys() {
53 long ret = bindings.TrustedCommitmentTransaction_keys(this.ptr);
54 Reference.reachabilityFence(this);
55 if (ret >= 0 && ret <= 4096) { return null; }
56 TxCreationKeys ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TxCreationKeys(null, ret); }
57 ret_hu_conv.ptrs_to.add(this);
62 * Should anchors be used.
64 public boolean opt_anchors() {
65 boolean ret = bindings.TrustedCommitmentTransaction_opt_anchors(this.ptr);
66 Reference.reachabilityFence(this);
71 * Get a signature for each HTLC which was included in the commitment transaction (ie for
72 * which HTLCOutputInCommitment::transaction_output_index.is_some()).
74 * The returned Vec has one entry for each HTLC, and in the same order.
76 public Result_CVec_SignatureZNoneZ get_htlc_sigs(byte[] htlc_base_key, DirectedChannelTransactionParameters channel_parameters) {
77 long ret = bindings.TrustedCommitmentTransaction_get_htlc_sigs(this.ptr, InternalUtils.check_arr_len(htlc_base_key, 32), channel_parameters == null ? 0 : channel_parameters.ptr & ~1);
78 Reference.reachabilityFence(this);
79 Reference.reachabilityFence(htlc_base_key);
80 Reference.reachabilityFence(channel_parameters);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret);
83 this.ptrs_to.add(channel_parameters);