/d/Monero

N/A subscribers

N/A


[code release] a simple xmr mutli wallet balance checker.

by /u/GatorQuest · 0 votes · 2024-05-06 22:44:00

Hi all,
If your like me and have loads of wallets in your monero directory and your not sure exactly how much balance you have, I have written a small script that might help you.
After years of XMR usage, over hundreds of different wallets I was sure that i definitely had lots of change and forgotten wallets which likely total up to a significant amount of balance. I wrote this script to check the total balance of all my wallets, and it turns out I have a LOT of XMR leftover in them.

#!/bin/bash
# e.g: /home/user/Monero/wallets
WALLETS_DIR="Your_wallet_location_folder"

total_balance=0.0000000

declare -A processed_wallets

for wallet_folder in "$WALLETS_DIR"/*; do
    if [ -d "$wallet_folder" ]; then

        wallet_name=$(basename "$wallet_folder")

	primary_address=$(echo -e "\n" | monero-wallet-cli --wallet-file "$wallet_folder/$wallet_name" address primary | grep "Opened wallet: " | awk '{print $3}')

	if [ -n "${processed_wallets[$primary_address]}" ]; then
            echo "Skipping duplicate wallet: $primary_address"
            continue
        fi

        processed_wallets["$primary_address"]=1

	sync_status=$(echo -e "\n" | monero-wallet-cli --wallet-file "$wallet_folder/$wallet_name" refresh | grep "Refresh done, blocks received:")

	if [ -n "$sync_status" ]; then
	    echo "Wallet is fully synchronized."
	else
	    sync_percentage=$(echo "$sync_status" | awk '{print $6}')
	    echo "Synchronization progress: $sync_percentage"
	fi

        # Run monero-wallet-cli to get the balance (press Enter when prompted for a password)
        balance=$(echo -e "\n" | monero-wallet-cli --wallet-file "$wallet_folder/$wallet_name" balance | grep "Balance:" | awk '{print $2}')
        balance=$(echo "$balance" | sed 's/,$//')

	echo "Adding balance: $balance"
	total_balance=$(echo $total_balance $balance | awk '{print $1 + $2}')
	echo "New total balance: $total_balance"
        echo "Wallet: $wallet_name"
        echo "Address: $primary_address"
        echo "Balance: $balance XMR"
        echo "Total So Far: $total_balance XMR"
        echo
    fi
done

echo "Overall Total XMR: $total_balance XMR"


I hope this helps you find some of your lost moneros

Comments (7)
/u/localnoderunner · N/A votes · 6th May, 2024 - 23:30 · Link

Based and bash-pilled, that's an upvote

/u/Sammox · N/A votes · 7th May, 2024 - 01:18 · Link

This is great, thank you for sharing. So this only works with addresses in your own wallet, right? You can't watch other people's addresses like you can with bitcoin, right? That would hurt a key privacy feature of XMR.

/u/Moitoza · N/A votes · 7th May, 2024 - 02:20 · Link

Yeah, it only works with your own wallets.

/u/hydronerd · N/A votes · 7th May, 2024 - 01:26 · Link

This is cool and all but what is the difference between this and the Monero GUI which automatically adds up all of the money you have in all of your wallets and displays that on your home page?

/u/GatorQuest · N/A votes · 7th May, 2024 - 22:59 · Link

What you are referring to are sub addresses, within 1 wallet. This script is for people who have hundreds of different wallets. I have lots of old qubes backups, I restored the qubes I used for monero and collected all the wallet folders into 1 main qube. If your a heavy user, this can easily total hundreds of different wallets. This will total up all of your change, forgotten about funds etc and show you exactly how much you can recover.

/u/hydronerd · N/A votes · 7th May, 2024 - 23:23 · Link

Ahhh understood. thanks for the clarification!

/u/BigDaddy2K · N/A votes · 7th May, 2024 - 05:17 · Link

Amazing info!

/u/gemini · N/A votes · 7th May, 2024 - 05:34 · Link

nice code mate, i like bash script

/u/cocainehippy · N/A votes · 7th May, 2024 - 20:55 · Link

This is amazing, thanks for posting it here.

/u/Amphora · N/A votes · 6th May, 2024 - 22:51 · Link

Take my upvote! Cross-post this to /d/CafeDread - I'm sure they might like it.

/u/GatorQuest · N/A votes · 6th May, 2024 - 22:52 · Link

Thanks. done.

/u/Amphora · N/A votes · 6th May, 2024 - 23:10 · Link

Good work!