Forked from cardano-apexpool/wallet_from_mnemonic.sh
Created
November 8, 2022 16:31
-
-
Save Wolfy18/c789b3d9d892f5c1fe8cdf081c752067 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 testnet | |
NET="testnet" | |
NET_WITH_PREFIX="--testnet-magic 1097911063" | |
ADDR_COUNT=1 | |
### Extract root keys and create Payment and Stake Addresses using "cardano-address" or "cardano-wallet" tool ### | |
touch phrase.prv rootkey.prv stake.prv | |
chmod 600 *.prv | |
# Recover existing wallet | |
#echo "your wallet 24 words" > phrase.prv | |
# or create a new wallet | |
cardano-address recovery-phrase generate > phrase.prv | |
cat phrase.prv | cardano-address key from-recovery-phrase Shelley > rootkey.prv | |
chmod 400 phrase.prv 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 | |
### Create Payment and Stake vkey/skey files using cardano-cli ### | |
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 | |
touch addr-${NR}.prv | |
chmod 600 addr-${NR}.prv | |
cat rootkey.prv | cardano-address key child 1852H/1815H/0H/0/${NR} > addr-${NR}.prv | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment