Last active
September 26, 2024 09:06
-
-
Save cardano-apexpool/99784308812bdf7aa01446fa95f47fd2 to your computer and use it in GitHub Desktop.
Extract the keys from the mnemonic for a Cardano wallet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# For mainnet | |
NET="mainnet" | |
NET_WITH_PREFIX="--mainnet" | |
# For preprod | |
#NET="testnet" | |
#NET_WITH_PREFIX="--testnet-magic 1" | |
# For preview | |
#NET="testnet" | |
#NET_WITH_PREFIX="--testnet-magic 2" | |
ADDR_COUNT=1 | |
umask 277 | |
# Recover existing wallet | |
#echo "your wallet 24 words" > phrase.prv | |
# or create a new wallet | |
cardano-address recovery-phrase generate > phrase.prv | |
umask 077 | |
cat phrase.prv | cardano-address key from-recovery-phrase Shelley > rootkey.prv | |
# cat rootkey.prv | cardano-address key public --with-chain-code > rootkey.pub | |
cat rootkey.prv | cardano-address key child 1852H/1815H/0H/2/0 > stake.prv | |
cat stake.prv | cardano-address key public --with-chain-code | cardano-address address stake --network-tag ${NET} > stake.addr | |
cardano-cli key convert-cardano-address-key --signing-key-file stake.prv --shelley-stake-key --out-file stake.skey | |
cardano-cli key verification-key --signing-key-file stake.skey --verification-key-file Ext_ShelleyStake.vkey | |
cardano-cli key non-extended-key --extended-verification-key-file Ext_ShelleyStake.vkey --verification-key-file stake.vkey | |
cardano-cli stake-address build --stake-verification-key-file stake.vkey --out-file stake.addr ${NET_WITH_PREFIX} | |
rm Ext_ShelleyStake.vkey stake.prv | |
for NR in $(seq 0 $(expr $ADDR_COUNT - 1)) | |
do | |
cat rootkey.prv | cardano-address key child 1852H/1815H/0H/0/${NR} > addr-${NR}.prv | |
cat addr-${NR}.prv | cardano-address key public --with-chain-code | cardano-address address payment --network-tag ${NET} > payment-short-${NR}.addr | |
cardano-cli key convert-cardano-address-key --signing-key-file addr-${NR}.prv --shelley-payment-key --out-file payment-${NR}.skey | |
cardano-cli key verification-key --signing-key-file payment-${NR}.skey --verification-key-file Ext_ShelleyPayment-${NR}.vkey | |
cardano-cli key non-extended-key --extended-verification-key-file Ext_ShelleyPayment-${NR}.vkey --verification-key-file payment-${NR}.vkey | |
cardano-cli address build --payment-verification-key-file payment-${NR}.vkey --stake-verification-key-file stake.vkey --out-file payment-${NR}.addr ${NET_WITH_PREFIX} | |
rm Ext_ShelleyPayment-${NR}.vkey addr-${NR}.prv | |
done | |
rm rootkey.prv |
The .vkey is not needed anymore, and the .prv file is deleted for security reasons.
Awesome thank you! 🙏🏽
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beautiful! I do have a question about the last line where the script deletes the
Ext_ShelleyStake.vkey
andstake.prv
. Why are we doing this? I'm sure there's a security reason for this last step.