How to have multiple wallets in grin-wallet?

Does grin-wallet support multiple wallets (multiple private keys)? If so, how would I accomplish this?

2 Likes

The official CLI wallet supports multiple sub-accounts in one main wallet.
e.g.
Wallet1 (one private key)

  • Sub1 (can be restored by above private key)
    β†’ Sub2 …

I am personally using this script here GitHub - hendi/grin-multi-wallet-scripts to generate multiple wallets with its own private keys.

Once created you can distribute your GRINS accordingly.

Can you explain how to do this without using that script?

I understand that there is an account system in the official grin-wallet CLI. What exactly are accounts; are they separate private keys with they’re own backup phrases, or are they derived keys in a hierarchical deterministic kind of way?

Accounts are just derived keys from a single HD seed. There’s really not an easy way to do what you want. You’ll either have to use accounts, switch to Grin++, or create several directories with different wallets and keep changing the config to point to the one you want.

So if I understand correctly: grin-wallet supports multiple wallets by creating a wallet directory using the following command:

grin-wallet -d directoryname init

This will create a directory named directoryname in the current working directory. The official wallet CLI will recognize when it’s in this directory during execution of commands like grin-wallet info.

So, if I wish to create a wallet for purpose of offline storage, I can simply delete this directory after funds have been transferred (of course the seed phrase would be backed-up somewhere)?

Is there anything else I should know about? What are β€œaccounts” when it comes to the official wallet CLI?

It looks like grin-wallet will use the current working directory as the wallet if it contains the wallet files generated from grin-wallet -d [directory-name] init. So, I wouldn’t need to change the my main config it seems.

1 Like

I too would like to know how to have multiple wallets in grin. I’m not good at rust, but i’d really like to see this implemented into the rust client. I feel that it is a must. Grin++ supports this, however I’m not sure if it has command line options, does anybody know?

do I really have to swap ./grin/wallet_data, will that even work?

A short and basic example of how to use the rust grin-wallet to have multiple wallets:

Requirements:

  • Full GRIN-Node already synced

or

Example(s):
In this example I am using the API from Grinnode.live because its always available and does not rely on your local GRIN-node to be fully synced. But for production systems you should use your OWN GRIN-Node!

We generate a folder called grin-wallets and create 3 (three) sub-folders:

  • wallet1
  • wallet2
  • wallet3
_$ ../grin-wallets$ tree

β”œβ”€β”€ wallet1
β”œβ”€β”€ wallet2
└── wallet3

Now we initialize into each folder one GRIN-Wallet using the command-line:

_$ ../grin-wallets$ grin-wallet --api_server_address "https://grinnode.live:3413" -t wallet1/ init

Please enter a password for your new wallet
Password: 
Confirm Password: 
20211105 22:52:38.721 WARN grin_wallet_impls::lifecycle::seed - Generating wallet seed file at: wallet1/wallet_data/wallet.seed
Your recovery phrase is:

race share girl solar initial awkward guess view tiger west pottery energy lecture dream quantum nose mountain brick brave company spider casual journey talent

Please back-up these words in a non-digital format.
Command 'init' completed successfully

with the -t wallet1 we just specify a folder where we want out wallet files to be stored.

We repeat this step for all 3 folders wallet1 + wallet2 + wallet3, once done we can now use the 3 wallets using:

grin-wallet --api_server_address "https://grinnode.live:3413" -t wallet2/ info

20211105 22:55:20.558 ERROR grin_wallet_impls::node_clients::http - Error calling get_version: Request error: Cannot make request: error trying to connect: tcp connect error: Connection refused (os error 111)
20211105 22:55:20.558 ERROR grin_wallet_impls::node_clients::http - Unable to contact Node to get version info: Client Callback Error: Error calling get_version: Request error: Cannot make request: error trying to connect: tcp connect error: Connection refused (os error 111)
Password: 
20211105 22:55:21.835 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20211105 22:55:22.377 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20211105 22:55:22.398 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20211105 22:55:22.400 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning Complete

____ Wallet Summary Info - Account 'default' as of height 1470323 ____

 Confirmed Total                  | 0.000000000 
 Awaiting Confirmation (< 10)     | 0.000000000 
 Awaiting Finalization            | 0.000000000 
 Locked by previous transaction   | 0.000000000 
 -------------------------------- | ------------- 
 Currently Spendable              | 0.000000000 

Command 'info' completed successfully

If you correctly did setup your 3 wallets in three different folders you should get something similar to my example here:

.
β”œβ”€β”€ wallet1
β”‚   β”œβ”€β”€ grin-wallet.log
β”‚   β”œβ”€β”€ grin-wallet.toml
β”‚   └── wallet_data
β”‚       β”œβ”€β”€ db
β”‚       β”‚   └── lmdb
β”‚       β”‚       β”œβ”€β”€ data.mdb
β”‚       β”‚       └── lock.mdb
β”‚       β”œβ”€β”€ saved_txs
β”‚       └── wallet.seed
β”œβ”€β”€ wallet2
β”‚   β”œβ”€β”€ grin-wallet.log
β”‚   β”œβ”€β”€ grin-wallet.toml
β”‚   └── wallet_data
β”‚       β”œβ”€β”€ db
β”‚       β”‚   └── lmdb
β”‚       β”‚       β”œβ”€β”€ data.mdb
β”‚       β”‚       └── lock.mdb
β”‚       β”œβ”€β”€ saved_txs
β”‚       └── wallet.seed
└── wallet3
    β”œβ”€β”€ grin-wallet.log
    β”œβ”€β”€ grin-wallet.toml
    └── wallet_data
        β”œβ”€β”€ db
        β”‚   └── lmdb
        β”‚       β”œβ”€β”€ data.mdb
        β”‚       └── lock.mdb
        β”œβ”€β”€ saved_txs
        └── wallet.seed

15 directories, 15 files

Now you have 3 independent wallets in three different folders.
Adjust your TOR binaries if needed and you good to go.

Additionally you can setup accounts on each wallet, but this is a topic for another time.

4 Likes