Struct lightning::util::sweep::OutputSweeper
source · pub struct OutputSweeper<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref>where
B::Target: BroadcasterInterface,
D::Target: ChangeDestinationSource,
E::Target: FeeEstimator,
F::Target: Filter + Sync + Send,
K::Target: KVStore,
L::Target: Logger,
O::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§
source§impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> OutputSweeper<B, D, E, F, K, L, O>where
B::Target: BroadcasterInterface,
D::Target: ChangeDestinationSource,
E::Target: FeeEstimator,
F::Target: Filter + Sync + Send,
K::Target: KVStore,
L::Target: Logger,
O::Target: OutputSpender,
impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref> OutputSweeper<B, D, E, F, K, L, O>where
B::Target: BroadcasterInterface,
D::Target: ChangeDestinationSource,
E::Target: FeeEstimator,
F::Target: Filter + Sync + Send,
K::Target: KVStore,
L::Target: Logger,
O::Target: OutputSpender,
sourcepub 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
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
.
sourcepub 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.
sourcepub fn tracked_spendable_outputs(&self) -> Vec<TrackedSpendableOutput>
pub fn tracked_spendable_outputs(&self) -> Vec<TrackedSpendableOutput>
Returns a list of the currently tracked spendable outputs.