Open
Description
Currently, there is no straightforward way to generate a snapshot of a node's financial state (wallet balance and channel balances) at a given point in time. This command would be useful for auditing, tax reporting, or debugging balance discrepancies.
Proposed Solution: Create a new command, e.g., bkpr-snapshot
to:
- Support time granularity for periodic snapshots.
- Filter and aggregate events chronologically between start_time and end_time.
- Optionally filter by account (e.g., a specific channel or wallet).
- Output structured balance summaries per period.
Input Parameters:
- start_time (u32, optional): UNIX timestamp (in seconds) that filters events after the provided timestamp. The default is zero.
- end_time (u32, optional): UNIX timestamp (in seconds) that filters events up to and at the provided timestamp. The default is max-int.
- time_granularity (string, optional) (one of 'minutely', 'hourly', 'daily', 'weekly', 'monthly', 'yearly'): Snapshot frequency. The default is 'daily'.
- account (string, optional): If specified, filters snapshot for the specified account only.
Example Input:
lightning-cli bkpr-snapshot -k time_granularity=daily start_time=1743532200 end_time=1743704999
Example Output:
[
{
"period_key": "2025-04-02",
"total_balance_msat": 175018872090,
"wallet_balance_msat": 117499668000,
"channel_balances": {
"157x1x0": 551927030,
"151x1x0": 56967277060
}
},
{
"period_key": "2025-04-03",
"total_balance_msat": 175024926277,
"wallet_balance_msat": 117499668000,
"channel_balances": {
"157x1x0": 558081217,
"151x1x0": 56967177060
}
}
]