-
Notifications
You must be signed in to change notification settings - Fork 8
Running ZCash Regtest
In order to run zcash regtest, you'll need zcashd
and zcash-cli
. You can get those by following this guide: https://zcash.readthedocs.io/en/latest/rtd_pages/user_guide.html#installation
I also suggest setting up an alias for running regtest commands, something like
alias zreg='zcash-cli -regtest -rpcuser=zcash_user -rpcpassword=zcash_password'
All future commands in this doc will assume you have a zreg
alias setup.
Run the following to get the regtest daemon started (Refer to README if you're running for the first time.)
zcashd -daemon -datadir=./.zcash
Confirm it's running by using zcash-cli
to check something:
zreg getnetworkinfo
You can stop it by running
zreg stop
Blocks must be mined manually in regtest mode. You can do so by running
zreg generate (num blocks)
This will generate blocks that reward you with the coinbase. You can run z_gettotalbalance
after to confirm you now have money. It takes ~100 blocks before you start being able to access mining rewards.
Once you've mined some blocks, you'll have some coinbase UTXOs. In order to spend these, you must transfer them to a z address first, otherwise you'll get the error Could not find any non-coinbase UTXOs to spend
. So initially you'll want to run the following to make them spendable:
# Run these if you don't yet have a t-address and z-address respectively
zreg getnewaddress
zreg z_getnewaddress sprout
# Send money to z-address, change amount as needed
zreg z_sendmany T_ADDR_HERE '[{"address": "Z_ADDR_HERE", "amount": 9.9999}]'
Send 9.9999 because coinbases can't have any dust, and the default tx fee is 0.0001
This will create a new operation which you can check in on by running
zreg z_getoperationstatus '["OPID_HERE"]'
Zcash sends are done asynchronously due to the time it takes to generate a sprout transaction. It should take about 40 seconds before the status becomes "success".
You will need to send the precise amount of zcash that you have in your UTXO, since z_sendmany does not allow for change. So you'll likely need to run z_getoperationstatus
, see how much you're off by, and add it to your amount.
Once the operation runs successfully, you'll need to mine a few blocks, and your funds will be available in the new address. Now that you've got your coinbase money in a non-coinbase address, you're free to send it around as you see fit. Thank god!
You can tail -f .zcash/regtest/debug.log
if you want to monitor logs. Running zcashd with debug=1
will add a lot more detail to the logging.
If you want to start regtest over from scratch, just delete the whole regtest folder (.zcash/regtest
if run using command in README) and start again.