MASP Key Management
This section will detail the commands to generate spending keys, viewing keys and payment addresses with namadaw
.
For an explanation of the different types of keys and addresses, see the glossary.
Generating a spending key and viewing key
The first step before interacting with the MASP is to create a spending key. A spending key is loosely analogous to the private key you may be familiar with from transparent accounts, in the sense that it grants one the authority to spend tokens in the associated account (and must always be kept secret). Create a new spending key with:
namadaw gen --shielded --alias $SPENDING_KEY_ALIAS
This command will also generate a corresponding Viewing Key sharing the same alias.
You will be prompted to provide an encryption passphrase. Once the key is created, your recovery mnemonic will be displayed in the terminal.
WARNING: Keep your mnemonic and passphrase safe. Loss of either can result in you being locked out of your accounts with no chance of recovering your funds.
Birthdays
When generating a spending key, you can optionally specify a birthday, like so:
namadaw gen --shielded --alias $SPENDING_KEY_ALIAS --birthday $BIRTHDAY
The birthday of a key is a block height before the key was created. Ideally, it should be as close to the current block height as possible. Recall that the current block height can be queried via:
namadac block
The purpose of giving your keys a birthday is to let the wallet know that when scanning the ledger for MASP transactions belonging to this key, there is no need to search blocks prior than the specified birthday. This can provide a lot of time savings when performing shielded sync.
If no birthday is provided for a spending key, the birthday is set to the genesis block by default. Furthermore, any viewing key derived from the spending key inherits its birthday.
Birthdays can also be provided when adding or deriving keys. By re-adding an existing key with a new birthday, you can
update a key's birthday in the wallet. Keys passed to shielded-sync directly (as opposed to being stored in the wallet),
can also be passed in with birthdays. This is done simply by by appending <<{BIRTHDAY}
to the end of the key.
Displaying your spending key and viewing key
You can display your viewing key with:
namadaw list --shielded
You can also display your spending key (your spending key should always be kept private, so use caution when executing this command):
namadaw list --shielded --unsafe-show-secret --decrypt
Generating a payment address
Once you have created a spending key, it can be used to derive a payment address. A payment address begins with znam
and is a public-facing address which you can
share when you wish to receive tokens.
namadaw gen-payment-addr --alias $PAYMENT_ADDRESS_ALIAS --key $SPENDING_KEY_ALIAS
It is possible (and recommended) to generate multiple payment addresses from the same spending key.
Displaying your payment addresses
You can display all payment addresses associated with your spending key(s) with:
namadaw list --shielded
Recovering an existing spending key from mnemonic
You can recover an existing spending key from your mnemonic and add it to your wallet with:
namadaw derive --alias $SPENDING_KEY_ALIAS --shielded
Adding an existing key or payment address to your wallet
If you know the raw value of a spending key, viewing key or payment address, you can add it to your wallet under an alias so you can more conveniently refer to it later.
namadaw add --alias $ALIAS --value $HEX_VALUE
where $HEX_VALUE
is the hex value of a spending key, viewing key or payment address.
Removing a key/address
You can remove all keys/addresses associated with an alias from your wallet with:
namadaw remove --alias $ALIAS --do-it