-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwithdraw_BTC_to_address.sh
More file actions
executable file
·47 lines (35 loc) · 1.52 KB
/
withdraw_BTC_to_address.sh
File metadata and controls
executable file
·47 lines (35 loc) · 1.52 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
clear
# Prompt for API key information
echo -n "Enter your API key and press [ENTER]: "
read apikey
echo
echo -n "Enter your API secret and press [ENTER]: "
read apisecret
# Alternately, you can assign your keys to variables as below, or read in from a file, etc. Be mindful of security.
# apikey="yourkeyhere"
# apisecret="yoursecrethere"
# Construct URI and fetch current balance
nonce=$(date +%s)
uri="https://bittrex.com/api/v1.1/account/getbalance?apikey=$apikey&nonce=$nonce¤cy=BTC"
sign=$(echo -n "$uri" | openssl dgst -sha512 -hmac "$apisecret")
btcbalanceraw=$(curl -s -H "apisign: $sign" $uri)
btcbalance=$(echo $btcbalanceraw | jq -r .result.Balance)
# Fetch current network fee
feebtc=$(curl -s "https://bittrex.com/api/v1.1/public/getcurrencies" | jq '.result[] | select(.Currency == "BTC") | .TxFee')
echo
echo -e "Current Bitcoin Balance is:\t$btcbalance BTC"
echo -e "Current Bitcoin TxFee is:\t$feebtc BTC"
echo
echo
echo -n "Enter (or paste in) the destination BTC address and press [ENTER] (or press ctrl-c to cancel): "
read btcdestination
echo -n "Enter the amount of BTC to transfer and press [ENTER] (or press ctrl-c to cancel): "
read xferamount
echo
echo "Transferring $xferamount BTC to $btcdestination"
nonce=$(date +%s)
uri="https://bittrex.com/api/v1.1/account/withdraw?apikey=$apikey&nonce=$nonce¤cy=BTC&quantity=$xferamount&address=$btcdestination"
sign=$(echo -n "$uri" | openssl dgst -sha512 -hmac "$apisecret")
echo $uri
curl -X POST -H "apisign: $sign" $uri -d "Content-Length: 0"