Creating a new wallet

Wallets are collections of addresses and their corresponding keys. Every node can have one or more wallets, but each node only has one default wallet. When running goal account or clerk commands the default wallet will be used unless the -w option is used. This option allows commands to be executed for a specific wallet. You can also change the default wallet by using the goal wallet -f option. This tutorial walks through creating a wallet and adding an account to it. 

Create the Private Network

See the creating private network tutorial for details on the network template.

goal network create -r ~/net1 -n private -t <path_to_template.json>

Start the Network

goal network start -r ~/net1

You can check that the status of the network is working by running the following command:

goal network status -r ~/net1

Add a new Wallet

You can list the current wallets a node manages by running the following command:

goal wallet list -d ~/net1/Primary

Which should return output similar to the following text. 

##################################################
Wallet:	unencrypted-default-wallet
ID:	3b21951f72565deeed2fd75dce18fbaf
##################################################

This node only has the default wallet created when we created the private network. By default, this is unencrypted, which is not ideal.  

To create a new wallet run this command.

goal wallet new MyWallet -d ~/net1/Primary

This will create a wallet and you will be prompted to enter the password for the wallet. In addition, you will be given the option to retrieve the mnemonic/backup phrase should you ever need to recover the wallet.

Please choose a password for wallet 'MyWallet': 
Please confirm the password: 
Creating wallet...
Created wallet 'MyWallet'
Your new wallet has a backup phrase that can be used for recovery.
Keeping this backup phrase safe is extremely important.
Would you like to see it now? (Y/n): Y
Your backup phrase is printed below.
Keep this information safe -- never share it with anyone!

ankle symptom tenant estate acoustic swarm extend uphold rescue code must exhaust lyrics client skill tray stuff undo original atom stairs ten pole abandon uncle

If you ever need to recover the wallet you can specify that using the -r option with the goal wallet new command.

goal wallet new MyWallet -r -d ~/net1/Primary

If you list the wallets again you will see the newly created one.

##################################################
Wallet:	MyWallet
ID:	a6ec169545116dcd2f0da216f12f70dc
##################################################
Wallet:	unencrypted-default-wallet
ID:	3b21951f72565deeed2fd75dce18fbaf
##################################################

Set the Default Wallet

You can now set the default wallet with goal like:

goal wallet -f MyWallet -d ~/net1/Primary

Add an Account to the Wallet

You can use the goal account commands to add or list accounts in the new wallet. 

goal account new -d ~/net1/Primary

goal account list -d ~/net1/Primary

You can also specify the wallet when creating an account.

goal account new -w MyWallet -d ~/net1/Primary