Update auto-generated bindings to 0.0.103
[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         /**
27          * Creates a copy of the ClosingTransaction
28          */
29         public ClosingTransaction clone() {
30                 long ret = bindings.ClosingTransaction_clone(this.ptr);
31                 if (ret >= 0 && ret <= 4096) { return null; }
32                 ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingTransaction(null, ret); }
33                 ret_hu_conv.ptrs_to.add(this);
34                 return ret_hu_conv;
35         }
36
37         /**
38          * Checks if two ClosingTransactions contain equal inner contents.
39          */
40         public long hash() {
41                 long ret = bindings.ClosingTransaction_hash(this.ptr);
42                 return ret;
43         }
44
45         /**
46          * Construct an object of the class
47          */
48         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) {
49                 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);
50                 if (ret >= 0 && ret <= 4096) { return null; }
51                 ClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new ClosingTransaction(null, ret); }
52                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
53                 return ret_hu_conv;
54         }
55
56         /**
57          * Trust our pre-built transaction.
58          * 
59          * Applies a wrapper which allows access to the transaction.
60          * 
61          * This should only be used if you fully trust the builder of this object. It should not
62          * be used by an external signer - instead use the verify function.
63          */
64         public TrustedClosingTransaction trust() {
65                 long ret = bindings.ClosingTransaction_trust(this.ptr);
66                 if (ret >= 0 && ret <= 4096) { return null; }
67                 TrustedClosingTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new TrustedClosingTransaction(null, ret); }
68                 ret_hu_conv.ptrs_to.add(this);
69                 return ret_hu_conv;
70         }
71
72         /**
73          * Verify our pre-built transaction.
74          * 
75          * Applies a wrapper which allows access to the transaction.
76          * 
77          * An external validating signer must call this method before signing
78          * or using the built transaction.
79          */
80         public Result_TrustedClosingTransactionNoneZ verify(OutPoint funding_outpoint) {
81                 long ret = bindings.ClosingTransaction_verify(this.ptr, funding_outpoint == null ? 0 : funding_outpoint.ptr & ~1);
82                 if (ret >= 0 && ret <= 4096) { return null; }
83                 Result_TrustedClosingTransactionNoneZ ret_hu_conv = Result_TrustedClosingTransactionNoneZ.constr_from_ptr(ret);
84                 return ret_hu_conv;
85         }
86
87         /**
88          * The value to be sent to the holder, or zero if the output will be omitted
89          */
90         public long to_holder_value_sat() {
91                 long ret = bindings.ClosingTransaction_to_holder_value_sat(this.ptr);
92                 return ret;
93         }
94
95         /**
96          * The value to be sent to the counterparty, or zero if the output will be omitted
97          */
98         public long to_counterparty_value_sat() {
99                 long ret = bindings.ClosingTransaction_to_counterparty_value_sat(this.ptr);
100                 return ret;
101         }
102
103         /**
104          * The destination of the holder's output
105          */
106         public byte[] to_holder_script() {
107                 byte[] ret = bindings.ClosingTransaction_to_holder_script(this.ptr);
108                 return ret;
109         }
110
111         /**
112          * The destination of the counterparty's output
113          */
114         public byte[] to_counterparty_script() {
115                 byte[] ret = bindings.ClosingTransaction_to_counterparty_script(this.ptr);
116                 return ret;
117         }
118
119 }