Does grin-wallet support multiple wallets (multiple private keys)? If so, how would I accomplish this?
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.
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
- Using https://grinnode.live/ API for testing
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.