2020-02-26 21:09:44 +01:00
---
id: getting-setup
title: Getting Bitcoin-S installed on your machine
---
2021-03-05 13:10:29 +01:00
> This documentation is intended for setting up development of bitcoin-s.
> If you want to just install bitcoin-s rather than develop,
> see [getting-started](getting-started.md)
2020-02-26 21:09:44 +01:00
## Getting Setup With Bitcoin-S
2020-04-08 23:51:37 +02:00
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE - RUN doctoc TO UPDATE -->
<!-- END doctoc -->
2021-08-11 14:25:27 +02:00
- [Step 1: Developer Runtimes ](#step-1--developer-runtimes )
* [Scala/Java ](#scala-java )
* [Scala.js ](#scalajs )
- [Step 2: Bitcoin-S Repository ](#step-2--bitcoin-s-repository )
+ [Optional: Running full test suite ](#optional--running-full-test-suite )
- [Step 3: Configuration ](#step-3--configuration )
- [Step 4: Building the Server and Setting Up the CLI ](#step-4--building-the-server-and-setting-up-the-cli )
- [Step 5: Setting Up A Bitcoin-S Node ](#step-5--setting-up-a-bitcoin-s-node )
* [Neutrino Node ](#neutrino-node )
* [Bitcoind Backend ](#bitcoind-backend )
- [Step 6 (Optional): Moving To Testnet ](#step-6--optional---moving-to-testnet )
2020-04-08 23:51:37 +02:00
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2021-03-05 13:10:29 +01:00
2021-08-11 14:25:27 +02:00
## Step 1: Developer Runtimes
2020-02-26 21:09:44 +01:00
2021-06-29 18:18:40 +02:00
### Scala/Java
2020-02-26 21:09:44 +01:00
2022-03-23 19:40:03 +01:00
You can choose to install the Scala toolchain with sdkmon or coursier.
#### Sdkman
You can install sdkman [here ](https://sdkman.io/install )
Next you can install `java` and `sbt` with
```
sdk install java
sdk install sbt
```
#### Coursier
2020-02-26 21:09:44 +01:00
2021-06-29 18:18:40 +02:00
If you don't like `curl` , you can use OS specific package managers to install coursier [here ](https://get-coursier.io/docs/2.0.0-RC2/cli-overview.html#installation )
2021-06-21 13:16:43 +02:00
>bitcoin-s requires java9+ for development environments. If you do not have java9+ installed, you will not be able to build bitcoin-s.
[You will run into this error if you are on java8 or lower ](https://github.com/bitcoin-s/bitcoin-s/issues/3298 )
2021-06-29 18:18:40 +02:00
If you follow the coursier route, [you can switch to a java11 version by running ](https://get-coursier.io/docs/2.0.0-RC6-15/cli-java.html )
>cs java --jvm adopt:11 --setup
### Scala.js
We support publishing of [scala.js ](https://www.scala-js.org/ ) artifacts.
This library will compile Scala source code into javascript artifacts.
To be able to run scala js tests, you need to have the Node.js installed.
You can install it from [here ](https://nodejs.org/en/ )
2020-02-26 21:09:44 +01:00
## Step 2: Bitcoin-S Repository
Now, it is time to clone the [Bitcoin-S repository ](https://github.com/bitcoin-s/bitcoin-s/ ) by running
```bashrc
2021-06-21 14:41:58 +02:00
git clone --depth 500 --recursive git@github.com:bitcoin-s/bitcoin-s.git
2020-02-26 21:09:44 +01:00
```
or alternatively, if you do not have ssh setup with github, you can run
```bashrc
2021-06-21 14:41:58 +02:00
git clone --depth 500 --recursive https://github.com/bitcoin-s/bitcoin-s.git
2020-02-26 21:09:44 +01:00
```
2021-01-22 00:33:33 +01:00
2021-04-12 12:58:27 +02:00
#### Optional: Running full test suite
< details >
2021-01-22 00:33:33 +01:00
> WARNING: This should not be done on low resource machines. Running the entire test suite requires at minimum of 4GB
> of RAM on the machine you are running this on.
To run the entire test suite, you need to download all bitcoind instances and eclair instances. This is needed for unit tests
2021-04-12 12:58:27 +02:00
or binding bitcoin-s to a bitcoind instance if you do not have locally running instances.
2020-02-26 21:09:44 +01:00
2022-01-24 00:43:30 +01:00
If you want to run the entire test suite you can run the following command.
2020-02-26 21:09:44 +01:00
```bashrc
sbt test
```
2021-04-12 12:58:27 +02:00
< / details >
2020-02-26 21:09:44 +01:00
## Step 3: Configuration
2021-08-11 14:25:27 +02:00
Now that we have the bitcoin-s repo setup, we want to create our application configurations.
2020-02-26 21:09:44 +01:00
2021-08-11 14:25:27 +02:00
First, create a `$HOME/.bitcoin-s` directory via `mkdir` or an equivalent command.
2020-02-26 21:09:44 +01:00
2022-02-12 14:45:11 +01:00
Next, create a `bitcoin-s.conf` file in `$HOME/.bitcoin-s` . [Here is an example configuration file ](config/configuration.md#example-configuration-file ).
2021-08-11 14:25:27 +02:00
## Step 4: Building the Server and Setting Up the CLI
We are finally ready to start running some programs! Follow the [instructions here ](applications/server.md#building-the-server ) to build the server.
2020-02-26 21:09:44 +01:00
2021-08-11 14:25:27 +02:00
Then, follow [these instructions ](applications/cli.md ) to setup the CLI.
2020-02-26 21:09:44 +01:00
2021-08-11 14:25:27 +02:00
## Step 5: Setting Up A Bitcoin-S Node
2020-08-25 17:33:05 +02:00
2021-02-07 22:00:25 +01:00
There are 2 ways to use the bitcoin-s server. It can either be as a neutrino node or use bitcoind as a backend.
2020-10-06 20:40:24 +02:00
This can be configured by the configuration option `bitcoin-s.node.mode` choosing either `neutrino` or `bitcoind` .
2020-08-25 17:33:05 +02:00
2021-04-12 12:58:27 +02:00
### Neutrino Node
2020-08-25 17:33:05 +02:00
2021-04-12 12:58:27 +02:00
< details >
2020-10-06 20:40:24 +02:00
To use a neutrino server you need to be paired with a bitcoin node that can serve compact filters.
2021-08-11 14:25:27 +02:00
[Suredbits ](https://suredbits.com/ ) runs a mainnet and testnet node you can connect to them by setting your `peers` config option in the `$HOME/.bitcoin-s/bitcoin-s.conf` to:
2020-08-25 17:33:05 +02:00
2020-10-06 20:40:24 +02:00
Mainnet:
2020-02-26 21:09:44 +01:00
2020-10-06 20:40:24 +02:00
`bitcoin-s.node.peers = ["neutrino.suredbits.com:8333"]`
2020-02-26 21:09:44 +01:00
2020-10-06 20:40:24 +02:00
Testnet:
2020-02-26 21:09:44 +01:00
2020-10-06 20:40:24 +02:00
`bitcoin-s.node.peers = ["neutrino.testnet3.suredbits.com:18333"]`
If you would like to use your own node you can either use the bitcoind backend option or connect to your own compatible node.
2022-01-24 00:43:30 +01:00
After building your bitcoin-s server and properly configuring it to be in `neutrino` mode you can start your server with:
2020-02-26 21:09:44 +01:00
```bashrc
./app/server/target/universal/stage/bin/bitcoin-s-server
```
and once this is done, you should be able to communicate with the server using
```bashrc
2021-06-18 15:21:19 +02:00
./app/cli/target/universal/stage/bin/bitcoin-s-cli getnewaddress
2020-02-26 21:09:44 +01:00
```
2021-04-12 12:58:27 +02:00
< / details >
2020-02-26 21:09:44 +01:00
2021-04-12 12:58:27 +02:00
### Bitcoind Backend
2020-10-06 20:40:24 +02:00
2021-04-12 12:58:27 +02:00
< details >
2021-08-11 14:25:27 +02:00
We recommend creating a directory someplace in which to run your `bitcoind` node. Once you have this directory created, add the following `bitcoin.conf` file to it:
```
regtest=1
server=1
rpcuser=[your username here]
rpcpassword=[your password here]
daemon=1
blockfilterindex=1
peerblockfilters=1
debug=1
txindex=1
```
2020-10-06 20:40:24 +02:00
If you already have a bitcoind node running and would like to connect your bitcoin-s server to it you can set your node's mode to `bitcoind` .
You will need to configure bitcoin-s to be able to find your bitcoind.
2020-10-12 14:59:57 +02:00
If you would only like bitcoin-s to connect to bitcoind and start it itself then you only need to properly set the `rpcuser` , and `rpcpassword` options.
2020-10-06 20:40:24 +02:00
If you would like bitcoin-s to launch bitcoind on start up you will need to set the other configuration options.
These options should default to use the latest bitcoind downloaded from `sbt downloadBitcoind` .
```$xslt
bitcoin-s {
bitcoind-rpc {
# bitcoind rpc username
rpcuser = user
# bitcoind rpc password
rpcpassword = password
# Binary location of bitcoind
binary = ${HOME}/.bitcoin-s/binaries/bitcoind/bitcoin-0.20.1/bin/bitcoind
# bitcoind datadir
datadir = ${HOME}/.bitcoin
2021-10-25 13:35:02 +02:00
# bitcoind network host
connect = localhost
2020-10-06 20:40:24 +02:00
# bitcoind p2p port
port = 8333
2021-10-25 13:35:02 +02:00
# bitcoind rpc host
rpcconnect = localhost
2020-10-06 20:40:24 +02:00
# bitcoind rpc port
rpcport = 8332
}
2021-05-14 12:51:02 +02:00
}
2020-02-26 21:09:44 +01:00
```
2021-04-12 12:58:27 +02:00
< / details >
2021-08-11 14:25:27 +02:00
## Step 6 (Optional): Moving To Testnet
2020-02-26 21:09:44 +01:00
2021-02-03 21:26:58 +01:00
To run your Bitcoin-S Server on testnet, simply change `network = testnet3` and change
2021-10-07 01:17:21 +02:00
your `bitcoin-s.node.peers = ["neutrino.testnet3.suredbits.com:18333"] ` in your `$HOME/.bitcoin-s/bitcoin-s.conf` file.
2021-02-03 21:26:58 +01:00
This will allow you to connect to Suredbits' neutrino-enabled `bitcoind` node.
Keep in mind then when you restart your server, it will begin initial sync which will take
many hours as all block filters for all testnet blocks will be downloaded.
If you wish to speed this process up,
download [this snapshot ](https://s3-us-west-2.amazonaws.com/www.suredbits.com/chaindb-testnet-2021-02-03.zip ), unzip it and put the file in your `$HOME/.bitcoin-s/testnet3` directory and then from there, run
2020-02-26 21:09:44 +01:00
2021-10-07 01:17:21 +02:00
This will start syncing your testnet node from block header ~1,900,000 rather than starting from zero.
2020-02-26 21:09:44 +01:00
```bashrc
2022-02-12 15:18:14 +01:00
unzip chaindb-testnet-2021-02-03.zip
mv chaindb.sqlite ~/.bitcoin-s/testnet3/
2020-02-26 21:09:44 +01:00
```
2021-10-07 01:17:21 +02:00
This should take a couple minutes to execute, but once it is done, you will only have a short while left to sync once you start your server.