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 * This class tracks the per-transaction information needed to build a closing transaction and will
12 * actually build it and sign.
14 * This class can be used inside a signer implementation to generate a signature given the relevant
17 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
18 public class ClosingTransaction extends CommonBase {
19 ClosingTransaction(Object _dummy, long ptr) { super(ptr); }
20 @Override @SuppressWarnings("deprecation")
21 protected void finalize() throws Throwable {
23 if (ptr != 0) { bindings.ClosingTransaction_free(ptr); }
27 long ret = bindings.ClosingTransaction_clone_ptr(this.ptr);
32 * Creates a copy of the ClosingTransaction
34 public ClosingTransaction clone() {
35 long ret = bindings.ClosingTransaction_clone(this.ptr);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingTransaction(null, ret); }
38 ret_hu_conv.ptrs_to.add(this);
43 * Checks if two ClosingTransactions contain equal inner contents.
46 long ret = bindings.ClosingTransaction_hash(this.ptr);
50 @Override public int hashCode() {
51 return (int)this.hash();
54 * Construct an object of the class
56 public static ClosingTransaction of(long to_holder_value_sat, long to_counterparty_value_sat, byte[] to_holder_script, byte[] to_counterparty_script, OutPoint funding_outpoint) {
57 long ret = bindings.ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script, to_counterparty_script, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1);
58 if (ret >= 0 && ret <= 4096) { return null; }
59 ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingTransaction(null, ret); }
60 ret_hu_conv.ptrs_to.add(ret_hu_conv);
65 * Trust our pre-built transaction.
67 * Applies a wrapper which allows access to the transaction.
69 * This should only be used if you fully trust the builder of this object. It should not
70 * be used by an external signer - instead use the verify function.
72 public TrustedClosingTransaction trust() {
73 long ret = bindings.ClosingTransaction_trust(this.ptr);
74 if (ret >= 0 && ret <= 4096) { return null; }
75 TrustedClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TrustedClosingTransaction(null, ret); }
76 ret_hu_conv.ptrs_to.add(this);
81 * Verify our pre-built transaction.
83 * Applies a wrapper which allows access to the transaction.
85 * An external validating signer must call this method before signing
86 * or using the built transaction.
88 public Result_TrustedClosingTransactionNoneZ verify(OutPoint funding_outpoint) {
89 long ret = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
96 * The value to be sent to the holder, or zero if the output will be omitted
98 public long to_holder_value_sat() {
99 long ret = bindings.ClosingTransaction_to_holder_value_sat(this.ptr);
104 * The value to be sent to the counterparty, or zero if the output will be omitted
106 public long to_counterparty_value_sat() {
107 long ret = bindings.ClosingTransaction_to_counterparty_value_sat(this.ptr);
112 * The destination of the holder's output
114 public byte[] to_holder_script() {
115 byte[] ret = bindings.ClosingTransaction_to_holder_script(this.ptr);
120 * The destination of the counterparty's output
122 public byte[] to_counterparty_script() {
123 byte[] ret = bindings.ClosingTransaction_to_counterparty_script(this.ptr);