joininbox/scripts/menu.tools.sh

257 lines
7.2 KiB
Bash
Raw Permalink Normal View History

2020-12-14 20:04:37 +00:00
#!/bin/bash
source /home/joinmarket/joinin.conf
source /home/joinmarket/_functions.sh
function installBitcoinScripts {
if [ ! -d "/home/bitcoin/bitcoin-scripts" ]; then
cd /home/bitcoin/ || exit 1
sudo -u bitcoin git clone https://github.com/kristapsk/bitcoin-scripts.git
cd bitcoin-scripts || exit 1
# from https://github.com/kristapsk/bitcoin-scripts/commits/master
sudo -u bitcoin git checkout 435dc29f377f0563c3b94390fcfe3ba5df3b6f11
sudo -u bitcoin chmod +x ./*.sh
fi
}
2021-05-09 20:43:50 +01:00
function listCJcandidateTXNs {
clear
cjTXNs=$(grep "Found Joinmarket coinjoin transaction" < \
/home/joinmarket/.joinmarket/candidates.txt | awk '{print $5}')
installBitcoinScripts
getRPC
for i in $cjTXNs; do
sudo -u bitcoin /home/bitcoin/bitcoin-scripts/checktransaction.sh \
-rpcwallet=$rpc_wallet $i
done
2021-05-09 20:43:50 +01:00
}
2020-12-14 20:04:37 +00:00
function installBoltzmann {
if [ ! -f "/home/joinmarket/boltzmann/bvenv/bin/activate" ]; then
2021-04-06 20:35:11 +01:00
cd /home/joinmarket/ || exit 1
2020-12-14 20:04:37 +00:00
git clone https://code.samourai.io/oxt/boltzmann.git
2021-04-06 20:35:11 +01:00
cd boltzmann || exit 1
2020-12-14 20:04:37 +00:00
python3 -m venv bvenv
source bvenv/bin/activate || exit 1
python setup.py install
fi
}
function dialog_inputbox {
local title=$1
local text=$2
local height=$3
local width=$4
trap 'rm -f "$inputdata"' EXIT
inputdata=$(mktemp -p /dev/shm/)
dialog --backtitle "$title" \
--title "$title" \
--inputbox "
$text" $height $width 2>"$inputdata"
2020-12-14 20:04:37 +00:00
openMenuIfCancelled $?
dialog_output=$(cat $inputdata)
2020-12-14 20:04:37 +00:00
}
function getQRstring {
trap 'rm -f "$QRstring"' EXIT
QRstring=$(mktemp -p /dev/shm/)
dialog --backtitle "Display a QR code from any text" \
--title "Enter any text" \
--inputbox "
Enter the text to be shown as a QR code" 9 71 2>"$QRstring"
openMenuIfCancelled $?
}
isLocalBitcoinCLI=$(sudo -u bitcoin bitcoin-cli -version | grep -c "Bitcoin Core RPC client")
2021-12-06 13:34:35 +00:00
isTxindex=$(sudo -u bitcoin cat /home/bitcoin/.bitcoin/bitcoin.conf | grep -c "txindex=1")
2021-05-09 00:15:05 +01:00
2020-12-14 20:04:37 +00:00
# BASIC MENU INFO
HEIGHT=13
WIDTH=61
2022-08-14 11:33:46 +01:00
CHOICE_HEIGHT=7
2020-12-14 20:04:37 +00:00
TITLE="Tools"
MENU=""
OPTIONS=()
BACKTITLE="JoininBox GUI"
# Basic Options
2021-03-02 10:30:40 +00:00
if [ "${runningEnv}" = standalone ]; then
OPTIONS+=(
SPECTER "Specter Desktop options")
HEIGHT=$((HEIGHT + 1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT + 1))
2021-03-02 10:30:40 +00:00
fi
OPTIONS+=(
QR "Display a QR code from any text"
CUSTOMRPC "Run a custom bitcoin RPC with curl"
CJFINDER "Scan blocks for JoinMarket coinjoins")
if [ "$isLocalBitcoinCLI" -gt 0 ] && [ "$isTxindex" -gt 0 ]; then
2021-05-09 00:15:05 +01:00
OPTIONS+=(
CHECKTXN "CLI transaction explorer")
HEIGHT=$((HEIGHT + 1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT + 1))
if [ -f /home/joinmarket/.joinmarket/candidates.txt ]; then
OPTIONS+=(
LISTCJS "List filtered coinjoin transactions")
HEIGHT=$((HEIGHT + 1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT + 1))
2021-12-06 13:34:35 +00:00
fi
fi
OPTIONS+=(
BOLTZMANN "Analyze the entropy of a transaction")
if [ "${runningEnv}" != mynode ]; then
OPTIONS+=(
PASSWORD "Change the ssh password")
HEIGHT=$((HEIGHT + 1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT + 1))
fi
if [ "${runningEnv}" != standalone ]; then
if grep -Eq "^joinmarketSSH=off" /home/joinmarket/joinin.conf; then
sshAction="Enable"
else
sshAction="Disable"
fi
OPTIONS+=(
SSH "$sshAction ssh access with the joinmarket user")
HEIGHT=$((HEIGHT + 1))
CHOICE_HEIGHT=$((CHOICE_HEIGHT + 1))
fi
OPTIONS+=(
LOGS "Show the bitcoind logs on $network"
API "Start the jmwalletd.py as a systemd service"
FULLYNODED "Connect Fully Noded with a QRcode")
2020-12-14 20:04:37 +00:00
CHOICE=$(dialog \
--clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--ok-label "Select" \
--cancel-label "Back" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
2020-12-14 20:04:37 +00:00
case $CHOICE in
QR)
getQRstring
datastring=$(cat $QRstring)
clear
echo
echo "Displaying the text:"
echo "$datastring"
echo
if [ ${#datastring} -eq 0 ]; then
echo "# Error='missing string'"
fi
qrencode -t ANSIUTF8 "${datastring}"
echo "(To shrink QR code: MacOS press CMD- / Linux press CTRL-)"
echo
echo "Press ENTER to return to the menu..."
read key
;;
CUSTOMRPC)
echo "***DANGER ZONE***"
echo "# See the options at https://developer.bitcoin.org/reference/rpc/"
echo
echo "# Input which method (command) to use"
read method
echo "# Input the parameter(s) (optional)"
read params
customRPC "# custom RPC" "$method" "$params"
echo
echo "Press ENTER to return to the menu..."
read key
;;
SPECTER)
/home/joinmarket/standalone/menu.specter.sh
;;
PASSWORD)
sudo /home/joinmarket/set.password.sh
;;
LOGS)
showBitcoinLogs
;;
CHECKTXN)
dialog_inputbox "CLI transaction explorer" "\nUsing: https://github.com/kristapsk/bitcoin-scripts\n\nPaste a TXID to check" 11 71
clear
installBitcoinScripts
getRPC
echo
echo "# Running the command:"
echo "sudo -u bitcoin /home/bitcoin/bitcoin-scripts/checktransaction.sh -rpcwallet=$rpc_wallet $dialog_output"
echo
sudo -u bitcoin /home/bitcoin/bitcoin-scripts/checktransaction.sh -rpcwallet=$rpc_wallet $dialog_output
echo
echo "Press ENTER to return to the menu..."
read key
;;
BOLTZMANN)
dialog_inputbox "Boltzmann transaction entropy analysis" "\nUsing: https://code.samourai.io/oxt/boltzmann\n\nPaste a TXID to analyze" 11 71
clear
installBoltzmann
python /home/joinmarket/start.boltzmann.py --txid=$dialog_output
echo
echo "Press ENTER to return to the menu..."
read key
;;
CJFINDER)
BLOCKHEIGHT=$(customRPC "" "getblockchaininfo" "" |
grep blocks | awk '{print $2}' | cut -d, -f1)
dialog_inputbox "snicker-finder.py" \
"\nUsing: https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/\
master/scripts/snicker/snicker-finder.py\n\n\
Note that scanning the blocks is slow.\n\
Current blockheight is: $BLOCKHEIGHT\n\
Input how many previous blocks from the tip you want to scan" 14 108
clear
echo
echo "Running the command:"
echo "python snicker/snicker-finder.py -j $((BLOCKHEIGHT - dialog_output)) \
-f /home/joinmarket/.joinmarket/candidates.txt"
echo
python /home/joinmarket/joinmarket-clientserver/scripts/snicker/snicker-finder.py -j $((BLOCKHEIGHT - dialog_output)) -f /home/joinmarket/.joinmarket/candidates.txt
echo
echo "The transaction details are saved in /home/joinmarket/.joinmarket/candidates.txt"
echo "To display the file in the terminal use:"
echo "'cat /home/joinmarket/.joinmarket/candidates.txt'"
if [ $isLocalBitcoinCLI -gt 0 ]; then
echo "or menu -> TOOLS -> CHECKTXN for a CLI transaction explorer"
echo
echo "Press ENTER for an overview of the JoinMarket coinjoins found with CHECKTXN"
read key
2021-12-06 13:34:35 +00:00
listCJcandidateTXNs
fi
echo "Press ENTER to return to the menu..."
read key
;;
LISTCJS)
listCJcandidateTXNs
echo "Press ENTER to return to the menu..."
read key
;;
SSH)
if [ $sshAction = "Disable" ]; then
sudo /home/joinmarket/set.ssh.sh off
elif [ $sshAction = "Enable" ]; then
sudo /home/joinmarket/set.ssh.sh on
fi
echo
echo "Press ENTER to return to the menu..."
read key
;;
API)
clear
echo
/home/joinmarket/install.joinmarket-api.sh on
echo "Press ENTER to return to the menu..."
read key
;;
FULLYNODED)
clear
/home/joinmarket/install.joinmarket-api.sh connect
echo "Press ENTER to return to the menu..."
read key
;;
2021-05-09 20:43:50 +01:00
esac