breez_sdk_liquid::lightning::sign

Enum SpendableOutputDescriptor

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

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 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 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 ChannelSigner::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 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:

<BIP 143 signature> <witness script>

Otherwise, it is:

<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, or after one confirmation in the case of anchor outputs channels.

Implementations§

§

impl SpendableOutputDescriptor

pub fn to_psbt_input(&self) -> Input

Turns this into a bitcoin::psbt::Input which can be used to create a PartiallySignedTransaction which spends the given descriptor.

Note that this does not include any signatures, just the information required to construct the transaction and sign it.

This is not exported to bindings users as there is no standard serialization for an input. See Self::create_spendable_outputs_psbt instead.

pub fn create_spendable_outputs_psbt( descriptors: &[&SpendableOutputDescriptor], outputs: Vec<TxOut>, change_destination_script: Script, feerate_sat_per_1000_weight: u32, locktime: Option<PackedLockTime>, ) -> Result<(PartiallySignedTransaction, usize), ()>

Creates an unsigned PartiallySignedTransaction which spends the given descriptors to the given outputs, plus an output to the given change destination (if sufficient change value remains). The PSBT will have a feerate, at least, of the given value.

The locktime argument is used to set the transaction’s locktime. If None, the transaction will have a locktime of 0. It it recommended to set this to the current block height to avoid fee sniping, unless you have some specific reason to use a different locktime.

Returns the PSBT and expected max transaction weight.

Returns Err(()) if the output value is greater than the input value minus required fee, if a descriptor was duplicated, or if an output descriptor script_pubkey does not match the one we can spend.

We do not enforce that outputs meet the dust limit or that any output scripts are standard.

Trait Implementations§

§

impl Clone for SpendableOutputDescriptor

§

fn clone(&self) -> SpendableOutputDescriptor

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Debug for SpendableOutputDescriptor

§

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

Formats the value using the given formatter. Read more
§

impl Hash for SpendableOutputDescriptor

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for SpendableOutputDescriptor

§

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

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

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

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

impl Readable for SpendableOutputDescriptor

§

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

Reads a Self in from the given Read.
§

impl Writeable for SpendableOutputDescriptor

§

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

Writes self out to the given Writer.
§

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

Writes self out to a Vec<u8>.
§

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

impl Eq for SpendableOutputDescriptor

§

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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, dst: *mut T)

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

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

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

§

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

Reads a Self in from the given Read.
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> DartSafe for T

§

impl<T> TaskRetFutTrait for T
where T: Send,