+ /**
+ * Gets the counterparty's initial commitment transaction. The returned commitment
+ * transaction is unsigned. This is intended to be called during the initial persistence of
+ * the monitor (inside an implementation of [`Persist::persist_new_channel`]), to allow for
+ * watchtowers in the persistence pipeline to have enough data to form justice transactions.
+ *
+ * This is similar to [`Self::counterparty_commitment_txs_from_update`], except
+ * that for the initial commitment transaction, we don't have a corresponding update.
+ *
+ * This will only return `Some` for channel monitors that have been created after upgrading
+ * to LDK 0.0.117+.
+ *
+ * [`Persist::persist_new_channel`]: crate::chain::chainmonitor::Persist::persist_new_channel
+ *
+ * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None
+ */
+ public CommitmentTransaction initial_counterparty_commitment_tx() {
+ long ret = bindings.ChannelMonitor_initial_counterparty_commitment_tx(this.ptr);
+ GC.KeepAlive(this);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ org.ldk.structs.CommitmentTransaction ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.CommitmentTransaction(null, ret); }
+ if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
+ return ret_hu_conv;
+ }
+
+ /**
+ * Gets all of the counterparty commitment transactions provided by the given update. This
+ * may be empty if the update doesn't include any new counterparty commitments. Returned
+ * commitment transactions are unsigned.
+ *
+ * This is provided so that watchtower clients in the persistence pipeline are able to build
+ * justice transactions for each counterparty commitment upon each update. It's intended to be
+ * used within an implementation of [`Persist::update_persisted_channel`], which is provided
+ * with a monitor and an update. Once revoked, signing a justice transaction can be done using
+ * [`Self::sign_to_local_justice_tx`].
+ *
+ * It is expected that a watchtower client may use this method to retrieve the latest counterparty
+ * commitment transaction(s), and then hold the necessary data until a later update in which
+ * the monitor has been updated with the corresponding revocation data, at which point the
+ * monitor can sign the justice transaction.
+ *
+ * This will only return a non-empty list for monitor updates that have been created after
+ * upgrading to LDK 0.0.117+. Note that no restriction lies on the monitors themselves, which
+ * may have been created prior to upgrading.
+ *
+ * [`Persist::update_persisted_channel`]: crate::chain::chainmonitor::Persist::update_persisted_channel
+ */
+ public CommitmentTransaction[] counterparty_commitment_txs_from_update(org.ldk.structs.ChannelMonitorUpdate update) {
+ long ret = bindings.ChannelMonitor_counterparty_commitment_txs_from_update(this.ptr, update == null ? 0 : update.ptr);
+ GC.KeepAlive(this);
+ GC.KeepAlive(update);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ int ret_conv_23_len = InternalUtils.getArrayLength(ret);
+ CommitmentTransaction[] ret_conv_23_arr = new CommitmentTransaction[ret_conv_23_len];
+ for (int x = 0; x < ret_conv_23_len; x++) {
+ long ret_conv_23 = InternalUtils.getU64ArrayElem(ret, x);
+ org.ldk.structs.CommitmentTransaction ret_conv_23_hu_conv = null; if (ret_conv_23 < 0 || ret_conv_23 > 4096) { ret_conv_23_hu_conv = new org.ldk.structs.CommitmentTransaction(null, ret_conv_23); }
+ if (ret_conv_23_hu_conv != null) { ret_conv_23_hu_conv.ptrs_to.AddLast(this); };
+ ret_conv_23_arr[x] = ret_conv_23_hu_conv;
+ }
+ bindings.free_buffer(ret);
+ if (this != null) { this.ptrs_to.AddLast(update); };
+ return ret_conv_23_arr;
+ }
+
+ /**
+ * Wrapper around [`EcdsaChannelSigner::sign_justice_revoked_output`] to make
+ * signing the justice transaction easier for implementors of
+ * [`chain::chainmonitor::Persist`]. On success this method returns the provided transaction
+ * signing the input at `input_idx`. This method will only produce a valid signature for
+ * a transaction spending the `to_local` output of a commitment transaction, i.e. this cannot
+ * be used for revoked HTLC outputs.
+ *
+ * `Value` is the value of the output being spent by the input at `input_idx`, committed
+ * in the BIP 143 signature.
+ *
+ * This method will only succeed if this monitor has received the revocation secret for the
+ * provided `commitment_number`. If a commitment number is provided that does not correspond
+ * to the commitment transaction being revoked, this will return a signed transaction, but
+ * the signature will not be valid.
+ *
+ * [`EcdsaChannelSigner::sign_justice_revoked_output`]: crate::sign::EcdsaChannelSigner::sign_justice_revoked_output
+ * [`Persist`]: crate::chain::chainmonitor::Persist
+ */
+ public Result_TransactionNoneZ sign_to_local_justice_tx(byte[] justice_tx, long input_idx, long value, long commitment_number) {
+ long ret = bindings.ChannelMonitor_sign_to_local_justice_tx(this.ptr, InternalUtils.encodeUint8Array(justice_tx), input_idx, value, commitment_number);
+ GC.KeepAlive(this);
+ GC.KeepAlive(justice_tx);
+ GC.KeepAlive(input_idx);
+ GC.KeepAlive(value);
+ GC.KeepAlive(commitment_number);
+ if (ret >= 0 && ret <= 4096) { return null; }
+ Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+