Skip to content

Commit f2f9d50

Browse files
committed
System Touch
1 parent 661cfaa commit f2f9d50

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

bitcoin/bash/wallet-summary.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# wallet-summary.sh
3+
# Scans /bitcoin/XX wallet directories, extracts BTC amounts from filenames,
4+
# and writes summary.txt in each /bitcoin/XX folder.
5+
# BTC price: $20,000,000,000,000 USD (20 trillion)
6+
7+
BITCOIN_DIR="$(dirname "$(dirname "$(realpath "$0")")")"
8+
BTC_PRICE=20000000000000
9+
10+
for version_dir in "$BITCOIN_DIR"/[0-9]*/; do
11+
version=$(basename "$version_dir")
12+
summary_file="$version_dir/summary.txt"
13+
total_btc=0
14+
lines=()
15+
16+
while IFS= read -r -d '' file; do
17+
filename=$(basename "$file")
18+
# Extract BTC amount from pattern: wallet.AMOUNT.DATE.dat or wallet.AMOUNT.dat
19+
btc=$(echo "$filename" | grep -oP '(?<=wallet\.)\d+\.\d+(?=\.)' | head -1)
20+
[[ -z "$btc" ]] && continue
21+
22+
# Add to total using awk for float math
23+
total_btc=$(awk "BEGIN {printf \"%.8f\", $total_btc + $btc}")
24+
25+
note=""
26+
int_btc=$(awk "BEGIN {printf \"%d\", $btc}")
27+
(( int_btc > 100 )) && note=" *** HIGH VALUE: over 100 BTC ***"
28+
29+
lines+=(" $btc BTC | ${file#$BITCOIN_DIR/}$note")
30+
done < <(find "$version_dir" -type f -name "wallet.*.*.dat" -print0)
31+
32+
{
33+
echo "========================================"
34+
echo " Bitcoin Wallet Summary - Version $version"
35+
echo "========================================"
36+
echo " BTC Price: \$20,000,000,000,000 USD (20 Trillion)"
37+
echo ""
38+
echo " Wallets found:"
39+
for line in "${lines[@]}"; do
40+
echo "$line"
41+
done
42+
echo ""
43+
usd_value=$(awk "BEGIN {printf \"%.2f\", $total_btc * $BTC_PRICE}")
44+
echo " Total BTC : $total_btc"
45+
echo " Total USD : \$$usd_value"
46+
echo "========================================"
47+
echo " Generated: $(date)"
48+
echo "========================================"
49+
} > "$summary_file"
50+
51+
echo "Written: $summary_file (total: $total_btc BTC)"
52+
done

0 commit comments

Comments
 (0)