[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / CommitmentTransaction.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * This class tracks the per-transaction information needed to build a commitment transaction and will
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 public class CommitmentTransaction : CommonBase {
18         internal CommitmentTransaction(object _dummy, long ptr) : base(ptr) { }
19         ~CommitmentTransaction() {
20                 if (ptr != 0) { bindings.CommitmentTransaction_free(ptr); }
21         }
22
23         internal long clone_ptr() {
24                 long ret = bindings.CommitmentTransaction_clone_ptr(this.ptr);
25                 GC.KeepAlive(this);
26                 return ret;
27         }
28
29         /**
30          * Creates a copy of the CommitmentTransaction
31          */
32         public CommitmentTransaction clone() {
33                 long ret = bindings.CommitmentTransaction_clone(this.ptr);
34                 GC.KeepAlive(this);
35                 if (ret >= 0 && ret <= 4096) { return null; }
36                 org.ldk.structs.CommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentTransaction(null, ret); }
37                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read
43          */
44         public byte[] write() {
45                 long ret = bindings.CommitmentTransaction_write(this.ptr);
46                 GC.KeepAlive(this);
47                 if (ret >= 0 && ret <= 4096) { return null; }
48                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
49                 return ret_conv;
50         }
51
52         /**
53          * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write
54          */
55         public static Result_CommitmentTransactionDecodeErrorZ read(byte[] ser) {
56                 long ret = bindings.CommitmentTransaction_read(InternalUtils.encodeUint8Array(ser));
57                 GC.KeepAlive(ser);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
60                 return ret_hu_conv;
61         }
62
63         /**
64          * The backwards-counting commitment number
65          */
66         public long commitment_number() {
67                 long ret = bindings.CommitmentTransaction_commitment_number(this.ptr);
68                 GC.KeepAlive(this);
69                 return ret;
70         }
71
72         /**
73          * The per commitment point used by the broadcaster.
74          */
75         public byte[] per_commitment_point() {
76                 long ret = bindings.CommitmentTransaction_per_commitment_point(this.ptr);
77                 GC.KeepAlive(this);
78                 if (ret >= 0 && ret <= 4096) { return null; }
79                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
80                 return ret_conv;
81         }
82
83         /**
84          * The value to be sent to the broadcaster
85          */
86         public long to_broadcaster_value_sat() {
87                 long ret = bindings.CommitmentTransaction_to_broadcaster_value_sat(this.ptr);
88                 GC.KeepAlive(this);
89                 return ret;
90         }
91
92         /**
93          * The value to be sent to the counterparty
94          */
95         public long to_countersignatory_value_sat() {
96                 long ret = bindings.CommitmentTransaction_to_countersignatory_value_sat(this.ptr);
97                 GC.KeepAlive(this);
98                 return ret;
99         }
100
101         /**
102          * The feerate paid per 1000-weight-unit in this commitment transaction.
103          */
104         public int feerate_per_kw() {
105                 int ret = bindings.CommitmentTransaction_feerate_per_kw(this.ptr);
106                 GC.KeepAlive(this);
107                 return ret;
108         }
109
110         /**
111          * Trust our pre-built transaction and derived transaction creation public keys.
112          * 
113          * Applies a wrapper which allows access to these fields.
114          * 
115          * This should only be used if you fully trust the builder of this object.  It should not
116          * be used by an external signer - instead use the verify function.
117          */
118         public TrustedCommitmentTransaction trust() {
119                 long ret = bindings.CommitmentTransaction_trust(this.ptr);
120                 GC.KeepAlive(this);
121                 if (ret >= 0 && ret <= 4096) { return null; }
122                 org.ldk.structs.TrustedCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrustedCommitmentTransaction(null, ret); }
123                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
124                 return ret_hu_conv;
125         }
126
127         /**
128          * Verify our pre-built transaction and derived transaction creation public keys.
129          * 
130          * Applies a wrapper which allows access to these fields.
131          * 
132          * An external validating signer must call this method before signing
133          * or using the built transaction.
134          */
135         public Result_TrustedCommitmentTransactionNoneZ verify(org.ldk.structs.DirectedChannelTransactionParameters channel_parameters, org.ldk.structs.ChannelPublicKeys broadcaster_keys, org.ldk.structs.ChannelPublicKeys countersignatory_keys) {
136                 long ret = bindings.CommitmentTransaction_verify(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr, broadcaster_keys == null ? 0 : broadcaster_keys.ptr, countersignatory_keys == null ? 0 : countersignatory_keys.ptr);
137                 GC.KeepAlive(this);
138                 GC.KeepAlive(channel_parameters);
139                 GC.KeepAlive(broadcaster_keys);
140                 GC.KeepAlive(countersignatory_keys);
141                 if (ret >= 0 && ret <= 4096) { return null; }
142                 Result_TrustedCommitmentTransactionNoneZ ret_hu_conv = Result_TrustedCommitmentTransactionNoneZ.constr_from_ptr(ret);
143                 if (this != null) { this.ptrs_to.AddLast(channel_parameters); };
144                 if (this != null) { this.ptrs_to.AddLast(broadcaster_keys); };
145                 if (this != null) { this.ptrs_to.AddLast(countersignatory_keys); };
146                 return ret_hu_conv;
147         }
148
149 }
150 } } }