Cold wallet implementation (DEPRICATED) - hadescoincom/hds-core GitHub Wiki
- can generate private keys, i.e. it has master key generated from seed phrase
- has no connection with internet, as a result, it cannot send transactions to the node, and it cannot get proofs and notifications from the node
- cannot generate any secrets from master key by the reason that it doesn't have it
- has internet connection and can send/get messages from the node
The goal of this design is to get cold wallet scenario with minimal changes in existing codebase.
The main idea is to split wallet database (wallet.db) onto two parts: public (wallet.db) and private (wallet.db.private). The last one should hold master key generated from seed phrase. "Cold" wallet has both of these files, "hot" has public data only. To be able to make tranasctions with this setup user have to constantly move public wallet.db file between "cold" and "hot" wallets. Since we override wallet.db we have to stop "hot" wallet before we copy wallet.db file from/into its folder
- For "Cold" wallet we don't set up connection with the node.
- "Cold" wallet stores all outgoing encrypted messages into public database (wallet.db), we subclass existing behavior with SBBS
- Add a stage for processing stored incoming messages.
- For "hot" wallet there is a need to add some checks if it has master key, also "hot" wallet has no ability to decrypt incoming SBBS messages, since it doesn't have private keys, so it has to store all incoming messages from the channel.
To tell wallet that it works in "cold" mode you have to add --cold_wallet
parameter
hds-wallet init --cold_wallet
This command will create two databases: wallet.db and wallet.db.private
Pre-conditions: Make sure the cold wallet is synced. In order to do so, follow the next steps:
- copy the wallet.db file to the "hot" wallet's data folder.
- launch the "hot" wallet and wait till it's synced.
- stop the "hot" wallet, copy the wallet.db file into the "cold" wallet folder.
- launch the "cold" wallet for listening.
hds-wallet listen --cold_wallet
Now as the "cold" wallet is synced, proceed with the next steps:
- In the cold wallet run the command:
hds-wallet send -a <amount> -r<receiver address> -f <fee> --cold_wallet
Note: there is no need in node address in this case - copy wallet.db file to "hot" wallet's data folder
- launch "hot" wallet. It should send encrypted message to the node, also he may get encrypted message back.
- stop "hot" wallet, copy wallet.db file into "cold" wallet folder
- launch "cold" wallet for listening
hds-wallet listen --cold_wallet
it should create a signed transaction kernel - copy wallet.db from "cold" to "hot" new transaction should go to the node and got confirmed
- copy wallet.db from "hot" to "cold" "cold" wallet should have actual balance and transactions statuses
- Generate new address in "cold" wallet and send it to the sender
- copy wallet.db to "hot"
- launch "hot" wallet. Note there will be no new transactions, since "hot" wallet cannot decrypt incoming messages
- stop "hot". copy wallet.db from "hot" to "cold"
- launch "cold" wallet for listening, it should get new transaction and accept it.
- copy wallet.db from "cold" to "hot"
- launch "hot", wait until new transaction becomes completed
- copy wallet.db "hot" to "cold" balance and transactions statuses should be correct.