X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FTrustedCommitmentTransaction.cs;fp=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FTrustedCommitmentTransaction.cs;h=0f81c2feadc14e9054a96c425b437e8fec2070ef;hb=8de7213fbf663ff60322896282dad51e8ab2f001;hp=638e16f326677d3a5b223452a6ea9808d7dad7c8;hpb=afc50e5d491a11364849383b75a8f939df703bac;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/TrustedCommitmentTransaction.cs b/c_sharp/src/org/ldk/structs/TrustedCommitmentTransaction.cs index 638e16f3..0f81c2fe 100644 --- a/c_sharp/src/org/ldk/structs/TrustedCommitmentTransaction.cs +++ b/c_sharp/src/org/ldk/structs/TrustedCommitmentTransaction.cs @@ -24,9 +24,11 @@ public class TrustedCommitmentTransaction : CommonBase { * The transaction ID of the built Bitcoin transaction */ public byte[] txid() { - byte[] ret = bindings.TrustedCommitmentTransaction_txid(this.ptr); + long ret = bindings.TrustedCommitmentTransaction_txid(this.ptr); GC.KeepAlive(this); - return ret; + if (ret >= 0 && ret <= 4096) { return null; } + byte[] ret_conv = InternalUtils.decodeUint8Array(ret); + return ret_conv; } /** @@ -73,18 +75,61 @@ public class TrustedCommitmentTransaction : CommonBase { * * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. */ - public Result_CVec_SignatureZNoneZ get_htlc_sigs(byte[] htlc_base_key, org.ldk.structs.DirectedChannelTransactionParameters channel_parameters, org.ldk.structs.EntropySource entropy_source) { - long ret = bindings.TrustedCommitmentTransaction_get_htlc_sigs(this.ptr, InternalUtils.check_arr_len(htlc_base_key, 32), channel_parameters == null ? 0 : channel_parameters.ptr, entropy_source.ptr); + public Result_CVec_ECDSASignatureZNoneZ get_htlc_sigs(byte[] htlc_base_key, org.ldk.structs.DirectedChannelTransactionParameters channel_parameters, org.ldk.structs.EntropySource entropy_source) { + long ret = bindings.TrustedCommitmentTransaction_get_htlc_sigs(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(htlc_base_key, 32)), channel_parameters == null ? 0 : channel_parameters.ptr, entropy_source.ptr); GC.KeepAlive(this); GC.KeepAlive(htlc_base_key); GC.KeepAlive(channel_parameters); GC.KeepAlive(entropy_source); if (ret >= 0 && ret <= 4096) { return null; } - Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret); + Result_CVec_ECDSASignatureZNoneZ ret_hu_conv = Result_CVec_ECDSASignatureZNoneZ.constr_from_ptr(ret); if (this != null) { this.ptrs_to.AddLast(channel_parameters); }; if (this != null) { this.ptrs_to.AddLast(entropy_source); }; return ret_hu_conv; } + /** + * Returns the index of the revokeable output, i.e. the `to_local` output sending funds to + * the broadcaster, in the built transaction, if any exists. + * + * There are two cases where this may return `None`: + * - The balance of the revokeable output is below the dust limit (only found on commitments + * early in the channel's lifetime, i.e. before the channel reserve is met). + * - This commitment was created before LDK 0.0.117. In this case, the + * commitment transaction previously didn't contain enough information to locate the + * revokeable output. + */ + public Option_usizeZ revokeable_output_index() { + long ret = bindings.TrustedCommitmentTransaction_revokeable_output_index(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.Option_usizeZ ret_hu_conv = org.ldk.structs.Option_usizeZ.constr_from_ptr(ret); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; + } + + /** + * Helper method to build an unsigned justice transaction spending the revokeable + * `to_local` output to a destination script. Fee estimation accounts for the expected + * revocation witness data that will be added when signed. + * + * This method will error if the given fee rate results in a fee greater than the value + * of the output being spent, or if there exists no revokeable `to_local` output on this + * commitment transaction. See [`Self::revokeable_output_index`] for more details. + * + * The built transaction will allow fee bumping with RBF, and this method takes + * `feerate_per_kw` as an input such that multiple copies of a justice transaction at different + * fee rates may be built. + */ + public Result_TransactionNoneZ build_to_local_justice_tx(long feerate_per_kw, byte[] destination_script) { + long ret = bindings.TrustedCommitmentTransaction_build_to_local_justice_tx(this.ptr, feerate_per_kw, InternalUtils.encodeUint8Array(destination_script)); + GC.KeepAlive(this); + GC.KeepAlive(feerate_per_kw); + GC.KeepAlive(destination_script); + if (ret >= 0 && ret <= 4096) { return null; } + Result_TransactionNoneZ ret_hu_conv = Result_TransactionNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + } } } }