6 namespace org { namespace ldk { namespace structs {
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.
14 * This class can be used inside a signer implementation to generate a signature given the relevant
17 public class CommitmentTransaction : CommonBase {
18 internal CommitmentTransaction(object _dummy, long ptr) : base(ptr) { }
19 ~CommitmentTransaction() {
20 if (ptr != 0) { bindings.CommitmentTransaction_free(ptr); }
23 internal long clone_ptr() {
24 long ret = bindings.CommitmentTransaction_clone_ptr(this.ptr);
30 * Creates a copy of the CommitmentTransaction
32 public CommitmentTransaction clone() {
33 long ret = bindings.CommitmentTransaction_clone(this.ptr);
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); };
42 * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read
44 public byte[] write() {
45 long ret = bindings.CommitmentTransaction_write(this.ptr);
47 if (ret >= 0 && ret <= 4096) { return null; }
48 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
53 * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write
55 public static Result_CommitmentTransactionDecodeErrorZ read(byte[] ser) {
56 long ret = bindings.CommitmentTransaction_read(InternalUtils.encodeUint8Array(ser));
58 if (ret >= 0 && ret <= 4096) { return null; }
59 Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
64 * The backwards-counting commitment number
66 public long commitment_number() {
67 long ret = bindings.CommitmentTransaction_commitment_number(this.ptr);
73 * The per commitment point used by the broadcaster.
75 public byte[] per_commitment_point() {
76 long ret = bindings.CommitmentTransaction_per_commitment_point(this.ptr);
78 if (ret >= 0 && ret <= 4096) { return null; }
79 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
84 * The value to be sent to the broadcaster
86 public long to_broadcaster_value_sat() {
87 long ret = bindings.CommitmentTransaction_to_broadcaster_value_sat(this.ptr);
93 * The value to be sent to the counterparty
95 public long to_countersignatory_value_sat() {
96 long ret = bindings.CommitmentTransaction_to_countersignatory_value_sat(this.ptr);
102 * The feerate paid per 1000-weight-unit in this commitment transaction.
104 public int feerate_per_kw() {
105 int ret = bindings.CommitmentTransaction_feerate_per_kw(this.ptr);
111 * Trust our pre-built transaction and derived transaction creation public keys.
113 * Applies a wrapper which allows access to these fields.
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.
118 public TrustedCommitmentTransaction trust() {
119 long ret = bindings.CommitmentTransaction_trust(this.ptr);
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); };
128 * Verify our pre-built transaction and derived transaction creation public keys.
130 * Applies a wrapper which allows access to these fields.
132 * An external validating signer must call this method before signing
133 * or using the built transaction.
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.ptr, broadcaster_keys.ptr, countersignatory_keys.ptr);
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); };