Skip to content

Commit 43a0c6c

Browse files
committed
Add OutputSweeper utility persisting and sweeping spendable outputs
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`.
1 parent 78ac48c commit 43a0c6c

File tree

3 files changed

+682
-0
lines changed

3 files changed

+682
-0
lines changed

lightning/src/util/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub mod message_signing;
2121
pub mod invoice;
2222
pub mod persist;
2323
pub mod string;
24+
pub mod sweep;
2425
pub mod wakers;
2526
#[cfg(fuzzing)]
2627
pub mod base32;

lightning/src/util/persist.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ pub const SCORER_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";
6565
/// The key under which the [`WriteableScore`] will be persisted.
6666
pub const SCORER_PERSISTENCE_KEY: &str = "scorer";
6767

68+
/// The primary namespace under which [`TrackedSpendableOutput`]s will be persisted by [`OutputSweeper`].
69+
///
70+
/// [`TrackedSpendableOutput`]: crate::util::sweep::TrackedSpendableOutput
71+
/// [`OutputSweeper`]: crate::util::sweep::OutputSweeper
72+
pub const SPENDABLE_OUTPUT_INFO_PERSISTENCE_PRIMARY_NAMESPACE: &str = "spendable_outputs";
73+
/// The secondary namespace under which [`TrackedSpendableOutput`]s will be persisted by [`OutputSweeper`].
74+
///
75+
/// [`TrackedSpendableOutput`]: crate::util::sweep::TrackedSpendableOutput
76+
/// [`OutputSweeper`]: crate::util::sweep::OutputSweeper
77+
pub const SPENDABLE_OUTPUT_INFO_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";
78+
6879
/// A sentinel value to be prepended to monitors persisted by the [`MonitorUpdatingPersister`].
6980
///
7081
/// This serves to prevent someone from accidentally loading such monitors (which may need

0 commit comments

Comments
 (0)