Skip to content

Commit 37b7f51

Browse files
committed
add cleanwallets-mainnet.sh
1 parent 668b5b6 commit 37b7f51

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

cleanwallets-mainnet.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env bash
2+
3+
determine_komodo_cli() {
4+
local cli_path
5+
# Check system-wide installation
6+
cli_path=$(command -v komodo-cli 2>/dev/null)
7+
if [[ -x "$cli_path" ]]; then
8+
echo "Found system-wide komodo-cli at: $cli_path" >&2
9+
echo "$cli_path"
10+
return 0
11+
fi
12+
13+
# Check in ~/komodo/src
14+
cli_path="$HOME/komodo/src/komodo-cli"
15+
if [[ -x "$cli_path" ]]; then
16+
echo "Found komodo-cli at: $cli_path" >&2
17+
echo "$cli_path"
18+
return 0
19+
fi
20+
21+
# Check in ~/KomodoOcean/src
22+
cli_path="$HOME/KomodoOcean/src/komodo-cli"
23+
if [[ -x "$cli_path" ]]; then
24+
echo "Found komodo-cli at: $cli_path" >&2
25+
echo "$cli_path"
26+
return 0
27+
fi
28+
29+
# komodo-cli not found
30+
echo -e "${RED}Error:${RESET} komodo-cli not found in system-wide path, $HOME/komodo/src, or $HOME/KomodoOcean/src." >&2
31+
exit 1
32+
}
33+
34+
# Function to source pubkey.txt from multiple locations
35+
source_pubkey() {
36+
local pubkey_file
37+
local found=0
38+
39+
# Define the search order
40+
local search_paths=(
41+
"$HOME/komodo/src/pubkey.txt"
42+
"$HOME/KomodoOcean/src/pubkey.txt"
43+
"$HOME/pubkey.txt"
44+
)
45+
46+
# Iterate through the search paths
47+
for pubkey_file in "${search_paths[@]}"; do
48+
if [[ -f "$pubkey_file" ]]; then
49+
echo "Found pubkey.txt at: $pubkey_file" >&2
50+
source "$pubkey_file"
51+
found=1
52+
break
53+
fi
54+
done
55+
56+
# Check if pubkey.txt was found and sourced
57+
if [[ "$found" -ne 1 ]]; then
58+
echo -e "${RED}Error:${RESET} pubkey.txt not found in any of the specified locations." >&2
59+
exit 1
60+
fi
61+
62+
# Ensure that the pubkey environment variable is set
63+
if [[ -z "$pubkey" ]]; then
64+
echo -e "${RED}Error:${RESET} pubkey environment variable is not set after sourcing pubkey.txt." >&2
65+
exit 1
66+
fi
67+
68+
echo -e "Pubkey: \"${pubkey}\""
69+
}
70+
71+
komodo_cli_binary=$(determine_komodo_cli)
72+
source_pubkey
73+
KMD_ADDRESS=$(${komodo_cli_binary} decodescript "21${pubkey}ac" | jq -r .addresses[0])
74+
printf "KMD Address: ${YELLOW}%-40s${RESET}\n" "$KMD_ADDRESS"
75+
76+
#readarray -t kmd_coins < <(curl -s https://raw.githubusercontent.com/KomodoPlatform/dPoW/master/iguana/assetchains.json | jq -r '[.[].ac_name] | join("\n")')
77+
readarray -t kmd_coins < <(cat $HOME/dPoW/iguana/assetchains.json | jq -r '[.[].ac_name] | join("\n")')
78+
79+
gleec_count=0
80+
for i in "${kmd_coins[@]}"
81+
do
82+
if [[ "$i" == "GLEEC" ]]; then
83+
((gleec_count++))
84+
85+
if [[ "$gleec_count" -eq 1 ]]; then
86+
echo Processing "GLEEC_OLD" 1>&2
87+
${komodo_cli_binary} -ac_name="GLEEC" -datadir="$HOME/.komodo/GLEEC_OLD" cleanwallettransactions
88+
elif [[ "$gleec_count" -eq 2 ]]; then
89+
echo Processing "GLEEC" 1>&2
90+
${komodo_cli_binary} -ac_name="GLEEC" cleanwallettransactions
91+
else
92+
echo -e "GLEEC has been encountered more than twice. No additional actions will be performed." >&2
93+
fi
94+
continue
95+
fi
96+
97+
echo Processing "$i" 1>&2
98+
#time (${komodo_cli_binary} -ac_name="$i" listunspent | jq '. | { "utxos" : length }' && ${komodo_cli_binary} -ac_name="$i" getwalletinfo | jq '{ "txcount" : .txcount }') | jq -s add
99+
#${komodo_cli_binary} -ac_name="$i" z_mergetoaddress '["ANY_TADDR"]' $KMD_ADDRESS 0.001 0
100+
${komodo_cli_binary} -ac_name="$i" cleanwallettransactions
101+
done
102+
103+
echo Processing "KMD" 1>&2
104+
${komodo_cli_binary} cleanwallettransactions
105+
echo Processing "LTC" 1>&2
106+
$HOME/litecoin/src/litecoin-cli cleanwallettransactions
107+
108+

0 commit comments

Comments
 (0)