Skip to content

Instantly share code, notes, and snippets.

@jbpin
Last active February 27, 2021 14:54
Show Gist options
  • Save jbpin/524f91a21808cc0d52ca3de2cbe9eb90 to your computer and use it in GitHub Desktop.
Save jbpin/524f91a21808cc0d52ca3de2cbe9eb90 to your computer and use it in GitHub Desktop.
Cardano Wallet HD -> Stake address

Generate key and address for stake and reward

| this work is based on https://gist.github.com/ilap/3fd57e39520c90f084d25b0ef2b96894

cat seed.txt | cardano-address key from-recovery-phrase Shelley > root.prv
cat root.prv | cardano-address key child 1852H/1815H/0H/0/0 > payment.xprv
cat root.prv | cardano-address key child 1852H/1815H/0H/2/0 > stake.xprv

cat payment.xprv \
| cardano-address key public --with-chain-code \
| cardano-address address payment --network-tag 1 \
| cardano-address address delegation $(cat stake.xprv | cardano-address key public --with-chain-code ) \
| tee base.addr_candidate \
| cardano-address address inspect

cardano-cli key convert-cardano-address-key --shelley-payment-key --signing-key-file payment.xprv --out-file payment.skey
cardano-cli key convert-cardano-address-key --shelley-stake-key --signing-key-file stake.xprv --out-file stake.skey

cardano-cli key verification-key --signing-key-file stake.skey --verification-key-file stake.evkey
cardano-cli key verification-key --signing-key-file payment.skey --verification-key-file payment.evkey

cardano-cli key non-extended-key --extended-verification-key-file payment.evkey --verification-key-file payment.vkey
cardano-cli key non-extended-key --extended-verification-key-file stake.evkey --verification-key-file stake.vkey

cardano-cli stake-address build \
  --stake-verification-key-file stake.vkey \
  --out-file stake.addr \
  --mainnet

# I think we don't need this but in case. 
cardano-cli address build \
  --payment-verification-key-file payment.vkey \
  --out-file deposit.addr \
  --mainnet

cardano-cli address build \
  --payment-verification-key-file payment.vkey \
  --stake-verification-key-file stake.vkey \
  --mainnet > base.addr

echo "Important the base.addr and the base.addr_candidate must be the same"
diff -s base.addr base.addr_candidate
# remove temp files. (optimiztion would be to store then in vars) 
rm root.prv payment.xprv stake.xprv stake.evkey payment.evkey base.addr_candidate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment