Skip to content

Instantly share code, notes, and snippets.

@nuke-web3
Last active September 29, 2021 20:33
Show Gist options
  • Save nuke-web3/b8587d676c38c4578634aa6fdf72b06b to your computer and use it in GitHub Desktop.
Save nuke-web3/b8587d676c38c4578634aa6fdf72b06b to your computer and use it in GitHub Desktop.

Revisions

  1. nuke-web3 revised this gist Apr 27, 2021. 1 changed file with 14 additions and 4 deletions.
    18 changes: 14 additions & 4 deletions check_substrate_address.sh
    Original file line number Diff line number Diff line change
    @@ -20,13 +20,20 @@ echo " *** Address finder ***
    echo "*** A Script using the \`subkey\` to search for your address over various derivation paths ***"
    echo "------------------------------"

    echo "*****"
    echo "First check your seed words show up in the BIP39 list"
    echo "https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt"
    echo "If there are words that you have recorded that are *not* in this list,"
    echo "you should look for what you might have had mistaken!"
    echo "all valid words are in this list!"
    echo "*****"

    # subkey needs to be installed.
    if ! command -v subkey &> /dev/null
    then
    echo "Command subkey not found!! You must install this first."
    echo "- Instructions to build and use subkey: https://substrate.dev/docs/en/knowledgebase/integrate/subkey"
    echo "- Or use the already compiled version: https://github.com/paritytech/substrate/releases/download/v2.0.1/subkey"
    echo "(and check the binary's integrity with https://github.com/paritytech/substrate/releases/download/v2.0.1/substrate.asc )"
    echo "Instructions and instaliation found here:"
    echo "https://substrate.dev/docs/en/knowledgebase/integrate/subkey"
    exit
    fi

    @@ -112,4 +119,7 @@ done | grep -B4 $ADDRESS
    echo "------------------------------"
    echo "Search Complete! If nothing found above, try to edit the script for various other derivation paths."
    echo "Need more help? Look for support: https://support.polkadot.network/support/home"
    echo "------------------------------"
    echo "------------------------------"
    echo "BE SURE TO CLEAR YOUR BASH HISTORY NOW!!! run:"
    echo "history -c"
    echo "More infor here: https://linuxhint.com/clear_bash_history/"
  2. nuke-web3 revised this gist Apr 15, 2021. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions check_substrate_address.sh
    Original file line number Diff line number Diff line change
    @@ -24,8 +24,9 @@ echo "------------------------------"
    if ! command -v subkey &> /dev/null
    then
    echo "Command subkey not found!! You must install this first."
    echo "Instructions and instaliation found here:"
    echo "https://substrate.dev/docs/en/knowledgebase/integrate/subkey"
    echo "- Instructions to build and use subkey: https://substrate.dev/docs/en/knowledgebase/integrate/subkey"
    echo "- Or use the already compiled version: https://github.com/paritytech/substrate/releases/download/v2.0.1/subkey"
    echo "(and check the binary's integrity with https://github.com/paritytech/substrate/releases/download/v2.0.1/substrate.asc )"
    exit
    fi

  3. nuke-web3 created this gist Apr 15, 2021.
    114 changes: 114 additions & 0 deletions check_substrate_address.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,114 @@
    #!/bin/bash

    # Use this script to try various derivation paths and passowords for a known seed.
    # ****NOTE!!!!****
    # DO NOT SAVE THIS FILE WITH YOUR SEED IN IT!!!!
    # INSTEAD RUN THIS ONCE AS IS, THEN MANALLY SET

    # YOU MUST EDIT THESE VARIABLES *NOT IN THIS FILE*!!
    # SET THESE IN YOUR TERMINAL:
    # SECRET="<put your seed words / mnemonic here>"
    # PASSWORD="<put your password here, could be empty, so just quotes "">"

    # Set your *real* variables like this in your terminal ONLY.
    # Don't save your secrets here in the file!!!

    # ---------------------------------- BEGIN SCRIPT ----------------------------------

    echo "------------------------------"
    echo " *** Address finder *** "
    echo "*** A Script using the \`subkey\` to search for your address over various derivation paths ***"
    echo "------------------------------"

    # subkey needs to be installed.
    if ! command -v subkey &> /dev/null
    then
    echo "Command subkey not found!! You must install this first."
    echo "Instructions and instaliation found here:"
    echo "https://substrate.dev/docs/en/knowledgebase/integrate/subkey"
    exit
    fi

    # TODO: Do a check for existing *shell* (not env) variables, otherwise use a default for testing.
    # https://www.baeldung.com/linux/bash-variables-export
    # for now, we need them to exist in the env (exported)
    if [[ -z "${SECRET}" ]]; then
    echo "SECRET phrase / mnemonic not set! Using default for test: \"increase dust illegal pottery half kite broccoli force cheese miss arrange cushion\""
    SECRET="increase dust illegal pottery half kite broccoli force cheese miss arrange cushion"
    echo "To set your secret, use \`export SECRET=\"<put your secret here>\"\`"
    echo "Then re-run this script"
    else
    echo "!! Found user set SECRET phrase / mnemonic !!"
    # echo $SECRET
    fi

    if [[ -z "${PASSWORD}" ]]; then
    echo "PASSWORD not set! Using default: \"\""
    PASSWORD=""
    echo "To set your password, use \`export PASSWORD=\"<put your password here>\"\`"
    echo "Then re-run this script"
    else
    echo "!! Found user set PASSWORD !!"
    # echo $PASSWORD
    fi

    if [[ -z "${NETWORK}" ]]; then
    echo "NETWORK not set! Using default: \"polkadot\""
    NETWORK="polkadot"
    echo "To set your network, use \`export NETWORK=\"<put your network here>\"\`"
    echo "Then re-run this script"
    else
    echo "!! Found user set NETWORK !!"
    # echo $NETWORK
    fi

    if [[ -z "${ADDRESS}" ]]; then
    echo "ADDRESS not set! Using default: \"13KsHzKyUtHaXQNjzcPGk17wFzbyzkogwgRoEKYftrL8e7vV\""
    ADDRESS="13KsHzKyUtHaXQNjzcPGk17wFzbyzkogwgRoEKYftrL8e7vV"
    echo "To set your address, use \`export ADDRESS=\"<put your address here>\"\`"
    echo "Then re-run this script"
    else
    echo "!! Found user set ADDRESS !!"
    # echo $ADDRESS
    fi

    echo "------------------------------"
    echo "Running search for "$ADDRESS" in with provided information various derivation paths"
    echo "...If nothing found, there will be no output..."
    echo "------------------------------"

    # *************************************************
    # NOTE: edit these to try other paths!!
    # *************************************************

    # try with no path or password
    subkey inspect --network $NETWORK "$SECRET" | grep -B4 $ADDRESS
    # try with only password
    subkey inspect --network $NETWORK "$SECRET///$PASSWORD" | grep -B4 $ADDRESS

    # loop over various derivation paths
    # parity signer uses a few: https://github.com/paritytech/parity-signer/blob/master/src/constants/networkSpecs.ts
    # see the `pathId` variable
    for i in "" 0 1 2 3 4 polkadot kusama kusama_dev centrifuge edgeware kulupu substrate_dev rococo westend
    do subkey inspect --network $NETWORK "$SECRET//$i///$PASSWORD";
    done | grep -B4 $ADDRESS

    for i in "" 0 1 2 3 4 polkadot kusama kusama_dev centrifuge edgeware kulupu substrate_dev rococo westend
    do for j in 0 1 2 3 4;
    do subkey inspect --network polkadot "$SECRET//$i//$j///$PASSWORD"
    done
    done | grep -B4 $ADDRESS

    for i in "" 0 1 2 3 4 polkadot kusama kusama_dev centrifuge edgeware kulupu substrate_dev rococo westend
    do for j in 0 1 2 3 4
    do for k in 0 1 2 3 4
    do subkey inspect --network $NETWORK "$SECRET//$i//$j//$k///$PASSWORD"
    done
    done
    done | grep -B4 $ADDRESS

    # Get more help if needed
    echo "------------------------------"
    echo "Search Complete! If nothing found above, try to edit the script for various other derivation paths."
    echo "Need more help? Look for support: https://support.polkadot.network/support/home"
    echo "------------------------------"