# Node Wallet
Every node has a connected wallet providing:
- ability to mine,
- ability to sign transactions.
A node can have only one wallet with one seed. Seed can be a secret phrase (a random set of 15 English words) converted to bytes, or an arbitrary array of bytes long enough to be unrealistically unlikely to be matched.
The node's main account is generated from the seed with a 4-byte nonce prefix of 0. Additional accounts can be created by the POST /addresses
operation of node's REST API; they are based on the same seed and incremental nonce values. Account generation rules are described in the Cryptographic practical details article.
In this article, the following use cases of wallet are reviewed:
- Create a new wallet from scratch
- Create a wallet using existing seed
- Use existing wallet
- Update wallet settings
- Change node's wallet
# Create New Wallet From Scratch
On startup, a node creates a wallet if the directory listed in wallet
section of node's configuration file does not already contain wallet.dat
file.
During the wallet creation the node does the following:
- generates a random seed;
- writes the generated seed to STDOUT;
- requests in the console password to encrypt the seed.
The encrypted seed is saved in wallet.dat
file. To avoid entering the password every time you run the node, specify the password in the wallet
section of the configuration file.
# Create Wallet Using Existing Seed
If you already have a seed, then input the following parameters in the wallet
section of node's configuration file:
- base58 encoded seed.
- password.
Base58 encoded seed length must not exceed 192 characters. A 24-word secret phrase may not be suitable as a seed.
There are many converters available to encode the secret phrase to base58. For security reasons, it makes sense to use Ride REPL in Waves IDE. To encode the passphrase in base58, paste into the console
"your-seed-phrase".toBytes().toBase58String()
If necessary, change the path to directory where the generated wallet.dat must be placed. wallet
section example with described settings is provided below:
wallet {
file = ${waves.directory}"/wallet/wallet.dat"
password = "some-string-as-password"
seed = "base58-encoded-seed"
}
As a result, the wallet.dat will be generated in the selected directory based on the existing seed.
More about the configuration file
# Use Existing Wallet
If you already have the wallet.dat created before, then just put it in the directory listed in the wallet
section of node's configuration file, and specify a password for it with the password
parameter. Additional actions are not required.
# Update Wallet Settings
If you want to run the node with another wallet, use one of the following instuctions:
- Replace
wallet.dat
file with the file which contains the seed of another wallet.
OR
- Delete/move to another location your
wallet.dat
file. Then update the seed in the node's configuration file.
After restarting the node will use another wallet settings.
# Change Node's Wallet
If you need to change node's account, first of all, delete or move the existing wallet.dat
. After that, you can:
If the seed in the
wallet.dat
file and in the node's configuration file do not match, the node will not start.
# Get node seed and private keys
You can obtain the base58-encoded node seed using the GET /wallet/seed
operation of the Node REST API. The operation requires the API key.
Using the base58-encoded seed, you can import the main node account into WX Network: Import accounts → Seed or Key → Encoded seed.
This way is not suitable for other accounts of the node wallet. Instead, you can obtain the account seed
for them (see the definition of account seed in Cryptographic practical details) using the GET /addresses/seed/{address}
of the Node REST API and then generate the account's private key from the account seed
. Run the following commands on the host where the node is running (insert your API key and the account address):
curl -s -H "x-api-key: ${api_key}" http://localhost:6869/addresses/seed/${address} | \
jq -c -r .seed | \
tr -d '\n' | \
waves util crypto create-keys -i - -o - | \
jq -r .privateKey
# Generate blocks by multiple accounts
Multiple accounts can generate blocks using one node. To do this, specify the private keys of generating accounts (base58-encoded) in the waves.miner.private-keys
parameter of the node's configuration file.
Example (do not use these keys on a real node!):
waves {
...
miner {
private-keys = [
"8V6ZDT59tAGV9Lwvv4bt7WSEwsBD3cPrTd65dxEJr1",
"FJgR2bv8fbJZanF6dRm7i8D1Y8rCtKyrsBbKs5UPRP"
]
}
}
If at least one private key is specified, the main account from the node's wallet does not generate blocks (however, it can still be used for signing transactions).