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 byte[] ret = bindings.CommitmentTransaction_write(this.ptr);
51 * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write
53 public static Result_CommitmentTransactionDecodeErrorZ read(byte[] ser) {
54 long ret = bindings.CommitmentTransaction_read(ser);
56 if (ret >= 0 && ret <= 4096) { return null; }
57 Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
62 * The backwards-counting commitment number
64 public long commitment_number() {
65 long ret = bindings.CommitmentTransaction_commitment_number(this.ptr);
71 * The value to be sent to the broadcaster
73 public long to_broadcaster_value_sat() {
74 long ret = bindings.CommitmentTransaction_to_broadcaster_value_sat(this.ptr);
80 * The value to be sent to the counterparty
82 public long to_countersignatory_value_sat() {
83 long ret = bindings.CommitmentTransaction_to_countersignatory_value_sat(this.ptr);
89 * The feerate paid per 1000-weight-unit in this commitment transaction.
91 public int feerate_per_kw() {
92 int ret = bindings.CommitmentTransaction_feerate_per_kw(this.ptr);
98 * Trust our pre-built transaction and derived transaction creation public keys.
100 * Applies a wrapper which allows access to these fields.
102 * This should only be used if you fully trust the builder of this object. It should not
103 * be used by an external signer - instead use the verify function.
105 public TrustedCommitmentTransaction trust() {
106 long ret = bindings.CommitmentTransaction_trust(this.ptr);
108 if (ret >= 0 && ret <= 4096) { return null; }
109 org.ldk.structs.TrustedCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.TrustedCommitmentTransaction(null, ret); }
110 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
115 * Verify our pre-built transaction and derived transaction creation public keys.
117 * Applies a wrapper which allows access to these fields.
119 * An external validating signer must call this method before signing
120 * or using the built transaction.
122 public Result_TrustedCommitmentTransactionNoneZ verify(org.ldk.structs.DirectedChannelTransactionParameters channel_parameters, org.ldk.structs.ChannelPublicKeys broadcaster_keys, org.ldk.structs.ChannelPublicKeys countersignatory_keys) {
123 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);
125 GC.KeepAlive(channel_parameters);
126 GC.KeepAlive(broadcaster_keys);
127 GC.KeepAlive(countersignatory_keys);
128 if (ret >= 0 && ret <= 4096) { return null; }
129 Result_TrustedCommitmentTransactionNoneZ ret_hu_conv = Result_TrustedCommitmentTransactionNoneZ.constr_from_ptr(ret);
130 if (this != null) { this.ptrs_to.AddLast(channel_parameters); };
131 if (this != null) { this.ptrs_to.AddLast(broadcaster_keys); };
132 if (this != null) { this.ptrs_to.AddLast(countersignatory_keys); };