X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FSpendableOutputDescriptor.java;h=cdb05d5e9d32d772ea0ca3572c6e7ace455cd384;hb=2bb592fb946e316dba9f4d1123f8ac72ff4e9bf8;hp=460a9b98149c6b3f9825086b50c3cdbfd8da7a8b;hpb=330ca992be304d0eac79bd59b411980dff294b03;p=ldk-java diff --git a/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java b/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java index 460a9b98..cdb05d5e 100644 --- a/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java +++ b/src/main/java/org/ldk/structs/SpendableOutputDescriptor.java @@ -17,7 +17,7 @@ import javax.annotation.Nullable; * outpoint describing which `txid` and output `index` is available, the full output which exists * at that `txid`/`index`, and any keys or other information required to sign. * - * [`SpendableOutputs`]: crate::util::events::Event::SpendableOutputs + * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class SpendableOutputDescriptor extends CommonBase { @@ -42,14 +42,14 @@ public class SpendableOutputDescriptor extends CommonBase { } /** - * An output to a script which was provided via [`KeysInterface`] directly, either from + * An output to a script which was provided via [`SignerProvider`] directly, either from * [`get_destination_script`] or [`get_shutdown_scriptpubkey`], thus you should already * know how to spend it. No secret keys are provided as LDK was never given any key. * These may include outputs from a transaction punishing our counterparty or claiming an HTLC * on-chain using the payment preimage or after it has timed out. * - * [`get_shutdown_scriptpubkey`]: KeysInterface::get_shutdown_scriptpubkey - * [`get_destination_script`]: KeysInterface::get_shutdown_scriptpubkey + * [`get_shutdown_scriptpubkey`]: SignerProvider::get_shutdown_scriptpubkey + * [`get_destination_script`]: SignerProvider::get_shutdown_scriptpubkey */ public final static class StaticOutput extends SpendableOutputDescriptor { /** @@ -60,6 +60,19 @@ public class SpendableOutputDescriptor extends CommonBase { * The output which is referenced by the given outpoint. */ public final org.ldk.structs.TxOut output; + /** + * The `channel_keys_id` for the channel which this output came from. + * + * For channels which were generated on LDK 0.0.119 or later, this is the value which was + * passed to the [`SignerProvider::get_destination_script`] call which provided this + * output script. + * + * For channels which were generated prior to LDK 0.0.119, no such argument existed, + * however this field may still be filled in if such data is available. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + @Nullable public final byte[] channel_keys_id; private StaticOutput(long ptr, bindings.LDKSpendableOutputDescriptor.StaticOutput obj) { super(null, ptr); long outpoint = obj.outpoint; @@ -69,6 +82,7 @@ public class SpendableOutputDescriptor extends CommonBase { long output = obj.output; TxOut output_conv = new TxOut(null, output); this.output = output_conv; + this.channel_keys_id = obj.channel_keys_id; } } /** @@ -93,17 +107,17 @@ public class SpendableOutputDescriptor extends CommonBase { * * To derive the delayed payment key which is used to sign this input, you must pass the * holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the - * [`ChannelPublicKeys::delayed_payment_basepoint`] in [`BaseSign::pubkeys`]) and the provided - * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The public key can be - * generated without the secret key using [`chan_utils::derive_public_key`] and only the - * [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`BaseSign::pubkeys`]. + * [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided + * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The DelayedPaymentKey can be + * generated without the secret key using [`DelayedPaymentKey::from_basepoint`] and only the + * [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`]. * * To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is * used in the witness script generation), you must pass the counterparty * [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to - * [`BaseSign::provide_channel_parameters`]) and the provided + * [`ChannelSigner::provide_channel_parameters`]) and the provided * [`DelayedPaymentOutputDescriptor::per_commitment_point`] to - * [`chan_utils::derive_public_revocation_key`]. + * [`RevocationKey`]. * * The witness script which is hashed and included in the output `script_pubkey` may be * regenerated by passing the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] (derived @@ -122,15 +136,23 @@ public class SpendableOutputDescriptor extends CommonBase { } } /** - * An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key - * which corresponds to the `payment_point` in [`BaseSign::pubkeys`]). The witness - * in the spending input is, thus, simply: + * An output spendable exclusively by our payment key (i.e., the private key that corresponds + * to the `payment_point` in [`ChannelSigner::pubkeys`]). The output type depends on the + * channel type negotiated. + * + * On an anchor outputs channel, the witness in the spending input is: + * ```bitcoin + * + * ``` + * + * Otherwise, it is: * ```bitcoin * * ``` * * These are generally the result of our counterparty having broadcast the current state, - * allowing us to claim the non-HTLC-encumbered outputs immediately. + * allowing us to claim the non-HTLC-encumbered outputs immediately, or after one confirmation + * in the case of anchor outputs channels. */ public final static class StaticPaymentOutput extends SpendableOutputDescriptor { public final org.ldk.structs.StaticPaymentOutputDescriptor static_payment_output; @@ -163,10 +185,11 @@ public class SpendableOutputDescriptor extends CommonBase { /** * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor */ - public static SpendableOutputDescriptor static_output(org.ldk.structs.OutPoint outpoint, org.ldk.structs.TxOut output) { - long ret = bindings.SpendableOutputDescriptor_static_output(outpoint == null ? 0 : outpoint.ptr, output.ptr); + public static SpendableOutputDescriptor static_output(org.ldk.structs.OutPoint outpoint, org.ldk.structs.TxOut output, byte[] channel_keys_id) { + long ret = bindings.SpendableOutputDescriptor_static_output(outpoint == null ? 0 : outpoint.ptr, output.ptr, InternalUtils.check_arr_len(channel_keys_id, 32)); Reference.reachabilityFence(outpoint); Reference.reachabilityFence(output); + Reference.reachabilityFence(channel_keys_id); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.SpendableOutputDescriptor ret_hu_conv = org.ldk.structs.SpendableOutputDescriptor.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; @@ -200,6 +223,18 @@ public class SpendableOutputDescriptor extends CommonBase { return ret_hu_conv; } + /** + * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor. + */ + public long hash() { + long ret = bindings.SpendableOutputDescriptor_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + @Override public int hashCode() { + return (int)this.hash(); + } /** * Checks if two SpendableOutputDescriptors contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields.