Created
February 20, 2024 21:18
-
-
Save PastaGringo/8481818829e6645ac65a54e9e52c1c07 to your computer and use it in GitHub Desktop.
Retrieving Nsec and Npub from Atomstr database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
clear | |
echo | |
echo " Welcome to" | |
echo | |
echo " --- Atomstr Hex to Nsec keys convertor ---" | |
echo | |
echo " by PastaGringo" | |
echo | |
echo "Checking if Docker is installed..." | |
if ! command -v docker &> /dev/null | |
then | |
echo "Docker is not installed ❌" | |
echo "Please install Docker before running this script." | |
echo | |
exit 1 | |
fi | |
echo "Docker is installed ✅" | |
echo | |
echo "Checking if sqlite3 is installed..." | |
if ! command -v sqlite3 &> /dev/null | |
then | |
echo "=> sqlite3 is not installed ❌" | |
echo "Please install sqlite3 before running this script." | |
echo | |
exit 1 | |
fi | |
echo "=> sqlite3 is installed ✅" | |
echo | |
echo "Checking if the file atomstr.db is in the current directory..." | |
if ! test -f ./atomstr.db; then | |
echo "=> atomstr.db is not into the current directory! ❌" | |
echo "Please run script the again where the atomstr.db file is located." | |
echo | |
exit 1 | |
else | |
echo "=> atomstr.db is well in the directory! ✅" | |
fi | |
echo | |
read -p "Please enter the Atomstr container name or ID [default is container name: atomstr] " name | |
name=${name:-atomstr} | |
echo $name | |
echo | |
echo "Checking if container $name exists..." | |
output=$( docker ps -a -f name=$name | grep $name 2> /dev/null ) | |
if [[ ! -z ${output} ]]; | |
then | |
echo "=> A container with a name $name EXISTS and has status: $( echo ${output} | awk '{ print $7 }' ) ✅" | |
else | |
echo "=> Container with a name: testContainer does not exist" | |
exit 1 | |
fi | |
echo | |
echo "Pulling the magical docker image from rot13maxi (https://github.com/rot13maxi/key-convertr) ..." | |
docker pull ghcr.io/rot13maxi/key-convertr:main --quiet | |
echo "=> Pulling done ✅" | |
echo | |
echo "Grabbing all the feeds from $name..." | |
feeds=$(sqlite3 ./atomstr.db 'select * from feeds') | |
echo | |
k=1 | |
for feed in ${feeds//\\n/ | |
} | |
do | |
j=1 | |
echo "Feed [$k] is : $feed" | |
IFS='|' read -ra item <<< "$feed" | |
for i in "${item[@]}"; do | |
char_count=${#i} | |
if [[ $char_count -eq 64 ]] | |
then | |
if [[ $j -eq 1 ]] | |
then | |
echo "HEX PUB = $i" | |
npub=$(docker run --rm ghcr.io/rot13maxi/key-convertr:main --kind npub $i) | |
echo "=> NPUB KEY : $npub" | |
j=$((j + 1)) | |
else | |
echo "HEX NSEC = $i" | |
nsec=$(docker run --rm ghcr.io/rot13maxi/key-convertr:main --kind nsec $i) | |
echo "=> NSEC KEY : $nsec" | |
fi | |
fi | |
done | |
k=$((k + 1)) | |
echo | |
done | |
echo "Everything done! Have a good day!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment