bitcoin-s/docs/applications/configuration.md
Torkel Rogstad c2f37335b8 Bump Scala versions (#697)
* Bump Scala versions

Support Scala 2.12.9
and 2.13.0.

To make this easier, we delete the `scripts` project. Everything
that was in here was covered by content on the website. We also
delete the `doc` folder, as that was a remnant from when `scripts`
was called `doc`.

* Crib uPickle akka-http support while we wait for publish

* Fix compiler warnings

* Add note on test logging to contribution guide

* Reduce duplication in Blockchain implementation

* Use Scala 2.12 for website

* Introduce compat package object for collections converters

* Fix Either compiler warnings

* Add sync-chain and create-wallet docs from deleted scripts

* Fix rebase goofup
2019-08-23 13:53:00 -05:00

1.9 KiB

id title
configuration Application configuration

Bitcoin-S uses HOCON to configure various parts of the application the library offers. HOCON is a superset of JSON, that is, all valid JSON is valid HOCON.

All configuration for Bitcoin-S is under the bitcoin-s key.

If you have a file application.conf anywhere on your classpath when using bitcoin-s, the values there take precedence over the ones found in our reference.conf. We also look for the file bitcoin-s.conf in the current Bitcoin-S data directory.

The resolved configuration gets parsed by AppConfig. AppConfig is an abstract class that's implemented by corresponding case classes in the wallet, chain and node projects. Here's some examples of how to construct a wallet configuration:

import org.bitcoins.wallet.config.WalletAppConfig
import com.typesafe.config.ConfigFactory
import java.nio.file.Paths
import scala.util.Properties

// reads $HOME/.bitcoin-s/
val defaultConfig = WalletAppConfig.fromDefaultDatadir()


// reads a custom data directory
val customDirectory = Paths.get(Properties.userHome, "custom-bitcoin-s-directory")
val configFromCustomDatadir = WalletAppConfig(customDirectory)

// reads a custom data directory and overrides the network to be testnet3
val customOverride = ConfigFactory.parseString("bitcoin-s.network = testnet3")
val configFromCustomDirAndOverride = WalletAppConfig(customDirectory, customOverride)

You can pass as many com.typesafe.config.Configs as you'd like. If any keys appear multiple times the last one encountered takes precedence.

Internal configuration

Database connections are also configured by using HOCON. This is done in db.conf. The options exposed here are not intended to be used by users of Bitcoin-S, and are internal only.