#!/usr/bin/env bash # # That the wallets stay removed: docs/giza-wallet-removal.md, Phase 8. # # docs/scripts/wallet-audit.sh lists the lines that break a rule # docs/scripts/wallet-audit.sh --check and exits 1 if there are any # # Giza keeps no wallet, and Bennu, which it takes fixes from, keeps several. Four rules # catch one coming back: # # 1. a retired kind's number (30331-30337, 30350-30366) in the app's own code. They # are Bennu's and stay reserved -- RetiredKinds.kt says why. Allowed in that file, # in the migrations (which have to keep meaning what they meant) and in tests, which # assert that Giza declines them; # 2. an import of lightning-kmp (`fr.acinq.lightning`). Nothing in the app needs it; # 3. a source file named for one of the wallets' own pieces -- the group wallet, the # Lightning wallet, Iceberg, guardians, member and guarded wallets, spends, # transactions, Electrum. Named rather than every *Wallet*: the profile pickers under # widgets/wallet/ and the SovereignWallet* startup kept Phoenix-era names, and the # files that decline a wallet (WalletRefusal, RemoveWalletsMigration) are about one; # 4. an amount in sats in a string a person reads. # # Needs only bash and git, like the other two audits, so the CI budgets job can run it. set -uo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/../.." || exit 1 CHECK=0 [[ "${1:-}" == "--check" ]] && CHECK=1 MAIN=(composeApp/src/commonMain composeApp/src/androidMain composeApp/src/jvmMain composeApp/src/iosMain) kinds=$( git grep -nE '\b303(3[1-7]|5[0-9]|6[0-6])\b' -- "${MAIN[@]}" \ ':!*/nostr/RetiredKinds.kt' ':!*/database/migrations/*' ) lightning=$(git grep -nE '^import fr\.acinq\.lightning' -- composeApp) files=$( git ls-files composeApp/src \ | grep -E '/(GroupWallet|GroupLightning|Iceberg|Guardian|GuardedWallet|MemberWallet|MemberSend|GroupSend|GroupSpend|GroupTransaction|GroupOnchain|GroupChainClients|StandaloneElectrum|IdentityElectrum|ProposedSpend)[A-Za-z]*\.kt$' ) sats=$(git grep -niE '>[^<]*\b(sats?|satoshis?)\b' -- composeApp/src/commonMain/composeResources) report() { local title=$1 lines=$2 n=0 [[ -n "$lines" ]] && n=$(printf '%s\n' "$lines" | wc -l) echo "$title: $n" [[ -n "$lines" ]] && printf '%s\n' "$lines" | sed 's/^/ /' total=$((total + n)) } total=0 report "Retired wallet kinds in the app's code" "$kinds" report "lightning-kmp imports" "$lightning" report "Files named for a wallet's pieces" "$files" report "Amounts in sats in the strings" "$sats" if (( CHECK && total > 0 )); then echo "Giza keeps no wallet. See docs/giza-wallet-removal.md before bringing one back." >&2 exit 1 fi exit 0