6 namespace org { namespace ldk { namespace structs {
10 * Information needed to build and sign a holder's commitment transaction.
12 * The transaction is only signed once we are ready to broadcast.
14 public class HolderCommitmentTransaction : CommonBase {
15 internal HolderCommitmentTransaction(object _dummy, long ptr) : base(ptr) { }
16 ~HolderCommitmentTransaction() {
17 if (ptr != 0) { bindings.HolderCommitmentTransaction_free(ptr); }
21 * Our counterparty's signature for the transaction
23 public byte[] get_counterparty_sig() {
24 long ret = bindings.HolderCommitmentTransaction_get_counterparty_sig(this.ptr);
26 if (ret >= 0 && ret <= 4096) { return null; }
27 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
32 * Our counterparty's signature for the transaction
34 public void set_counterparty_sig(byte[] val) {
35 bindings.HolderCommitmentTransaction_set_counterparty_sig(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val, 64)));
41 * All non-dust counterparty HTLC signatures, in the order they appear in the transaction
43 * Returns a copy of the field.
45 public byte[][] get_counterparty_htlc_sigs() {
46 long ret = bindings.HolderCommitmentTransaction_get_counterparty_htlc_sigs(this.ptr);
48 if (ret >= 0 && ret <= 4096) { return null; }
49 int ret_conv_8_len = InternalUtils.getArrayLength(ret);
50 byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][];
51 for (int i = 0; i < ret_conv_8_len; i++) {
52 long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i);
53 byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8);
54 ret_conv_8_arr[i] = ret_conv_8_conv;
56 bindings.free_buffer(ret);
57 return ret_conv_8_arr;
61 * All non-dust counterparty HTLC signatures, in the order they appear in the transaction
63 public void set_counterparty_htlc_sigs(byte[][] val) {
64 bindings.HolderCommitmentTransaction_set_counterparty_htlc_sigs(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(val, val_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(val_conv_8, 64)))));
69 internal long clone_ptr() {
70 long ret = bindings.HolderCommitmentTransaction_clone_ptr(this.ptr);
76 * Creates a copy of the HolderCommitmentTransaction
78 public HolderCommitmentTransaction clone() {
79 long ret = bindings.HolderCommitmentTransaction_clone(this.ptr);
81 if (ret >= 0 && ret <= 4096) { return null; }
82 org.ldk.structs.HolderCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, ret); }
83 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
88 * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read
90 public byte[] write() {
91 long ret = bindings.HolderCommitmentTransaction_write(this.ptr);
93 if (ret >= 0 && ret <= 4096) { return null; }
94 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
99 * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write
101 public static Result_HolderCommitmentTransactionDecodeErrorZ read(byte[] ser) {
102 long ret = bindings.HolderCommitmentTransaction_read(InternalUtils.encodeUint8Array(ser));
104 if (ret >= 0 && ret <= 4096) { return null; }
105 Result_HolderCommitmentTransactionDecodeErrorZ ret_hu_conv = Result_HolderCommitmentTransactionDecodeErrorZ.constr_from_ptr(ret);
110 * Create a new holder transaction with the given counterparty signatures.
111 * The funding keys are used to figure out which signature should go first when building the transaction for broadcast.
113 public static HolderCommitmentTransaction of(org.ldk.structs.CommitmentTransaction commitment_tx, byte[] counterparty_sig, byte[][] counterparty_htlc_sigs, byte[] holder_funding_key, byte[] counterparty_funding_key) {
114 long ret = bindings.HolderCommitmentTransaction_new(commitment_tx.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_sig, 64)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(counterparty_htlc_sigs, counterparty_htlc_sigs_conv_8 => InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_htlc_sigs_conv_8, 64)))), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(holder_funding_key, 33)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(counterparty_funding_key, 33)));
115 GC.KeepAlive(commitment_tx);
116 GC.KeepAlive(counterparty_sig);
117 GC.KeepAlive(counterparty_htlc_sigs);
118 GC.KeepAlive(holder_funding_key);
119 GC.KeepAlive(counterparty_funding_key);
120 if (ret >= 0 && ret <= 4096) { return null; }
121 org.ldk.structs.HolderCommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.HolderCommitmentTransaction(null, ret); }
122 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
123 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(commitment_tx); };