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 * This class tracks the per-transaction information needed to build a closing transaction and will
13 * actually build it and sign.
15 * This class can be used inside a signer implementation to generate a signature given the relevant
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class ClosingTransaction extends CommonBase {
20 ClosingTransaction(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.ClosingTransaction_free(ptr); }
28 long ret = bindings.ClosingTransaction_clone_ptr(this.ptr);
29 Reference.reachabilityFence(this);
34 * Creates a copy of the ClosingTransaction
36 public ClosingTransaction clone() {
37 long ret = bindings.ClosingTransaction_clone(this.ptr);
38 Reference.reachabilityFence(this);
39 if (ret >= 0 && ret <= 4096) { return null; }
40 org.ldk.structs.ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingTransaction(null, ret); }
41 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
46 * Checks if two ClosingTransactions contain equal inner contents.
49 long ret = bindings.ClosingTransaction_hash(this.ptr);
50 Reference.reachabilityFence(this);
54 @Override public int hashCode() {
55 return (int)this.hash();
58 * Construct an object of the class
60 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) {
61 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);
62 Reference.reachabilityFence(to_holder_value_sat);
63 Reference.reachabilityFence(to_counterparty_value_sat);
64 Reference.reachabilityFence(to_holder_script);
65 Reference.reachabilityFence(to_counterparty_script);
66 Reference.reachabilityFence(funding_outpoint);
67 if (ret >= 0 && ret <= 4096) { return null; }
68 org.ldk.structs.ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ClosingTransaction(null, ret); }
69 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
70 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(funding_outpoint); };
75 * Trust our pre-built transaction.
77 * Applies a wrapper which allows access to the transaction.
79 * This should only be used if you fully trust the builder of this object. It should not
80 * be used by an external signer - instead use the verify function.
82 public TrustedClosingTransaction trust() {
83 long ret = bindings.ClosingTransaction_trust(this.ptr);
84 Reference.reachabilityFence(this);
85 if (ret >= 0 && ret <= 4096) { return null; }
86 org.ldk.structs.TrustedClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrustedClosingTransaction(null, ret); }
87 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
92 * Verify our pre-built transaction.
94 * Applies a wrapper which allows access to the transaction.
96 * An external validating signer must call this method before signing
97 * or using the built transaction.
99 public Result_TrustedClosingTransactionNoneZ verify(OutPoint funding_outpoint) {
100 long ret = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : funding_outpoint.ptr);
101 Reference.reachabilityFence(this);
102 Reference.reachabilityFence(funding_outpoint);
103 if (ret >= 0 && ret <= 4096) { return null; }
104 Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
105 if (this != null) { this.ptrs_to.add(funding_outpoint); };
110 * The value to be sent to the holder, or zero if the output will be omitted
112 public long to_holder_value_sat() {
113 long ret = bindings.ClosingTransaction_to_holder_value_sat(this.ptr);
114 Reference.reachabilityFence(this);
119 * The value to be sent to the counterparty, or zero if the output will be omitted
121 public long to_counterparty_value_sat() {
122 long ret = bindings.ClosingTransaction_to_counterparty_value_sat(this.ptr);
123 Reference.reachabilityFence(this);
128 * The destination of the holder's output
130 public byte[] to_holder_script() {
131 byte[] ret = bindings.ClosingTransaction_to_holder_script(this.ptr);
132 Reference.reachabilityFence(this);
137 * The destination of the counterparty's output
139 public byte[] to_counterparty_script() {
140 byte[] ret = bindings.ClosingTransaction_to_counterparty_script(this.ptr);
141 Reference.reachabilityFence(this);