Struct OutputSweeper
pub struct OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,{ /* private fields */ }
Expand description
A utility that keeps track of SpendableOutputDescriptor
s, 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 SpendableOutputDescriptor
s 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§
§impl<B, D, E, F, K, L, O> OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
impl<B, D, E, F, K, L, O> OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
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,
) -> OutputSweeper<B, D, E, F, K, L, O>
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, ) -> OutputSweeper<B, D, E, F, K, L, O>
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
.
pub fn track_spendable_outputs(
&self,
output_descriptors: Vec<SpendableOutputDescriptor>,
channel_id: Option<ChannelId>,
exclude_static_outputs: bool,
delay_until_height: Option<u32>,
) -> Result<(), ()>
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::StaticOutput
s, 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.
pub fn tracked_spendable_outputs(&self) -> Vec<TrackedSpendableOutput>
pub fn tracked_spendable_outputs(&self) -> Vec<TrackedSpendableOutput>
Returns a list of the currently tracked spendable outputs.
pub fn current_best_block(&self) -> BestBlock
pub fn current_best_block(&self) -> BestBlock
Trait Implementations§
§impl<B, D, E, F, K, L, O> Confirm for OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
impl<B, D, E, F, K, L, O> Confirm for OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
§fn transactions_confirmed(
&self,
header: &Header,
txdata: &[(usize, &Transaction)],
height: u32,
)
fn transactions_confirmed( &self, header: &Header, txdata: &[(usize, &Transaction)], height: u32, )
§fn transaction_unconfirmed(&self, txid: &Txid)
fn transaction_unconfirmed(&self, txid: &Txid)
§fn best_block_updated(&self, header: &Header, height: u32)
fn best_block_updated(&self, header: &Header, height: u32)
§impl<B, D, E, F, K, L, O> Listen for OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
impl<B, D, E, F, K, L, O> Listen for OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
§fn filtered_block_connected(
&self,
header: &Header,
txdata: &[(usize, &Transaction)],
height: u32,
)
fn filtered_block_connected( &self, header: &Header, txdata: &[(usize, &Transaction)], height: u32, )
§fn block_disconnected(&self, header: &Header, height: u32)
fn block_disconnected(&self, header: &Header, height: u32)
§fn block_connected(&self, block: &Block, height: u32)
fn block_connected(&self, block: &Block, height: u32)
§impl<B, D, E, F, K, L, O> ReadableArgs<(B, E, Option<F>, O, D, K, L)> for OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
impl<B, D, E, F, K, L, O> ReadableArgs<(B, E, Option<F>, O, D, K, L)> for OutputSweeper<B, D, E, F, K, L, O>where
B: Deref,
D: Deref,
E: Deref,
F: Deref,
K: Deref,
L: Deref,
O: Deref,
<B as Deref>::Target: BroadcasterInterface,
<D as Deref>::Target: ChangeDestinationSource,
<E as Deref>::Target: FeeEstimator,
<F as Deref>::Target: Filter + Sync + Send,
<K as Deref>::Target: KVStore,
<L as Deref>::Target: Logger,
<O as Deref>::Target: OutputSpender,
§fn read<R>(
reader: &mut R,
args: (B, E, Option<F>, O, D, K, L),
) -> Result<OutputSweeper<B, D, E, F, K, L, O>, DecodeError>where
R: Read,
fn read<R>(
reader: &mut R,
args: (B, E, Option<F>, O, D, K, L),
) -> Result<OutputSweeper<B, D, E, F, K, L, O>, DecodeError>where
R: Read,
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>where
B: RefUnwindSafe,
E: RefUnwindSafe,
O: RefUnwindSafe,
D: RefUnwindSafe,
K: RefUnwindSafe,
L: RefUnwindSafe,
F: RefUnwindSafe,
impl<B, D, E, F, K, L, O> Send for OutputSweeper<B, D, E, F, K, L, O>
impl<B, D, E, F, K, L, O> Sync for OutputSweeper<B, D, E, F, K, L, O>
impl<B, D, E, F, K, L, O> Unpin for OutputSweeper<B, D, E, F, K, L, O>
impl<B, D, E, F, K, L, O> UnwindSafe for OutputSweeper<B, D, E, F, K, L, O>where
B: UnwindSafe,
E: UnwindSafe,
O: UnwindSafe,
D: UnwindSafe,
K: UnwindSafe,
L: UnwindSafe,
F: UnwindSafe,
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
§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
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