#!/bin/bash

# Script to parse clear text password to command line without appearing in bash history
# Password may appear transitently in process logs

# This was written to be automated and easy to use rather than to be highly secure

# Please use this script at your own risk
# Provided as a community service for research use only

# The password is in this file in clear text but protected by permissions
# chmod 400  $HOME/.secret/.pass
x=`cat $HOME/.secret/.pass`

# Change this to where biblepay-cli is located
cli=$HOME"/biblepay-evolution/src/biblepay-cli"

# Unlock wallet for x seconds
time=87000

	echo "waiting for Blockchain and Masternodes to sync..."
	until $cli mnsync status | grep AssetID | awk -F" " '{print $2}' | awk -F, '{print $1}' 2>&1 | grep "999" -C 4; do echo -n .; sleep 5; done

	echo "Unlocking wallet with passphrase..."
        $cli walletpassphrase "$x" $time

echo "Wallet unlocked for "$time" seconds."

