6 namespace org { namespace ldk { namespace structs {
10 * A pre-built Bitcoin commitment transaction and its txid.
12 public class BuiltCommitmentTransaction : CommonBase {
13 internal BuiltCommitmentTransaction(object _dummy, long ptr) : base(ptr) { }
14 ~BuiltCommitmentTransaction() {
15 if (ptr != 0) { bindings.BuiltCommitmentTransaction_free(ptr); }
19 * The commitment transaction
21 public byte[] get_transaction() {
22 long ret = bindings.BuiltCommitmentTransaction_get_transaction(this.ptr);
24 if (ret >= 0 && ret <= 4096) { return null; }
25 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
30 * The commitment transaction
32 public void set_transaction(byte[] val) {
33 bindings.BuiltCommitmentTransaction_set_transaction(this.ptr, InternalUtils.encodeUint8Array(val));
39 * The txid for the commitment transaction.
41 * This is provided as a performance optimization, instead of calling transaction.txid()
44 public byte[] get_txid() {
45 long ret = bindings.BuiltCommitmentTransaction_get_txid(this.ptr);
47 if (ret >= 0 && ret <= 4096) { return null; }
48 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
53 * The txid for the commitment transaction.
55 * This is provided as a performance optimization, instead of calling transaction.txid()
58 public void set_txid(byte[] val) {
59 bindings.BuiltCommitmentTransaction_set_txid(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 32)));
65 * Constructs a new BuiltCommitmentTransaction given each field
67 public static BuiltCommitmentTransaction of(byte[] transaction_arg, byte[] txid_arg) {
68 long ret = bindings.BuiltCommitmentTransaction_new(InternalUtils.encodeUint8Array(transaction_arg), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(txid_arg, 32)));
69 GC.KeepAlive(transaction_arg);
70 GC.KeepAlive(txid_arg);
71 if (ret >= 0 && ret <= 4096) { return null; }
72 org.ldk.structs.BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BuiltCommitmentTransaction(null, ret); }
73 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
77 internal long clone_ptr() {
78 long ret = bindings.BuiltCommitmentTransaction_clone_ptr(this.ptr);
84 * Creates a copy of the BuiltCommitmentTransaction
86 public BuiltCommitmentTransaction clone() {
87 long ret = bindings.BuiltCommitmentTransaction_clone(this.ptr);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.BuiltCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.BuiltCommitmentTransaction(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
96 * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read
98 public byte[] write() {
99 long ret = bindings.BuiltCommitmentTransaction_write(this.ptr);
101 if (ret >= 0 && ret <= 4096) { return null; }
102 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
107 * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write
109 public static Result_BuiltCommitmentTransactionDecodeErrorZ read(byte[] ser) {
110 long ret = bindings.BuiltCommitmentTransaction_read(InternalUtils.encodeUint8Array(ser));
112 if (ret >= 0 && ret <= 4096) { return null; }
113 Result_BuiltCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_BuiltCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
118 * Get the SIGHASH_ALL sighash value of the transaction.
120 * This can be used to verify a signature.
122 public byte[] get_sighash_all(byte[] funding_redeemscript, long channel_value_satoshis) {
123 long ret = bindings.BuiltCommitmentTransaction_get_sighash_all(this.ptr, InternalUtils.encodeUint8Array(funding_redeemscript), channel_value_satoshis);
125 GC.KeepAlive(funding_redeemscript);
126 GC.KeepAlive(channel_value_satoshis);
127 if (ret >= 0 && ret <= 4096) { return null; }
128 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
133 * Signs the counterparty's commitment transaction.
135 public byte[] sign_counterparty_commitment(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis) {
136 long ret = bindings.BuiltCommitmentTransaction_sign_counterparty_commitment(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_key, 32)), InternalUtils.encodeUint8Array(funding_redeemscript), channel_value_satoshis);
138 GC.KeepAlive(funding_key);
139 GC.KeepAlive(funding_redeemscript);
140 GC.KeepAlive(channel_value_satoshis);
141 if (ret >= 0 && ret <= 4096) { return null; }
142 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
147 * Signs the holder commitment transaction because we are about to broadcast it.
149 public byte[] sign_holder_commitment(byte[] funding_key, byte[] funding_redeemscript, long channel_value_satoshis, org.ldk.structs.EntropySource entropy_source) {
150 long ret = bindings.BuiltCommitmentTransaction_sign_holder_commitment(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(funding_key, 32)), InternalUtils.encodeUint8Array(funding_redeemscript), channel_value_satoshis, entropy_source.ptr);
152 GC.KeepAlive(funding_key);
153 GC.KeepAlive(funding_redeemscript);
154 GC.KeepAlive(channel_value_satoshis);
155 GC.KeepAlive(entropy_source);
156 if (ret >= 0 && ret <= 4096) { return null; }
157 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
158 if (this != null) { this.ptrs_to.AddLast(entropy_source); };