* 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 {
* 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;
long output = obj.output;
TxOut output_conv = new TxOut(null, output);
this.output = output_conv;
+ this.channel_keys_id = obj.channel_keys_id;
}
}
/**
* 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 [`ChannelSigner::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
+ * [`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
* [`ChannelPublicKeys::revocation_basepoint`] (which appears in the call to
* [`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
}
}
/**
- * An output to a P2WPKH, spendable exclusively by our payment key (i.e., the private key
- * which corresponds to the `payment_point` in [`ChannelSigner::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
+ * <BIP 143 signature> <witness script>
+ * ```
+ *
+ * Otherwise, it is:
* ```bitcoin
* <BIP 143 signature> <payment key>
* ```
*
* 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;
/**
* 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.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); };
- if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(outpoint); };
return ret_hu_conv;
}
* Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor
*/
public static SpendableOutputDescriptor delayed_payment_output(org.ldk.structs.DelayedPaymentOutputDescriptor a) {
- long ret = bindings.SpendableOutputDescriptor_delayed_payment_output(a == null ? 0 : a.ptr);
+ long ret = bindings.SpendableOutputDescriptor_delayed_payment_output(a.ptr);
Reference.reachabilityFence(a);
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); };
- if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
return ret_hu_conv;
}
* Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor
*/
public static SpendableOutputDescriptor static_payment_output(org.ldk.structs.StaticPaymentOutputDescriptor a) {
- long ret = bindings.SpendableOutputDescriptor_static_payment_output(a == null ? 0 : a.ptr);
+ long ret = bindings.SpendableOutputDescriptor_static_payment_output(a.ptr);
Reference.reachabilityFence(a);
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); };
- if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(a); };
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.
*/
public boolean eq(org.ldk.structs.SpendableOutputDescriptor b) {
- boolean ret = bindings.SpendableOutputDescriptor_eq(this.ptr, b == null ? 0 : b.ptr);
+ boolean ret = bindings.SpendableOutputDescriptor_eq(this.ptr, b.ptr);
Reference.reachabilityFence(this);
Reference.reachabilityFence(b);
return ret;