Create wallets and config files

Two options -- automated and manual -- to create all required configuration.

Option A: Using the quickstart script

We provide a script that automates the setup for wallets and configuration files for five validators and two users.

Before running it:

  • Make sure you have followed all previous setup steps.

  • Make sure that ~/.ipc does not exist. The script will not override it.

From within the bitcoin-ipc repo run:

./target/release/quickstart
circle-exclamation

The script prints the the IPC address (aka ETH address) and the X-Only public key of each validator and user, as well as a whitelist consisting of the first four validators (to be used when creating a subnet).

circle-check

For ease of use, you can extract the IPC address and the whitelist into env variables:

The ~/.ipc directory should have the following structure:

the ~/.ipc directory after the quickstart script

Option B: Manual setup

The script performs the following steps, which you can also do manually.

Step 1: Set up Bitcoin wallets for validators and clients

Throughout the demo we will use six validators (four in the initial subnet and two to demonstrate the dynamic participation) and two clients. In this step we create the necessary bitcoin wallets for them.

In order for each validator to stake, they need to have a bitcoin wallet with enough funds in it. We'll create and fund a bitcoin wallet for each validator.

All wallets should have at least 100 BTC.

After restarting

If in the future you restart bitcoind, you only have to load each wallet:

Step 2: Create IPC wallets for each validator

Now each validator has personal funds on Bitcoin. We will set up an IPC wallet for each validator and each user, that is, eight IPC wallets. This wallet will be used to interact with the child subnet and, for validators, to sign multisig transactions.

circle-check
circle-check

List and record the newly created wallets addresses and corresponding x-only public keys:

Pick four validators that you want to use in the initial subnet and

  • Write down their IPC addresses, or set the env variables ${IPC_ADDRESS_OF_VALIDATOR_1} , ..., ${IPC_ADDRESS_OF_VALIDATOR_4} . The IPC address is printed as Address: by ipc-cli and starts with 0x .

  • Construct and write down the validator-whitelist (to be used in the next step) as a comma-separated list using the the x-only public keys of these four validators return by ipc-cli (printed as XonlyPubKey:). This should look like the following. Observe that there are no empty spaces between the keys.

Let's export the secret keys of all validators:

circle-check

Step 3: Create .env file for each validator and user

The .env file of each validator is used by the bitcoin monitor and bitcoin provider.

Create .env for validators

Navigate to bitcoin-ipc directory and run the following commands:

In each .env file modify the values

  • RPC_USER and RPC_PASS : Update them if you changed the default values in the bitcoin.conf file (in Bitcoin Regtest)

  • WALLET_NAME : Use the bitcoin wallet names created on the previous step ("validator1", ... "validator5")

  • DATABASE_URL : You can use <HOME_DIR>/.ipc/validator1/regtest_db , ... , <HOME_DIR>/.ipc/validator5/regtest_db

  • PROVIDER_PORT : Use ports 3030, 3031, 3032, 3033, 3034, respectively.

  • PROVIDER_AUTH_TOKEN : You can use validator1_auth_token , ... , validator5_auth_token

  • VALIDATOR_SK_PATH : Use <HOME_DIR>/.ipc/validator1/validator.sk , ..., <HOME_DIR>/.ipc/validator5/validator.sk

  • replace <HOME_DIR> with your absolute home directory path.

Let's see the ~/.ipc/validator1/.env file as an example:

Create .env for users

Let's do the same for the users.

Edit the two new .env files as follows:

  • RPC_USER and RPC_PASS : Update them if you changed the default values in the bitcoin.conf file (in Bitcoin Regtest)

  • WALLET_NAME : Use user1 and user2 , respectively.

  • DATABASE_URL : You can use <HOME_DIR>/.ipc/user1/regtest_db and <HOME_DIR>/.ipc/user2/regtest_db , respectively

  • PROVIDER_PORT : Use 3040, 3041, respectively

  • PROVIDER_AUTH_TOKEN : You can use user1_auth_token and user2_auth_token , respectively

  • VALIDATOR_SK_PATH : It is irrelevant, it is only used by validators

  • replace <HOME_DIR> with your absolute home directory path.

Let's see the ~/.ipc/validator1/.env file as an example:

Step 5: Initialise the config file for each validator and user

The config.toml of each validator file is used by Fendermint and by ipc-cli.

Navigate to the ipc repo and run the following.

For each validator's and user's config file, modify:

  • provider_http to match the port you set in PROVIDER_PORT in the .env file of the validator, that is, using ports 3030, 3031, 3032, 3033, 3034 for the validators and 3040, 3041 for the user.

  • auth_token to match the PARENT_AUTH_TOKEN you've set in the .env file of the validator, that is use validator1_auth_token , ... , validator5_auth_token for validators and user1_auth_token , ... , user2_auth_token for users.

Let's see ~/.ipc/validator1/config.toml for example. It should look similar to the following.

circle-check

Last updated