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
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
impl SpendableOutputDescriptor
pub fn to_psbt_input(&self) -> Input
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), ()>
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
impl Clone for SpendableOutputDescriptor
§fn clone(&self) -> SpendableOutputDescriptor
fn clone(&self) -> SpendableOutputDescriptor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for SpendableOutputDescriptor
impl Debug for SpendableOutputDescriptor
§impl Hash for SpendableOutputDescriptor
impl Hash for SpendableOutputDescriptor
§impl PartialEq for SpendableOutputDescriptor
impl PartialEq for SpendableOutputDescriptor
§impl Readable for SpendableOutputDescriptor
impl Readable for SpendableOutputDescriptor
§fn read<R>(reader: &mut R) -> Result<SpendableOutputDescriptor, DecodeError>where
R: Read,
fn read<R>(reader: &mut R) -> Result<SpendableOutputDescriptor, DecodeError>where
R: Read,
Self
in from the given Read
.§impl Writeable for SpendableOutputDescriptor
impl Writeable for SpendableOutputDescriptor
impl Eq for SpendableOutputDescriptor
impl StructuralPartialEq for SpendableOutputDescriptor
Auto Trait Implementations§
impl Freeze for SpendableOutputDescriptor
impl RefUnwindSafe for SpendableOutputDescriptor
impl Send for SpendableOutputDescriptor
impl Sync for SpendableOutputDescriptor
impl Unpin for SpendableOutputDescriptor
impl UnwindSafe for SpendableOutputDescriptor
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request