upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-money-log-lines.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/check-money-log-lines.sh b/scripts/check-money-log-lines.sh
new file mode 100755
index 0000000..c9f348b
--- /dev/null
+++ b/scripts/check-money-log-lines.sh
@@ -0,0 +1,38 @@
1#!/usr/bin/env bash
2# Money-moving payout lines must print every time they fire: they are the
3# audit trail for obligations created, moved and destroyed, and LogPrint's
4# burst collapse can stand one line in for any number of events inside one
5# 3-second window (issue #3: 100 voids totalling 4,950 BTF read as one
6# 49.49 BTF line). Every line carrying one of the phrases below must use
7# LogPrintAlways, which keeps the category gate but skips the collapse.
8#
9# Adding a payout line that reports money moving? Use LogPrintAlways and
10# add its phrase here. A phrase found in a plain LogPrint call fails this
11# check; anything else passes, so a non-money line is never held up by it.
12set -euo pipefail
13cd "$(dirname "$0")/.."
14
15phrases='was orphaned -- voiding|orphaned while queued|\[payout\] paid %s to %s|FAILED to pay|writing off|SKIPPED bad address'
16
17# Call sites span several lines; flatten each call to a single line first so
18# the phrase and the macro it belongs to are matched together. Only a line
19# whose first token is the macro starts a call, so comments mentioning
20# LogPrint are never mistaken for one.
21bad=$(awk '
22 /^[ \t]*LogPrint(Always)?[(]/ {
23 if (collecting) print buf
24 buf = $0; collecting = 1; next
25 }
26 collecting {
27 buf = buf $0
28 if (/;[ \t]*$/) { print buf; collecting = 0 }
29 }
30 END { if (collecting) print buf }
31' src/rpc.cpp | grep -E '^[[:space:]]*LogPrint[(]' | grep -E "$phrases" || true)
32
33if [ -n "$bad" ]; then
34 echo "error: money-moving payout line(s) on collapsing LogPrint:" >&2
35 echo "$bad" >&2
36 exit 1
37fi
38echo "ok: every money-moving payout line in src/rpc.cpp uses LogPrintAlways"