lightning-terminal/rules
bitromortac b1593b9bee
rules: improve channel-restriction resilience
The channel-restriction rule was previously fragile because it failed to
initialize when a restricted channel was closed while the session was
inactive. This often caused unnecessary session invalidation and blocked
users from managing their nodes.

This change makes the rule resilient by allowing it to start even if
some channels in the deny-list are missing from the node's current
active set. To maintain high performance, this implements a negative
cache that tracks unknown channel IDs, shielding LND from redundant RPC
calls during request evaluation.

Only having a negative cache without invalidation can be a security
problem. Someone could apply a rule with a future guessed channel id
such that the channel restriction populates the checkedIDs map with it.
After the channel was opened, we'd then allow making actions on the
channel because we don't know about the channel's id in the getChannelID
check.

To ensure security isn't compromised by the cache, this adds a
self-healing retry mechanism. If the firewall encounters an unknown
channel outpoint while it still has unmapped restricted IDs, it clears
the negative cache and forces a single retry in the next RPC call. This
ensures that any newly opened restricted channels are correctly
identified and blocked without adding latency to the common path.

Note: This approach deliberately accepts potential cache thrashing in the
edge case where a user repeatedly requests an unknown channel point
while a permanently missing ID exists in the deny list. This trade-off
is accepted to prioritize security (fail close) over performance in this
specific invalid state.
2026-02-04 13:31:09 +01:00
..
docs rules: add on-chain budget 2024-07-02 18:21:41 +02:00
chan_policy_bounds.go multi: thread contexts through privacy map interfaces 2025-03-25 18:10:52 +02:00
chan_policy_bounds_test.go rules: restrict initial channel fee parameters 2024-07-02 18:21:41 +02:00
channel_constraints.go multi: thread contexts through privacy map interfaces 2025-03-25 18:10:52 +02:00
channel_constraints_test.go rules: add channel open constraints 2024-07-02 18:21:41 +02:00
channel_restrictions.go rules: improve channel-restriction resilience 2026-02-04 13:31:09 +01:00
channel_restrictions_test.go rules: improve channel-restriction resilience 2026-02-04 13:31:09 +01:00
config.go multi: rename ActionsDB to ActionsListDB 2025-05-07 13:30:34 +02:00
history_limit.go multi: reformat long lines for readability 2025-12-09 16:12:03 +00:00
history_limit_test.go multi: reformat long lines for readability 2025-12-09 16:12:03 +00:00
interfaces.go multi: thread contexts through privacy map interfaces 2025-03-25 18:10:52 +02:00
log.go multi: update LND and friends 2025-03-26 09:20:52 -05:00
manager_set.go rules: thread context through 2025-01-13 09:23:20 +02:00
mock.go firewalldb+rules: thread contexts through KVStores methods 2025-03-11 15:44:15 -05:00
onchain_budget.go multi: reformat long lines for readability 2025-12-09 16:12:03 +00:00
onchain_budget_test.go multi: reformat long lines for readability 2025-12-09 16:12:03 +00:00
peer_restrictions.go firewalldb: thread context to PseudoToReal 2025-03-25 18:10:52 +02:00
peer_restrictions_test.go rules: add test to demo failure for closed channels 2026-02-03 15:40:13 +01:00
rate_limit.go multi: rename ActionsDB to ActionsListDB 2025-05-07 13:30:34 +02:00
rate_limit_test.go multi: reformat long lines for readability 2025-12-09 16:12:03 +00:00