Skip to content

Commit

Permalink
Add OutputSweeper utility persisting and sweeping spendable outputs
Browse files Browse the repository at this point in the history
We add a `OutputSweeper` utility that allows to track the state of
spendable output descriptors as emitted by `Event::SpendableOutputs`.

To this end, the `OutputSweeper` persists the necessary information in
our `KVStore` and regularly tries to sweep the spendable outputs,
removing them after reaching threshold confirmations, i.e.,
`ANTI_REORG_DELAY`.
  • Loading branch information
tnull committed Jan 15, 2024
1 parent 78ac48c commit 64bf2f6
Show file tree
Hide file tree
Showing 3 changed files with 687 additions and 0 deletions.
1 change: 1 addition & 0 deletions lightning/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod message_signing;
pub mod invoice;
pub mod persist;
pub mod string;
pub mod sweep;
pub mod wakers;
#[cfg(fuzzing)]
pub mod base32;
Expand Down
11 changes: 11 additions & 0 deletions lightning/src/util/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ pub const SCORER_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";
/// The key under which the [`WriteableScore`] will be persisted.
pub const SCORER_PERSISTENCE_KEY: &str = "scorer";

/// The primary namespace under which [`TrackedSpendableOutput`]s will be persisted by [`OutputSweeper`].
///
/// [`TrackedSpendableOutput`]: crate::util::sweep::TrackedSpendableOutput
/// [`OutputSweeper`]: crate::util::sweep::OutputSweeper
pub const SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE: &str = "spendable_outputs";
/// The secondary namespace under which [`TrackedSpendableOutput`]s will be persisted by [`OutputSweeper`].
///
/// [`TrackedSpendableOutput`]: crate::util::sweep::TrackedSpendableOutput
/// [`OutputSweeper`]: crate::util::sweep::OutputSweeper
pub const SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";

/// A sentinel value to be prepended to monitors persisted by the [`MonitorUpdatingPersister`].
///
/// This serves to prevent someone from accidentally loading such monitors (which may need
Expand Down
Loading

0 comments on commit 64bf2f6

Please sign in to comment.