Skip to content

Commit

Permalink
Add Bitcoin install guide for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
thobson88 committed Jul 16, 2024
1 parent ee0d2de commit d81d5e1
Showing 1 changed file with 65 additions and 31 deletions.
96 changes: 65 additions & 31 deletions docs/ion.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ IPFS is the InterPlanetary File System, a peer-to-peer protocol and network used

Open the [MongoDB Community Server Download](https://www.mongodb.com/try/download/community) page and download the package for your platform.

Then following the instructions to install MongoDB on Linux
Then following [these instructions](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/) to install MongoDB on Linux


=== "Mac OS"
Expand All @@ -148,17 +148,25 @@ Trustchain has been tested with Bitcoin Core v24.0.1 and therefore the instructi

=== "Linux"

If using sidetree bitcoin install script(https://github.com/decentralized-identity/sidetree/blob/master/lib/bitcoin/setup.sh), pay attention to the following:
Begin by downloading the [Bitcoin Core release](https://bitcoincore.org/bin/bitcoin-core-24.0.1/) for your system:

- [Download link](https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-x86_64-linux-gnu.tar.gz) for Linux with x86-64 processor.
- [Download link](https://bitcoincore.org/bin/bitcoin-core-24.0.1/bitcoin-24.0.1-arm-linux-gnueabihf.tar.gz) for Linux with ARM processor.

* By default the script writes the `testnet` flag to the `bitcoin.conf` file it generates - for a mainnet install, remove this flag.
* It's advised to further edit the `bitcoin.conf` file by setting the `datadir` flag with an absolute path to the desired directory. This ensures the bitcoin chain sync data is directed to a disk with enough space (1T is recommended).
* The `start.sh` file generated by the script is unlikely to work and it is not advised to run it.
Verify the download by comparing the [published hash](https://bitcoincore.org/bin/bitcoin-core-24.0.1/SHA256SUMS) with the result of this command:
```console
$ shasum -a 256 ~/Downloads/bitcoin-24.0.1-*.tar.gz
```

It's advised to set an alias in `~/.bash_profile` for the bitcoin daemon binary with the `-conf` flag set to the path where the `.conf` file is. This ensures that the binary is not accidentally run without the configuration of the `datadir` path.
* Adjust the path to `bitcoind` and `bitcoin.conf`
Unzip the archive: TODO: UNZIP COMMAND IS SPECIFIC TO ARCHITECTURE.
```console
$ (cd ~/Downloads && tar xvzf bitcoin-27.0-x86_64-linux-gnu.tar.gz)
```
and install Bitcoin Core:
```console
alias bitcoind='$insert_correct_path$/bin/bitcoind -conf=$insert_correct_path$/bitcoin.conf'
$ sudo install -m 0755 -t /usr/local/bin bitcoin-24.0.1/bin/*
```
The installation includes an executable file named `bitcoind` which we will run to start Bitcoin Core.

=== "Mac OS"

Expand All @@ -172,7 +180,7 @@ Trustchain has been tested with Bitcoin Core v24.0.1 and therefore the instructi
$ shasum -a 256 ~/Downloads/bitcoin-24.0.1-*.tar.gz
```

Unzip the archive:
Unzip the archive: TODO: UNZIP COMMAND IS SPECIFIC TO ARCHITECTURE.
```console
$ (cd ~/Downloads && tar xvzf bitcoin-24.0.1-arm64-apple-darwin.tar.gz)
```
Expand All @@ -198,10 +206,15 @@ Trustchain has been tested with Bitcoin Core v24.0.1 and therefore the instructi
$ codesign -s - /Applications/bitcoin-24.0.1/bin/bitcoin-cli
```


### Configure Bitcoin Core

Let's begin by creating a folder to store the Bitcoin blockchain data. For convenience, we'll also create an environment variable for that folder.
We shall need to specify a folder to store the Bitcoin blockchain data.

!!! warning "Bitcoin data storage requirements"

TODO... x GB for Mainnet and y GB for Testnet.

For convenience, we create an environment variable for the Bitcoin data folder.

!!! tip "Create the `BITCOIN_DATA` environment variable"

Expand All @@ -210,60 +223,72 @@ Let's begin by creating a folder to store the Bitcoin blockchain data. For conve
$ echo "export BITCOIN_DATA=~/.bitcoin" >> $SHELL_CONFIG; source $SHELL_CONFIG
```

Having defined the `BITCOIN_DATA` environment variable (above), use it to create the data folder itself:
Having defined the `BITCOIN_DATA` environment variable, use it to create the data folder itself:
```console
$ mkdir $BITCOIN_DATA
```

=== "Mainnet"

Bitcoin configuration parameters are stored in the file `/Applications/bitcoin-24.0.1/bitcoin.conf`. The following command adds the required parameters to the beginning of this file:

Bitcoin configuration parameters will be stored in a file named `bitcoin.conf` inside the `$BITCOIN_DATA` folder.
The following command creates that file with the required parameters:
```console
$ sed -i '' "1s|^|server=1\ntxindex=1\ndatadir=$BITCOIN_DATA\n\n|" /Applications/bitcoin-24.0.1/bitcoin.conf
$ echo "server=1\ndaemon=1\ntxindex=1\ndatadir=$BITCOIN_DATA\n\n" > $BITCOIN_DATA/bitcoin.conf
```

To confirm these changes were made correctly, check the first three lines in the `bitcoin.conf` file by running:
```console
$ head -n 3 /Applications/bitcoin-24.0.1/bitcoin.conf
$ head -n 4 $BITCOIN_DATA/bitcoin.conf
```
You should see lines like these printed to the Terminal:
```
server=1
daemon=1
txindex=1
datadir=<PATH_TO_YOUR_BITCOIN_DATA_DIRECTORY>
datadir=<YOUR_BITCOIN_DATA_DIRECTORY>
```

=== "Testnet"

Bitcoin configuration parameters are stored in the file `/Applications/bitcoin-24.0.1/bitcoin.conf`. The following command adds the required parameters to the beginning of this file:

Bitcoin configuration parameters will be stored in a file named `bitcoin.conf` inside the `$BITCOIN_DATA` folder.
The following command creates that file with the required parameters:
```console
$ sed -i '' "1s|^|testnet=1\nserver=1\ntxindex=1\ndatadir=$BITCOIN_DATA\n\n|" /Applications/bitcoin-24.0.1/bitcoin.conf
$ echo "testnet=1\nserver=1\ndaemon=1\ntxindex=1\ndatadir=$BITCOIN_DATA\n\n" > $BITCOIN_DATA/bitcoin.conf
```

To confirm these changes were made correctly, check the first four lines in the `bitcoin.conf` file by running:
To confirm these changes were made correctly, check the first three lines in the `bitcoin.conf` file by running:
```console
$ head -n 4 /Applications/bitcoin-24.0.1/bitcoin.conf
$ head -n 5 $BITCOIN_DATA/bitcoin.conf
```
You should see lines like these printed to the Terminal:
```
testnet=1
server=1
daemon=1
txindex=1
datadir=<PATH_TO_YOUR_BITCOIN_DATA_DIRECTORY>
datadir=<YOUR_BITCOIN_DATA_DIRECTORY>
```

!!! warning "Note: Do not use the `~` shorthand in the `datadir` parameter"

The directory path in the `datadir` parameter must not contain the `~` character as a shorthand for the user's home directory.

The example given in the official [ION install guide](https://identity.foundation/ion/install-guide/) does use this shorthand, which causes an error, so beware of this issue if you edit the `bitcoin.conf` file manually when following that guide.
The example given in the official [ION install guide](https://identity.foundation/ion/install-guide/) does use this shorthand, which causes an error, so beware of this issue if you are following that guide and/or editing the `bitcoin.conf` file manually.

When we start Bitcoin Core we will need to make sure it uses the correct configuration file that was created above. To make this more convenient, let's create an alias in our `SHELL_CONFIG` file:

=== "Linux"

```console
$ echo 'alias bitcoind="/usr/local/bin/bitcoind -conf=$BITCOIN_DATA/bitcoin.conf -daemon"' >> $SHELL_CONFIG; source $SHELL_CONFIG
```

=== "Mac OS"

```console
$ echo 'alias bitcoind="/Applications/bitcoin-24.0.1/bin/bitcoind -conf=$BITCOIN_DATA/bitcoin.conf -daemon"' >> $SHELL_CONFIG; source $SHELL_CONFIG
```

When we start Bitcoin Core we will need to make sure it uses the correct configuration file that was edited above (and we also want to run it as a background process). To make this more convenient, let's create an alias in our `SHELL_CONFIG` file:
```console
$ echo 'alias bitcoind="/Applications/bitcoin-24.0.1/bin/bitcoind -daemon -conf=/Applications/bitcoin-24.0.1/bitcoin.conf -daemon"' >> $SHELL_CONFIG; source $SHELL_CONFIG
```
Now we can use the following simple command to start Bitcoin Core:
```console
$ bitcoind
Expand Down Expand Up @@ -295,9 +320,18 @@ You should now see the message "Bitcoin Core starting" in the Terminal.
Now that your Bitcoin Core node is up and running, you will want to be able to communicate with it. Bitcoin Core provides a command line interface (CLI) for this purpose.

Run the following command to create an alias, making to easy to access the CLI:
```console
$ echo 'alias bitcoin-cli="/Applications/bitcoin-24.0.1/bin/bitcoin-cli -conf=/Applications/bitcoin-24.0.1/bitcoin.conf"' >> $SHELL_CONFIG; source $SHELL_CONFIG
```

=== "Linux"

```console
$ echo 'alias bitcoin-cli="/usr/local/bin/bitcoin-cli -conf=$BITCOIN_DATA/bitcoin.conf"' >> $SHELL_CONFIG; source $SHELL_CONFIG
```

=== "Mac OS"

```console
$ echo 'alias bitcoin-cli="/Applications/bitcoin-24.0.1/bin/bitcoin-cli -conf=$BITCOIN_DATA/bitcoin.conf"' >> $SHELL_CONFIG; source $SHELL_CONFIG
```

!!! info "Bitcoin RPC username and password"

Expand Down

0 comments on commit d81d5e1

Please sign in to comment.