Enum SpendableOutputDescriptor

Source
pub enum SpendableOutputDescriptor {
    StaticOutput {
        outpoint: OutPoint,
        output: TxOut,
    },
    DelayedPaymentOutput(DelayedPaymentOutputDescriptor),
    StaticPaymentOutput(StaticPaymentOutputDescriptor),
}
Expand description

Describes the necessary information to spend a spendable output.

When on-chain outputs are created by LDK (which our counterparty is not able to claim at any point in the future) a SpendableOutputs event is generated which you must track and be able to spend on-chain. The information needed to do this is provided in this enum, including the 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.

Variants§

§

StaticOutput

An output to a script which was provided via KeysInterface 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.

Fields

§outpoint: OutPoint

The outpoint which is spendable.

§output: TxOut

The output which is referenced by the given outpoint.

§

DelayedPaymentOutput(DelayedPaymentOutputDescriptor)

An output to a P2WSH script which can be spent with a single signature after an OP_CSV delay.

The witness in the spending input should be:

<BIP 143 signature> <empty vector> (MINIMALIF standard rule) <provided witnessScript>

Note that the nSequence field in the spending input must be set to DelayedPaymentOutputDescriptor::to_self_delay (which means the transaction is not broadcastable until at least DelayedPaymentOutputDescriptor::to_self_delay blocks after the outpoint confirms, see BIP 68). Also note that LDK won’t generate a SpendableOutputDescriptor until the corresponding block height is reached.

These are generally the result of a “revocable” output to us, spendable only by us unless it is an output from an old state which we broadcast (which should never happen).

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.

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 DelayedPaymentOutputDescriptor::per_commitment_point to chan_utils::derive_public_revocation_key.

The witness script which is hashed and included in the output script_pubkey may be regenerated by passing the DelayedPaymentOutputDescriptor::revocation_pubkey (derived as explained above), our delayed payment pubkey (derived as explained above), and the DelayedPaymentOutputDescriptor::to_self_delay contained here to chan_utils::get_revokeable_redeemscript.

§

StaticPaymentOutput(StaticPaymentOutputDescriptor)

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:

<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.

Trait Implementations§

Source§

impl Clone for SpendableOutputDescriptor

Source§

fn clone(&self) -> SpendableOutputDescriptor

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpendableOutputDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SpendableOutputDescriptor

Source§

fn eq(&self, other: &SpendableOutputDescriptor) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Readable for SpendableOutputDescriptor

Source§

fn read<R: Read>(reader: &mut R) -> Result<Self, DecodeError>

Reads a Self in from the given Read
Source§

impl Writeable for SpendableOutputDescriptor

Source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Writes self out to the given Writer
Source§

fn encode(&self) -> Vec<u8>

Writes self out to a Vec
Source§

fn serialized_length(&self) -> usize

Gets the length of this object after it has been serialized. This can be overridden to optimize cases where we prepend an object with its length.
Source§

impl Eq for SpendableOutputDescriptor

Source§

impl StructuralPartialEq for SpendableOutputDescriptor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeReadable for T
where T: Readable,

Source§

fn read<R>(reader: &mut R) -> Result<Option<T>, DecodeError>
where R: Read,

Reads a Self in from the given Read
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.