-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwithdraw
executable file
·31 lines (27 loc) · 1.07 KB
/
withdraw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#
# Create a signed raw tx to send funds away.
# With automation=1 it will attempt to automatically send the tx as well
#
# @todo add error checking for addresses and amounts
#
# @author webworker01
# @link https://developers.atomicdex.io/basic-docs/atomicdex-api-legacy/withdraw.html
#
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $scriptpath/main
if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]]; then
echo "Usage: ./withdraw <coin> <address> <amount or max>"
exit 0
fi
coin=${1^^}
if [[ "$3" == "max" ]]; then
sendtx=$(jq . <<< $(curl -s --url "http://127.0.0.1:7783" --data '{"method":"withdraw","coin":"'${coin}'","to":"'${2}'","max":true,"userpass":"'${userpass}'"}'))
else
sendtx=$(jq . <<< $(curl -s --url "http://127.0.0.1:7783" --data '{"method":"withdraw","coin":"'${coin}'","to":"'${2}'","amount":"'${3}'","userpass":"'${userpass}'"}'))
fi
if (( $automation > 0 )); then
txid=$(echo $sendtx | jq -r .tx_hex)
log "withdraw" "Attempting to send ${txid}"
${scriptpath}/sendrawtransaction ${coin} ${txid}
fi