joininbox/scripts/menu.send.sh

213 lines
5.3 KiB
Bash
Raw Permalink Normal View History

2020-06-15 15:33:41 +01:00
#!/bin/bash
2020-07-01 15:10:50 +01:00
source /home/joinmarket/joinin.conf
source /home/joinmarket/_functions.sh
2020-06-17 11:05:46 +01:00
checkRPCwallet
2020-06-15 15:33:41 +01:00
# wallet
2020-06-22 15:15:43 +01:00
chooseWallet
2020-06-15 15:33:41 +01:00
# mixdepth
trap 'rm -f "$mixdepth"' EXIT
mixdepth=$(mktemp -p /dev/shm/)
2020-06-22 14:37:32 +01:00
dialog --backtitle "Choose a mixdepth to send from" \
--title "Choose a mixdepth to send from" \
--inputbox "
From the wallet: $walletFileName
mixdepth: $(cat "$mixdepth")
send: $amountsats
coinjoin: $makercountMessage
miner fee: $txfeeMessage
destination address:
$(cat "$address")
2023-04-16 08:21:33 +01:00
change address (optional):
$changeAddressMessage
2023-04-16 08:21:33 +01:00
Enter a number between 0 to 4 to choose the mixdepth" 19 69 2> "$mixdepth"
openMenuIfCancelled $?
# amount
trap 'rm -f "$amount"' EXIT
amount=$(mktemp -p /dev/shm/)
dialog --backtitle "Choose the amount" \
--title "Choose the amount" \
--inputbox "
From the wallet: $walletFileName
mixdepth: $(cat "$mixdepth")
send: $amountsats
coinjoin: $makercountMessage
miner fee: $txfeeMessage
destination address:
$(cat "$address")
2023-04-16 08:21:33 +01:00
change address (optional):
$changeAddressMessage
Enter the amount to send in satoshis
2023-04-16 08:21:33 +01:00
Use 0 to sweep the mixdepth without a change output" 20 69 2> "$amount"
2020-06-17 11:05:46 +01:00
openMenuIfCancelled $?
amountsats="$(cat "$amount") sats"
2020-06-15 15:33:41 +01:00
# makercount
trap 'rm -f "$makercount"' EXIT
makercount=$(mktemp -p /dev/shm/)
2020-06-15 15:33:41 +01:00
dialog --backtitle "Choose the makercount" \
--title "Choose the makercount" \
--inputbox "
From the wallet: $walletFileName
mixdepth: $(cat "$mixdepth")
send: $amountsats
coinjoin: $makercountMessage
miner fee: $txfeeMessage
destination address:
$(cat "$address")
2023-04-16 08:21:33 +01:00
change address (optional):
$changeAddressMessage
Enter the number of makers to coinjoin with (min 4)
Leave empty for the default 5-9 (randomized)
2023-04-16 08:21:33 +01:00
Enter 0 to send without a coinjoin." 21 69 2> "$makercount"
openMenuIfCancelled $?
varMakercount=$(cat "$makercount")
if [ ${#varMakercount} -eq 0 ]; then
makercountMessage="with 5-9 (randomized) makers"
makercountOption=""
elif [ "$varMakercount" = "0" ]; then
makercountMessage="none"
makercountOption="-N 0"
else
makercountMessage="with $varMakercount makers"
makercountOption="-N $varMakercount"
fi
2020-06-15 15:33:41 +01:00
# txfee
trap 'rm -f "$txfee"' EXIT
txfee=$(mktemp -p /dev/shm/)
dialog --backtitle "Choose the miner fee" \
--title "Choose the miner fee" \
--inputbox "
From the wallet: $walletFileName
mixdepth: $(cat "$mixdepth")
send: $amountsats
coinjoin: $makercountMessage
miner fee: $txfeeMessage
destination address:
$(cat "$address")
2023-04-16 08:21:33 +01:00
change address (optional):
$changeAddressMessage
Enter the miner fee to be used for the transaction in sat/byte
2023-04-16 08:21:33 +01:00
Leave empty to use the default fee (set in the joinmarket.cfg)" 20 69 2> "$txfee"
openMenuIfCancelled $?
varTxfee=$(cat "$txfee")
if [ ${#varTxfee} -eq 0 ]; then
txfeeMessage="default (set in the joinmarket.cfg)"
txfeeOption=""
else
txfeeMessage="$varTxfee sat/byte"
if [ ${varTxfee} -eq 1 ]; then
# https://github.com/openoms/joininbox/issues/64
txfeeOption="--txfee=1001"
else
txfeeOption="--txfee=$((varTxfee * 1000))"
fi
fi
2020-06-15 15:33:41 +01:00
# address
trap 'rm -f "$address"' EXIT
address=$(mktemp -p /dev/shm/)
2020-06-15 15:33:41 +01:00
dialog --backtitle "Choose the address" \
--title "Choose the address" \
--inputbox "
From the wallet: $walletFileName
mixdepth: $(cat "$mixdepth")
send: $amountsats
coinjoin: $makercountMessage
miner fee: $txfeeMessage
destination address:
$(cat "$address")
2023-04-16 08:21:33 +01:00
change address (optional):
$changeAddressMessage
2023-04-16 08:21:33 +01:00
Paste the destination address" 19 69 2> "$address"
2020-06-17 11:05:46 +01:00
openMenuIfCancelled $?
2020-06-15 15:33:41 +01:00
2023-04-16 08:21:33 +01:00
# changeAddress
trap 'rm -f "$changeAddress"' EXIT
2023-04-16 08:21:33 +01:00
changeAddress=$(mktemp -p /dev/shm/)
if [ "$amountsats" != "0 sats" ]; then
dialog --backtitle "Custom change address" \
--title "Custom change address" \
--inputbox "
From the wallet: $walletFileName
mixdepth: $(cat "$mixdepth")
send: $amountsats
coinjoin: $makercountMessage
miner fee: $txfeeMessage
destination address:
$(cat "$address")
change address (optional):
$changeAddressMessage
Paste the address to receive the change to
or leave empty to use an internal address in the mixdepth$(cat $mixdepth)" 20 69 2> "$changeAddress"
openMenuIfCancelled $?
fi
varChangeAddress=$(cat "$changeAddress")
if [ "$amountsats" = "0 sats" ]; then
changeAddressMessage="none"
changeAddressOption=""
elif [ ${#varChangeAddress} -eq 0 ]; then
changeAddressMessage="internal address in m$(cat $mixdepth)"
changeAddressOption=""
else
changeAddressMessage="$varChangeAddress"
changeAddressOption="--custom-change $varChangeAddress"
fi
if [ "${RPCoverTor}" = "on" ]; then
2021-10-03 00:37:34 +01:00
tor="torsocks"
else
tor=""
fi
2020-06-15 15:33:41 +01:00
# check command
dialog --backtitle "Confirm the details" \
--title "Confirm the details" \
--yesno "
From the wallet: $walletFileName
mixdepth: $(cat "$mixdepth")
send: $amountsats
coinjoin: $makercountMessage
miner fee: $txfeeMessage
destination address:
2023-04-16 08:21:33 +01:00
$(cat "$address")
change address (optional):
$changeAddressMessage" 17 69
2020-06-15 15:33:41 +01:00
# make decision
2020-06-15 15:33:41 +01:00
pressed=$?
case $pressed in
0)
clear
# display
echo "Running the command:
2020-06-22 14:37:32 +01:00
$tor python sendpayment.py \
-m $(cat "$mixdepth") $makercountOption $(sed "s#$walletPath##g" < "$wallet" ) \
2023-04-16 08:21:33 +01:00
$(cat "$amount") $(cat "$address") $txfeeOption $changeAddressOption
"
# run
$tor python ~/joinmarket-clientserver/scripts/sendpayment.py \
-m "$(cat "$mixdepth")" $makercountOption "$(cat "$wallet")" \
2023-04-16 08:21:33 +01:00
"$(cat "$amount")" "$(cat "$address")" $txfeeOption $changeAddressOption
2020-06-15 15:33:41 +01:00
;;
1)
echo "Cancelled"
exit 1
;;
255)
echo "ESC pressed."
exit 1
;;
2023-04-16 08:21:33 +01:00
esac