X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FCommitmentTransaction.java;h=42f044ac5ccdf1b9a0ba825412b5a692d05986ea;hb=b6cc0960eaee5a5bbc7fde79a56152d6dcd649d8;hp=bb38be53660229ac2a186bf5a361c5e0a57a0ccb;hpb=fed2245c60159f6c074c9ed5c0f3ce273ad9841b;p=ldk-java diff --git a/src/main/java/org/ldk/structs/CommitmentTransaction.java b/src/main/java/org/ldk/structs/CommitmentTransaction.java index bb38be53..42f044ac 100644 --- a/src/main/java/org/ldk/structs/CommitmentTransaction.java +++ b/src/main/java/org/ldk/structs/CommitmentTransaction.java @@ -5,6 +5,15 @@ import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; + +/** + * This class tracks the per-transaction information needed to build a commitment transaction and to + * actually build it and sign. It is used for holder transactions that we sign only when needed + * and for transactions we sign for the counterparty. + * + * This class can be used inside a signer implementation to generate a signature given the relevant + * secret key. + */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class CommitmentTransaction extends CommonBase { CommitmentTransaction(Object _dummy, long ptr) { super(ptr); } @@ -14,6 +23,9 @@ public class CommitmentTransaction extends CommonBase { if (ptr != 0) { bindings.CommitmentTransaction_free(ptr); } } + /** + * Creates a copy of the CommitmentTransaction + */ public CommitmentTransaction clone() { long ret = bindings.CommitmentTransaction_clone(this.ptr); CommitmentTransaction ret_hu_conv = new CommitmentTransaction(null, ret); @@ -21,38 +33,63 @@ public class CommitmentTransaction extends CommonBase { return ret_hu_conv; } + /** + * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read + */ public byte[] write() { byte[] ret = bindings.CommitmentTransaction_write(this.ptr); return ret; } - public static CommitmentTransaction constructor_read(byte[] ser) { + /** + * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write + */ + public static Result_CommitmentTransactionDecodeErrorZ read(byte[] ser) { long ret = bindings.CommitmentTransaction_read(ser); - CommitmentTransaction ret_hu_conv = new CommitmentTransaction(null, ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + Result_CommitmentTransactionDecodeErrorZ ret_hu_conv = Result_CommitmentTransactionDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; } + /** + * The backwards-counting commitment number + */ public long commitment_number() { long ret = bindings.CommitmentTransaction_commitment_number(this.ptr); return ret; } + /** + * The value to be sent to the broadcaster + */ public long to_broadcaster_value_sat() { long ret = bindings.CommitmentTransaction_to_broadcaster_value_sat(this.ptr); return ret; } + /** + * The value to be sent to the counterparty + */ public long to_countersignatory_value_sat() { long ret = bindings.CommitmentTransaction_to_countersignatory_value_sat(this.ptr); return ret; } + /** + * The feerate paid per 1000-weight-unit in this commitment transaction. + */ public int feerate_per_kw() { int ret = bindings.CommitmentTransaction_feerate_per_kw(this.ptr); return ret; } + /** + * Trust our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * This should only be used if you fully trust the builder of this object. It should not + * \tbe used by an external signer - instead use the verify function. + */ public TrustedCommitmentTransaction trust() { long ret = bindings.CommitmentTransaction_trust(this.ptr); TrustedCommitmentTransaction ret_hu_conv = new TrustedCommitmentTransaction(null, ret); @@ -60,6 +97,14 @@ public class CommitmentTransaction extends CommonBase { return ret_hu_conv; } + /** + * Verify our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * An external validating signer must call this method before signing + * or using the built transaction. + */ public Result_TrustedCommitmentTransactionNoneZ verify(DirectedChannelTransactionParameters channel_parameters, ChannelPublicKeys broadcaster_keys, ChannelPublicKeys countersignatory_keys) { long ret = bindings.CommitmentTransaction_verify(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr & ~1, broadcaster_keys == null ? 0 : broadcaster_keys.ptr & ~1, countersignatory_keys == null ? 0 : countersignatory_keys.ptr & ~1); Result_TrustedCommitmentTransactionNoneZ ret_hu_conv = Result_TrustedCommitmentTransactionNoneZ.constr_from_ptr(ret);