joininbox/scripts/start.script.sh

119 lines
2.4 KiB
Bash
Raw Normal View History

2020-06-13 19:25:26 +01:00
#!/bin/bash
script="$1"
if [ ${#script} -eq 0 ]; then
2020-06-15 15:34:43 +01:00
echo "must specify a script to run"
2020-06-16 13:12:56 +01:00
exit 1
elif [ ${script} == "receive-payjoin" ]; then
specialMessage="
Communicate the sender the:
- receiving address (3....)
- ephemeral nickname (J5...)
- amount in satoshis
"
else
specialMessage=""
2020-06-13 19:25:26 +01:00
fi
2020-06-16 14:29:39 +01:00
wallet="$2"
2020-06-16 13:12:56 +01:00
if [ ${#wallet} -eq 0 ] || [ ${wallet} == "" ]; then
# wallet
2020-06-17 11:05:46 +01:00
source menu.functions.sh
2020-06-16 13:12:56 +01:00
tempwallet=$(tempfile 2>/dev/null)
dialog --backtitle "Choose a wallet" \
--title "Choose a wallet by typing the full name of the file" \
--fselect "/home/joinmarket/.joinmarket/wallets/" 10 60 2> $tempwallet
2020-06-17 11:05:46 +01:00
openMenuIfCancelled $?
2020-06-16 13:12:56 +01:00
wallet=$(cat $tempwallet)
2020-06-15 15:34:43 +01:00
fi
option="$3"
2020-06-21 11:33:57 +01:00
if [ ${#option} -eq 0 ] || [ ${option} = "nooption" ]; then
2020-06-13 19:25:26 +01:00
option=""
fi
2020-06-15 15:34:43 +01:00
mixdepth="$4"
if [ ${#mixdepth} -eq 0 ]; then
mixdepth=""
else
mixdepth="-m$4"
fi
2020-06-13 19:25:26 +01:00
2020-06-15 15:34:43 +01:00
makercount="$5"
2020-06-21 11:33:57 +01:00
if [ ${#makercount} -eq 0 ] || [ ${makercount} = "nomakercount" ]; then
2020-06-15 15:34:43 +01:00
makercount=""
else
makercount="-N$5"
fi
2020-06-13 19:25:26 +01:00
2020-06-15 15:34:43 +01:00
amount="$6"
if [ ${#amount} -eq 0 ]; then
amount=""
fi
address="$7"
if [ ${#address} -eq 0 ]; then
address=""
fi
nickname="$8"
if [ ${#nickname} -eq 0 ]; then
nickname=""
else
nickname="-T $8"
fi
2020-06-17 14:52:34 +01:00
source /home/joinmarket/joinin.conf
2020-06-21 00:42:29 +01:00
if [ ${RPCoverTor} = "on" ]; then
2020-06-15 15:34:43 +01:00
tor="torify"
else
tor=""
fi
2020-06-13 19:25:26 +01:00
# get password
data=$(tempfile 2>/dev/null)
# trap it
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Decrypting Wallet" \
--insecure \
2020-06-21 01:03:29 +01:00
--passwordbox "Type or paste the wallet decryption password" \
8 52 2> $data
2020-06-13 19:25:26 +01:00
# make decison
pressed=$?
case $pressed in
0)
2020-06-21 00:42:29 +01:00
clear
if [ ${RPCoverTor} = "on" ];then
2020-06-21 01:03:29 +01:00
echo "Running the command:
2020-06-15 15:34:43 +01:00
$tor python ~/joinmarket-clientserver/scripts/$script.py \
$makercount $mixdepth $wallet $option $amount $address $nickname"
2020-06-17 14:52:34 +01:00
else
2020-06-21 01:03:29 +01:00
echo "Running the command:
2020-06-17 14:52:34 +01:00
python ~/joinmarket-clientserver/scripts/$script.py \
$makercount $mixdepth $wallet $option $amount $address $nickname"
2020-06-17 14:52:34 +01:00
fi
echo "$specialMessage"
2020-06-17 14:52:34 +01:00
. /home/joinmarket/joinmarket-clientserver/jmvenv/bin/activate
2020-06-15 15:34:43 +01:00
cat $data | $tor \
python ~/joinmarket-clientserver/scripts/$script.py \
2020-06-21 01:03:29 +01:00
$makercount $mixdepth $wallet $option $amount $address $nickname \
--wallet-password-stdin
2020-06-15 15:34:43 +01:00
shred $data
;;
2020-06-13 19:25:26 +01:00
1)
shred $data
rm -f .pw
echo "Cancelled"
2020-06-15 15:34:43 +01:00
exit 1
;;
2020-06-13 19:25:26 +01:00
255)
shred $data
rm -f .pw
[ -s $data ] && cat $data || echo "ESC pressed."
2020-06-15 15:34:43 +01:00
exit 1
;;
2020-06-13 19:25:26 +01:00
esac