joininbox/scripts/menu.payjoin.sh

174 lines
3.4 KiB
Bash
Raw Normal View History

#!/bin/bash
2020-06-22 15:25:23 +01:00
source /home/joinmarket/joinin.conf
source /home/joinmarket/_functions.sh
function receivePayJoin() {
# wallet
2020-06-22 15:15:43 +01:00
chooseWallet
# mixdepth
mixdepth=$(mktemp 2>/dev/null)
dialog --backtitle "Choose a mixdepth to receive to" \
--title "Choose a mixdepth to receive to" \
--inputbox "
Enter a number between 0 to 4 to choose the mixdepth
(make sure there is at least one UTXO there already)" 10 60 2> $mixdepth
openMenuIfCancelled $?
# amount
amount=$(mktemp 2>/dev/null)
dialog --backtitle "Choose the amount" \
--title "Choose the amount" \
--inputbox "
Enter the amount to receive in satoshis" 9 60 2> $amount
openMenuIfCancelled $?
if [ ${RPCoverTor} = "on" ];then
tor="torify"
else
tor=""
fi
# check command
dialog --backtitle "Confirm the details" \
--title "Confirm the details" \
--yesno "
Receive: $(cat $amount) sats
To the wallet:
$(echo $(cat $wallet) | sed "s#$walletPath##g")
2020-07-16 13:31:25 +01:00
mixdepth: $(cat $mixdepth)
2020-07-16 13:31:25 +01:00
" 12 55
# make decison
pressed=$?
case $pressed in
0)
clear
2020-06-22 14:11:58 +01:00
# display
echo "Running the command:
$tor python receive-payjoin.py -m$(cat $mixdepth) \
$(echo $(cat $wallet) | sed "s#$walletPath##g") $(cat $amount)
"
2020-10-14 09:10:12 +01:00
echo "Will wait for the ephemeral Tor Hidden Service to be created.
Can cancel the process by pressing CTRL+C .
"
2020-06-22 14:11:58 +01:00
# run
$tor python ~/joinmarket-clientserver/scripts/receive-payjoin.py \
-m$(cat $mixdepth) $(cat $wallet) $(cat $amount)
;;
1)
echo "Cancelled"
exit 1
;;
255)
echo "ESC pressed."
exit 1
;;
esac
}
function sendPayJoin() {
# wallet
2020-06-22 15:15:43 +01:00
chooseWallet
# mixdepth
mixdepth=$(mktemp 2>/dev/null)
dialog --backtitle "Choose a mixdepth to send from" \
--title "Choose a mixdepth to send from" \
--inputbox "
2020-06-22 15:15:43 +01:00
Enter a number between 0 to 4 to choose the mixdepth" 9 60 2> $mixdepth
openMenuIfCancelled $?
2020-07-16 13:31:25 +01:00
# receiveURI
receiveURI=$(mktemp 2>/dev/null)
2020-07-16 13:31:25 +01:00
dialog --backtitle "Receive URI" \
--title "Receive URI" \
--inputbox "
2020-07-16 13:31:25 +01:00
Paste the Receive URI to send to" 9 60 2> $receiveURI
openMenuIfCancelled $?
2020-06-22 14:37:10 +01:00
if [ ${RPCoverTor} = "on" ]; then
tor="torify"
else
tor=""
fi
# check command
dialog --backtitle "Confirm the selections" \
--title "Confirm the details" \
--yesno "
2020-07-16 13:31:25 +01:00
Send to:
$(cat $receiveURI)
from the wallet:
$(sed "s#$walletPath##g" < "$wallet")
mixdepth: $(cat "$mixdepth")
2020-07-16 13:31:25 +01:00
" 13 55
# make decison
pressed=$?
case $pressed in
0)
2020-06-22 14:37:10 +01:00
# display
echo "Running the command:
$tor python sendpayment.py -m$(cat "$mixdepth") \
$(sed "s#$walletPath##g" < "$wallet") \
$(cat "$receiveURI")
2020-06-22 14:37:10 +01:00
"
# run
$tor python ~/joinmarket-clientserver/scripts/sendpayment.py \
-m"$(cat "$mixdepth")" "$(cat "$wallet")" "$(cat "$receiveURI")"
;;
1)
echo "Cancelled"
exit 1
;;
255)
echo "ESC pressed."
exit 1
;;
esac
}
# BASIC MENU INFO
2020-10-14 09:10:12 +01:00
HEIGHT=8
WIDTH=48
CHOICE_HEIGHT=20
2020-10-14 09:10:12 +01:00
TITLE="PayJoin options"
2020-10-14 09:39:28 +01:00
MENU=""
OPTIONS=()
BACKTITLE="JoininBox GUI"
# Basic Options
OPTIONS+=(\
SEND "Send a payment with PayJoin" \
RECEIVE "Receive a payment with PayJoin" \
)
CHOICE=$(dialog --clear \
--backtitle "$BACKTITLE" \
--title "$TITLE" \
--menu "$MENU" \
$HEIGHT $WIDTH $CHOICE_HEIGHT \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
case $CHOICE in
2020-06-21 01:03:29 +01:00
RECEIVE)
receivePayJoin
2020-10-14 01:18:11 +01:00
echo ""
echo "Press ENTER to return to the menu..."
read key
2020-06-21 01:03:29 +01:00
;;
SEND)
sendPayJoin
2020-10-14 01:18:11 +01:00
echo ""
echo "Press ENTER to return to the menu..."
read key
2020-06-21 01:03:29 +01:00
;;
esac