[project] More leftover wallet support scripts, update README (#2687)
parent
64fd469741
commit
780ecf4034
@ -1,133 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
sudo yum install -q -y jq |
||||
|
||||
usage () { |
||||
cat << EOT |
||||
Usage: $0 [option] command |
||||
|
||||
Option: |
||||
-h print this help |
||||
|
||||
Actions: |
||||
1. health - Generates a status report of your node |
||||
2. address - Checks if your wallet is registered in the FN list |
||||
3. all - Does all above |
||||
EOT |
||||
} |
||||
|
||||
valid_ip () { |
||||
# https://www.linuxjournal.com/content/validating-ip-address-bash-script |
||||
local ip=$1 |
||||
local stat=1 |
||||
|
||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then |
||||
OIFS=$IFS |
||||
IFS='.' |
||||
ip=($ip) |
||||
IFS=$OIFS |
||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ |
||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]] |
||||
stat=$? |
||||
fi |
||||
return $stat |
||||
} |
||||
|
||||
health_report () { |
||||
# Block heights |
||||
lastSynchBlock=$(tac latest/validator*.log | grep -Eoim1 '"OtherHeight":[0-9]+' | cut -d: -f2) |
||||
[ -z "$lastSynchBlock" ] && lastSynchBlock=Unknown |
||||
|
||||
chainLength=$(jq -r 'select(.msg == "[TryCatchup] Adding block to chain") | .myBlock' ./latest/v*.log | tail -1 | cut -d: -f2) |
||||
[ -z "$chainLength" ] && chainLength=Unknown |
||||
|
||||
synchStatus=$(jq -r 'select(.msg == "Node is in sync" or .msg == "Node is out of sync") | .msg' ./latest/v*.log | tail -1 | cut -d: -f2) |
||||
[ -z "$synchStatus" ] && synchStatus=Unknown |
||||
|
||||
lengthOfChain=$(tac latest/validator*.log | grep -Eoim1 '"OtherHeight":[0-9]+' | cut -d: -f2) |
||||
[ -z "$lengthOfChain" ] && lengthOfChain=Unknown |
||||
|
||||
# Shard number |
||||
my_shard=$(grep -Eom1 "shardID\"\:[0-9]+" latest/validator*.log | cut -d: -f2) |
||||
[ -z "$my_shard" ] && lengthOfChain=Unknown |
||||
|
||||
# Public IP |
||||
ip=$(dig -4 @resolver1.opendns.com ANY myip.opendns.com +short) |
||||
|
||||
# Check validity of IP |
||||
if ! valid_ip $ip; then |
||||
echo "NO valid public IP found: $ip" |
||||
exit 2 |
||||
fi |
||||
|
||||
# Number of bingos |
||||
bingos=$(grep -c "BINGO" ./latest/validator*log) |
||||
[ -z bingos ] && bingos=0 |
||||
|
||||
#echo "Your Node Version : " |
||||
echo -e "\n====== HEALTH ======\n" |
||||
LD_LIBRARY_PATH=$(pwd) ./harmony -version |
||||
echo "Your IP:" $ip |
||||
echo "Your Shard:" $my_shard |
||||
echo "Your Sync Status:" $synchStatus |
||||
echo "Your Current Length of Chain:" $chainLength |
||||
echo "Your Latest Block Synchronized:" $lastSynchBlock |
||||
echo "Your Total Blocks Received After Syncing:" $bingos |
||||
./wallet.sh balances |
||||
} |
||||
|
||||
address_report () { |
||||
filename=$(find .hmy/keystore -maxdepth 1 -type f | head -n1) |
||||
address_field=$(grep -o '"address":"[a-z0-9]*' "${filename}") |
||||
base16=$(cut -d\" -f4 <<< "${address_field}") |
||||
bech32=$(./wallet.sh format --address 0x${base16} | head -n1 | awk -F: '{print $2}' | awk '{$1=$1}1') |
||||
curl -s https://raw.githubusercontent.com/harmony-one/harmony/master/internal/genesis/foundational.go | cat | cat | grep -qom1 "${bech32}" |
||||
echo -e "\n====== ADDRESS ======\n" |
||||
if [ $? -eq 0 ]; then |
||||
echo "SUCCESS: "${bech32}" FOUND in our foundational list!" |
||||
else |
||||
echo "FAILURE: "${bech32}" NOT FOUND in our foundational list, check if you have the right keyfile." |
||||
fi |
||||
} |
||||
|
||||
#####Main##### |
||||
|
||||
while getopts "h" opt; do |
||||
case $opt in |
||||
h|*) |
||||
echo "GETOPTS" |
||||
usage |
||||
exit 1 |
||||
;; |
||||
esac |
||||
done |
||||
shift $(($OPTIND - 1)) |
||||
|
||||
[ $# -eq 0 ] && address_report && health_report && exit 1 |
||||
|
||||
while :; do |
||||
case "$1" in |
||||
health) |
||||
health_report |
||||
shift |
||||
;; |
||||
address) |
||||
address_report |
||||
shift |
||||
;; |
||||
all) |
||||
address_report |
||||
health_report |
||||
shift |
||||
;; |
||||
'') |
||||
echo "EMPTY" |
||||
exit 0 |
||||
;; |
||||
*) |
||||
echo "**********" |
||||
usage |
||||
exit 1 |
||||
;; |
||||
esac |
||||
done |
@ -1,132 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
BUCKET=pub.harmony.one |
||||
OS=$(uname -s) |
||||
|
||||
# formatted with 4 spaces indentation for consistency with wallet binary |
||||
usage () { |
||||
cat << EOT |
||||
Usage: $0 [option] command |
||||
|
||||
Options: |
||||
-d download all the binaries/config files (must come after network flag) |
||||
-p profile use the profile for the given network (main, local, beta, pangaea; default: main) |
||||
-t equivalent to -p pangaea (deprecated) |
||||
-h print this help |
||||
|
||||
Commands: |
||||
1. new - Generates a new account and store the private key locally |
||||
2. list - Lists all accounts in local keystore |
||||
3. removeAll - Removes all accounts in local keystore |
||||
4. import - Imports a new account by private key |
||||
--privateKey - the private key to import |
||||
5. balances - Shows the balances of all addresses or specific address |
||||
--address - The address to check balance for |
||||
6. getFreeToken - Gets free token on each shard |
||||
--address - The free token receiver account's address |
||||
7. transfer - Transfer token from one account to another |
||||
--from - The sender account's address or index in the local keystore |
||||
--to - The receiver account's address |
||||
--amount - The amount of token to transfer |
||||
--shardID - The shard Id for the transfer |
||||
--toShardID - The destination shard Id for the transfer |
||||
--inputData - Base64-encoded input data to embed in the transaction |
||||
--pass - Passphrase of sender's private key |
||||
--waitThenBal - Wait after the transfer with colored balances output |
||||
8. export - Export account key to a new file |
||||
--account - Specify the account to export. Empty will export every key. |
||||
9. exportPriKey - Export account private key |
||||
--account - Specify the account to export private key. |
||||
10. blsgen - Generate a bls key and store private key locally. |
||||
--nopass - The private key has no passphrase (for test only) |
||||
11. format - Shows different encoding formats of specific address |
||||
--address - The address to display the different encoding formats for |
||||
12. blsRecovery - Recover non-human readable file. |
||||
--pass - The file containg the passphrase to decrypt the bls key. |
||||
--file - Non-human readable bls file. |
||||
13. importBLS - Convert raw private key into encrypted bls key. |
||||
--key - Raw private key. |
||||
14. getBLSPublic - Show BLS public key given raw private bls key. |
||||
--key - Raw private key. |
||||
--file - encrypted bls file. |
||||
EOT |
||||
} |
||||
|
||||
set_download () { |
||||
case "${network}" in |
||||
main) |
||||
REL=mainnet |
||||
;; |
||||
beta) |
||||
REL=testnet |
||||
;; |
||||
pangaea) |
||||
REL=pangaea |
||||
;; |
||||
*) |
||||
err 64 "${network}: invalid network" |
||||
;; |
||||
esac |
||||
|
||||
case "$OS" in |
||||
Darwin) |
||||
FOLDER=release/darwin-x86_64/${REL}/ |
||||
BIN=( wallet libbls384_256.dylib libcrypto.1.0.0.dylib libgmp.10.dylib libgmpxx.4.dylib libmcl.dylib ) |
||||
;; |
||||
Linux) |
||||
FOLDER=release/linux-x86_64/${REL}/ |
||||
BIN=( wallet libbls384_256.so libcrypto.so.10 libgmp.so.10 libgmpxx.so.4 libmcl.so ) |
||||
;; |
||||
*) |
||||
echo "${OS} not supported." |
||||
exit 2 |
||||
;; |
||||
esac |
||||
} |
||||
|
||||
do_download () { |
||||
# clean up old files |
||||
for bin in "${BIN[@]}"; do |
||||
rm -f ${bin} |
||||
done |
||||
|
||||
# download all the binaries |
||||
for bin in "${BIN[@]}"; do |
||||
curl http://${BUCKET}.s3.amazonaws.com/${FOLDER}${bin} -o ${bin} |
||||
done |
||||
|
||||
mkdir -p .hmy/keystore |
||||
chmod +x wallet |
||||
} |
||||
|
||||
unset network |
||||
network=main |
||||
|
||||
while getopts "dp:th" opt; do |
||||
case ${opt} in |
||||
d) |
||||
set_download |
||||
do_download |
||||
exit 0 |
||||
;; |
||||
p) |
||||
network="${OPTARG}" |
||||
;; |
||||
t) |
||||
network=pangaea |
||||
;; |
||||
h|*) |
||||
usage |
||||
exit 1 |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
shift $((OPTIND-1)) |
||||
|
||||
# Run Harmony Wallet |
||||
if [ "$OS" = "Linux" ]; then |
||||
LD_LIBRARY_PATH=$(pwd) ./wallet -p "$network" "$@" |
||||
else |
||||
DYLD_FALLBACK_LIBRARY_PATH=$(pwd) ./wallet -p "$network" "$@" |
||||
fi |
@ -1,8 +0,0 @@ |
||||
package main |
||||
|
||||
import "github.com/harmony-one/harmony/internal/utils" |
||||
|
||||
// Embed the default wallet.ini file into defaultWalletIni string literal constant
|
||||
func main() { |
||||
utils.EmbedFile("../../../.hmy/wallet.ini", "defaultWalletIni") |
||||
} |
Loading…
Reference in new issue