Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / CommitmentTransaction.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
8
9 /**
10  * This class tracks the per-transaction information needed to build a commitment transaction and to
11  * actually build it and sign.  It is used for holder transactions that we sign only when needed
12  * and for transactions we sign for the counterparty.
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 CommitmentTransaction extends CommonBase {
19         CommitmentTransaction(Object _dummy, long ptr) { super(ptr); }
20         @Override @SuppressWarnings("deprecation")
21         protected void finalize() throws Throwable {
22                 super.finalize();
23                 if (ptr != 0) { bindings.CommitmentTransaction_free(ptr); }
24         }
25
26         /**
27          * Creates a copy of the CommitmentTransaction
28          */
29         public CommitmentTransaction clone() {
30                 long ret = bindings.CommitmentTransaction_clone(this.ptr);
31                 CommitmentTransaction ret_hu_conv = new CommitmentTransaction(null, ret);
32                 ret_hu_conv.ptrs_to.add(this);
33                 return ret_hu_conv;
34         }
35
36         /**
37          * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read
38          */
39         public byte[] write() {
40                 byte[] ret = bindings.CommitmentTransaction_write(this.ptr);
41                 return ret;
42         }
43
44         /**
45          * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write
46          */
47         public static Result_CommitmentTransactionDecodeErrorZ read(byte[] ser) {
48                 long ret = bindings.CommitmentTransaction_read(ser);
49                 Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
50                 return ret_hu_conv;
51         }
52
53         /**
54          * The backwards-counting commitment number
55          */
56         public long commitment_number() {
57                 long ret = bindings.CommitmentTransaction_commitment_number(this.ptr);
58                 return ret;
59         }
60
61         /**
62          * The value to be sent to the broadcaster
63          */
64         public long to_broadcaster_value_sat() {
65                 long ret = bindings.CommitmentTransaction_to_broadcaster_value_sat(this.ptr);
66                 return ret;
67         }
68
69         /**
70          * The value to be sent to the counterparty
71          */
72         public long to_countersignatory_value_sat() {
73                 long ret = bindings.CommitmentTransaction_to_countersignatory_value_sat(this.ptr);
74                 return ret;
75         }
76
77         /**
78          * The feerate paid per 1000-weight-unit in this commitment transaction.
79          */
80         public int feerate_per_kw() {
81                 int ret = bindings.CommitmentTransaction_feerate_per_kw(this.ptr);
82                 return ret;
83         }
84
85         /**
86          * Trust our pre-built transaction and derived transaction creation public keys.
87          * 
88          * Applies a wrapper which allows access to these fields.
89          * 
90          * This should only be used if you fully trust the builder of this object.  It should not
91          * \tbe used by an external signer - instead use the verify function.
92          */
93         public TrustedCommitmentTransaction trust() {
94                 long ret = bindings.CommitmentTransaction_trust(this.ptr);
95                 TrustedCommitmentTransaction ret_hu_conv = new TrustedCommitmentTransaction(null, ret);
96                 ret_hu_conv.ptrs_to.add(this);
97                 return ret_hu_conv;
98         }
99
100         /**
101          * Verify our pre-built transaction and derived transaction creation public keys.
102          * 
103          * Applies a wrapper which allows access to these fields.
104          * 
105          * An external validating signer must call this method before signing
106          * or using the built transaction.
107          */
108         public Result_TrustedCommitmentTransactionNoneZ verify(DirectedChannelTransactionParameters channel_parameters, ChannelPublicKeys broadcaster_keys, ChannelPublicKeys countersignatory_keys) {
109                 long ret = bindings.CommitmentTransaction_verify(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr & ~1, broadcaster_keys == null ? 0 : broadcaster_keys.ptr & ~1, countersignatory_keys == null ? 0 : countersignatory_keys.ptr & ~1);
110                 Result_TrustedCommitmentTransactionNoneZ ret_hu_conv = Result_TrustedCommitmentTransactionNoneZ.constr_from_ptr(ret);
111                 this.ptrs_to.add(channel_parameters);
112                 this.ptrs_to.add(broadcaster_keys);
113                 this.ptrs_to.add(countersignatory_keys);
114                 return ret_hu_conv;
115         }
116
117 }