Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Running JoinMarket with Bitcoin Core full node

unsystemizer edited this page Jul 29, 2017 · 37 revisions

Running JoinMarket with a full node.

JoinMarket can use different methods to interface with the bitcoin network and the blockchain, which is needed to find the balance of your wallet and broadcast transactions.

The default method is to query the blockr.io blockchain explorer web API. There are a few disadvantages to this:

  • Privacy is degraded because a single company knows which addresses are yours and which transactions you broadcast. They are able to unmix all your coinjoins. Blockr.io is owned by Coinbase.com which is bound by law to collect information. They may also to sell it to advertisers. Historically they have attempted to censor bitcoin user's transactions.
  • Resources are wasted and speed reduced by constantly polling the website.
  • Response time is slower as you will not be notified of new blocks immediately.

If you use JoinMarket to improve privacy and run efficiently, blockr.io is clearly unacceptable.

Yield Generator

If you run a yield generator for the purpose of profit, using blockr.io will reduce your response time which will lead to a worse rating by market takers who are your customers, takers will start to avoid you in favour of faster makers. A full bitcoin node will also enable you to accurately estimate the required miner fee using the estimatefee RPC call, meaning you are less likely to overpay and so unnecessarily increase your costs.

Read more about the internal reviewing of market makers here. https://github.com/chris-belcher/joinmarket/issues/57 (Which is not yet implemented)

Long story short, if you want to earn the highest possible profit, you must run a yield generator with a full node.

Your bot will be immediately notified of new confirmations with a full bitcoin client node, allowing your bitcoins to work as hard as possible for you.

Requirements / How-to

You will need:

  • Any flavor of up-to-date bitcoin client full node software. Bitcoin Core version 0.10 or above. The import watch-only address feature is required.
  • Fully downloaded and verified blockchain
  • The json-rpc interface open (with server=1), with rpcuser/rpcpassword set in bitcoin.conf
  • cURL installed. Found on most platforms (linux, windows, etc) and easy to install if not there.

Notify Options - Needed so Bitcoin client can notify JoinMarket of blockchain events

If you're only running the sendpayment.py you can skip this step.

Add the following notify options on the command line when starting bitcoin-qt or bitcoind:

-walletnotify="curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s"
-alertnotify="curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s"

If you wish to configure these options in bitcoin.conf, make sure to leave out the quotes and leading dash:

walletnotify=curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s
alertnotify=curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s

Example bitcoin.conf (change YourUsername and YourPassword to a secure username and passphrase)

server=1
rpcuser=YourUsername
rpcpassword=YourRandomlyGeneratedPassword

# Joinmarket
walletnotify=curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s
alertnotify=curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s

Configuring joinmarket.cfg

In the joinmarket.cfg file set the blockchain_source parameter to bitcoin-rpc. Also set the configuration options required. For example

rpc_host = localhost
rpc_port = 8332
rpc_user = YourUsername
rpc_password = YourRandomlyGeneratedPassword

Note that the default port for mainnet is 8332 and for testnet is 18332.

Obsolete option json-rpc

The blockchain_source parameter can also be json-rpc which created a subprocess of bitcoin-cli for every RPC call and was therefore inefficent. The code remains for backwards compatibility. To use it set bitcoin_cli_cmd as the required command line options. For example

blockchain_source = json-rpc
bitcoin_cli_cmd = bitcoin-cli -datadir=/path/to/your/bitcoin/directory

Running / Checking it works

With Bitcoin client software running, try using the wallet-tool.py from JoinMarket.

$ python wallet-tool.py wallet.json

First time using a new wallet requires several addresses to be imported. JoinMarket will then exit with the following message:

[2015/03/31 21:58:24] importing 80 addresses into account joinmarket-wallet-2734ec
restart Bitcoin Core with -rescan if you're recovering an existing wallet from backup seed
 otherwise just restart this joinmarket script

If you're using an entirely new wallet, you can just run the wallet-tool.py command line again.

If you're recovering a wallet from seed on a new Bitcoin Core instance then it must be restarted with -rescan option.

$ bitcoind -rescan

Run wallet-tool.py again to check all is well. It may take two or three rescans if your wallet has many addresses.

Once the standard wallet-tool output is displayed the Bitcoin Core interface is correctly set up.

Tips and Tricks to Running A Full Bitcoin Node

  • Bandwidth consumption can be reduced using this guide: https://bitcoin.org/en/full-node#reduce-traffic

  • If using Bitcoin Core v0.12 or above, blockchain pruning can be enabled using prune. Long story short you enable it by adding prune=550 to bitcoin.conf. Read the release notes here to better understand the idea. Also this github issue about using pruning with JoinMarket.

  • You can use another bitcoin directory using -datadir. This can be useful if for example you want to store the blockchain on an external hard drive. -datadir=/optional/path/to/your/bitcoin/directory