Struct lightning::util::sweep::OutputSweeper

source ·
pub struct OutputSweeper<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref>{ /* private fields */ }
Expand description

A utility that keeps track of SpendableOutputDescriptors, persists them in a given KVStore and regularly retries sweeping them based on a callback given to the constructor methods.

Users should call Self::track_spendable_outputs for any SpendableOutputDescriptors received via Event::SpendableOutputs.

This needs to be notified of chain state changes either via its Listen or Confirm implementation and hence has to be connected with the utilized chain data sources.

If chain data is provided via the Confirm interface or via filtered blocks, users are required to give their chain data sources (i.e., Filter implementation) to the respective constructor.

Implementations§

source§

impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> OutputSweeper<B, D, E, F, K, L, O>

source

pub fn new( best_block: BestBlock, broadcaster: B, fee_estimator: E, chain_data_source: Option<F>, output_spender: O, change_destination_source: D, kv_store: K, logger: L ) -> Self

Constructs a new OutputSweeper.

If chain data is provided via the Confirm interface or via filtered blocks, users also need to register their Filter implementation via the given chain_data_source.

source

pub fn track_spendable_outputs( &self, output_descriptors: Vec<SpendableOutputDescriptor>, channel_id: Option<ChannelId>, exclude_static_outputs: bool, delay_until_height: Option<u32> ) -> Result<(), ()>

Tells the sweeper to track the given outputs descriptors.

Usually, this should be called based on the values emitted by the Event::SpendableOutputs.

The given exclude_static_outputs flag controls whether the sweeper will filter out SpendableOutputDescriptor::StaticOutputs, which may be handled directly by the on-chain wallet implementation.

If delay_until_height is set, we will delay the spending until the respective block height is reached. This can be used to batch spends, e.g., to reduce on-chain fees.

Returns Err on persistence failure, in which case the call may be safely retried.

source

pub fn tracked_spendable_outputs(&self) -> Vec<TrackedSpendableOutput>

Returns a list of the currently tracked spendable outputs.

source

pub fn current_best_block(&self) -> BestBlock

Gets the latest best block which was connected either via the Listen or Confirm interfaces.

Trait Implementations§

source§

impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> Confirm for OutputSweeper<B, D, E, F, K, L, O>

source§

fn transactions_confirmed( &self, header: &Header, txdata: &TransactionData<'_>, height: u32 )

Notifies LDK of transactions confirmed in a block with a given header and height. Read more
source§

fn transaction_unconfirmed(&self, txid: &Txid)

Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization. Read more
source§

fn best_block_updated(&self, header: &Header, height: u32)

Notifies LDK of an update to the best header connected at the given height. Read more
source§

fn get_relevant_txids(&self) -> Vec<(Txid, u32, Option<BlockHash>)>

Returns transactions that must be monitored for reorganization out of the chain along with the height and the hash of the block as part of which it had been previously confirmed. Read more
source§

impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> Listen for OutputSweeper<B, D, E, F, K, L, O>

source§

fn filtered_block_connected( &self, header: &Header, txdata: &TransactionData<'_>, height: u32 )

Notifies the listener that a block was added at the given height, with the transaction data possibly filtered.
source§

fn block_disconnected(&self, header: &Header, height: u32)

Notifies the listener that a block was removed at the given height.
source§

fn block_connected(&self, block: &Block, height: u32)

Notifies the listener that a block was added at the given height.
source§

impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> ReadableArgs<(B, E, Option<F>, O, D, K, L)> for OutputSweeper<B, D, E, F, K, L, O>

source§

fn read<R: Read>( reader: &mut R, args: (B, E, Option<F>, O, D, K, L) ) -> Result<Self, DecodeError>

Reads a Self in from the given Read.

Auto Trait Implementations§

§

impl<B, D, E, F, K, L, O> !Freeze for OutputSweeper<B, D, E, F, K, L, O>

§

impl<B, D, E, F, K, L, O> RefUnwindSafe for OutputSweeper<B, D, E, F, K, L, O>

§

impl<B, D, E, F, K, L, O> Send for OutputSweeper<B, D, E, F, K, L, O>
where B: Send, E: Send, O: Send, D: Send, K: Send, L: Send, F: Send,

§

impl<B, D, E, F, K, L, O> Sync for OutputSweeper<B, D, E, F, K, L, O>
where B: Sync, E: Sync, O: Sync, D: Sync, K: Sync, L: Sync, F: Sync,

§

impl<B, D, E, F, K, L, O> Unpin for OutputSweeper<B, D, E, F, K, L, O>
where B: Unpin, E: Unpin, O: Unpin, D: Unpin, K: Unpin, L: Unpin, F: Unpin,

§

impl<B, D, E, F, K, L, O> UnwindSafe for OutputSweeper<B, D, E, F, K, L, O>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.