Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / ClosingTransaction.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * This class tracks the per-transaction information needed to build a closing transaction and will
12  * actually build it and sign.
13  * 
14  * This class can be used inside a signer implementation to generate a signature given the relevant
15  * secret key.
16  */
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 {
22                 super.finalize();
23                 if (ptr != 0) { bindings.ClosingTransaction_free(ptr); }
24         }
25
26         long clone_ptr() {
27                 long ret = bindings.ClosingTransaction_clone_ptr(this.ptr);
28                 return ret;
29         }
30
31         /**
32          * Creates a copy of the ClosingTransaction
33          */
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);
39                 return ret_hu_conv;
40         }
41
42         /**
43          * Checks if two ClosingTransactions contain equal inner contents.
44          */
45         public long hash() {
46                 long ret = bindings.ClosingTransaction_hash(this.ptr);
47                 return ret;
48         }
49
50         /**
51          * Construct an object of the class
52          */
53         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) {
54                 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);
55                 if (ret >= 0 && ret <= 4096) { return null; }
56                 ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingTransaction(null, ret); }
57                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
58                 return ret_hu_conv;
59         }
60
61         /**
62          * Trust our pre-built transaction.
63          * 
64          * Applies a wrapper which allows access to the transaction.
65          * 
66          * This should only be used if you fully trust the builder of this object. It should not
67          * be used by an external signer - instead use the verify function.
68          */
69         public TrustedClosingTransaction trust() {
70                 long ret = bindings.ClosingTransaction_trust(this.ptr);
71                 if (ret >= 0 && ret <= 4096) { return null; }
72                 TrustedClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TrustedClosingTransaction(null, ret); }
73                 ret_hu_conv.ptrs_to.add(this);
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Verify our pre-built transaction.
79          * 
80          * Applies a wrapper which allows access to the transaction.
81          * 
82          * An external validating signer must call this method before signing
83          * or using the built transaction.
84          */
85         public Result_TrustedClosingTransactionNoneZ verify(OutPoint funding_outpoint) {
86                 long ret = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1);
87                 if (ret >= 0 && ret <= 4096) { return null; }
88                 Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
89                 return ret_hu_conv;
90         }
91
92         /**
93          * The value to be sent to the holder, or zero if the output will be omitted
94          */
95         public long to_holder_value_sat() {
96                 long ret = bindings.ClosingTransaction_to_holder_value_sat(this.ptr);
97                 return ret;
98         }
99
100         /**
101          * The value to be sent to the counterparty, or zero if the output will be omitted
102          */
103         public long to_counterparty_value_sat() {
104                 long ret = bindings.ClosingTransaction_to_counterparty_value_sat(this.ptr);
105                 return ret;
106         }
107
108         /**
109          * The destination of the holder's output
110          */
111         public byte[] to_holder_script() {
112                 byte[] ret = bindings.ClosingTransaction_to_holder_script(this.ptr);
113                 return ret;
114         }
115
116         /**
117          * The destination of the counterparty's output
118          */
119         public byte[] to_counterparty_script() {
120                 byte[] ret = bindings.ClosingTransaction_to_counterparty_script(this.ptr);
121                 return ret;
122         }
123
124 }