Accept user provided ethereum private key to save it locally

This commit is contained in:
Slava 2024-10-09 08:28:38 +03:00
parent 76d56a9548
commit 34c5c8fd2f
No known key found for this signature in database
GPG Key ID: 351E7AA9BD0DFEB8

View File

@ -6,7 +6,8 @@ key_file="eth.key"
address_file="eth.address"
url=https://key.codex.storage
# Generate
# Generate remote
generate_remote() {
echo "Generating private key from remote <${url}>..."
response=$(curl -s ${url})
@ -21,3 +22,22 @@ address=$(cat ${address_file})
echo " * your private key has been saved to ${PWD}/${key_file}"
echo " * your ethereum address has been saved to ${PWD}/${address_file}"
echo " * your ethereum address is ${address}"
}
# Use user provided private key
user_private_key() {
# Create file with required permissions
echo "${ETH_PRIVATE_KEY}" >"${key_file}"
chmod 600 "${key_file}"
echo "Using provided private key..."
echo " * your private key has been saved to ${PWD}/${key_file}"
echo " * please use your key address to get the tokens"
}
# Save keyrair
if [[ -z "${ETH_PRIVATE_KEY}" ]]; then
generate_remote
else
user_private_key
fi