How to run a Bitcoin node in Debian

We are going to run a Bitcoin full node in a Debian system (Sid)

Download Bitcoin precompiled binaries

I download the Bitcoin Core binary suitable for my system architecture (e.g: linux amd 64 bits)

I download 64 bit version for linux:
$ wget

Extract the tar ball:
$ tar xvzf bitcoin-0.14.2-x86_64-linux-gnu.tar.gz

Install the binaries in /usr/local/bin directory
$ sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.14.2/bin/*

Run Bitcoin daemon

By now we are going to run only Bitcoin daemon with no graphical interface:

I create a new user to run the daemon
$ sudo adduser bitcoin_user

Then we log in with the new user
$ sudo login bitcoin_user

And launch the daemon:
bitcoin_user@my_box:~$ bitcoind -daemon
Bitcoin server starting

Show help about bitcoin server options:
$ bitcoind -help

We can list configuration files:
$ cd .bitcoin
$ ls
banlist.dat blocks chainstate database db.log debug.log peers.dat wallet.dat

Data directory
bitcoin.conf configuration file

NOTE: Right now, if we do not open the necessary ports in the router we are only using our Bitcoin node as a wallet.

Communicate with the server using Bitcoin client for command line

Get general help:
$ bitcoin-cli help

Get help for a specific command:
$ bitcoin-cli help getinfo

$ bitcoin-cli getinfo

$ bitcoin-cli getblockchaininfo

$ bitcoin-cli getnetworkinfo

$ bitcoin-cli getnettotals

$ bitcoin-cli getwalletinfo

$ bitcoin-cli getconnectioncount

To stop the Bitcoin server:
$ bitcoin-cli stop

List my accounts:
$ bitcoin-cli listaccounts
"": 0.00000000

NOTE: "" is the default account.

Get addresses for your default account:
$ bitcoin-cli getaddressesbyaccount ""

Validate an address:
$ bitcoin-cli validateaddress "1pXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
It shows public key, etc for that address.

Dump private key:
It shows private key associated to that address. Be careful!!!

Show info about a block based on its hash:
$ bitcoin-cli getblock "0000000000000000038726af63010f9b3e8fa34ac75050d620d1253176ed88fc"

How to encrypt your wallet

We want to encrypt our wallet so attackers cannot dump the private keys, etc.

Help about encrypting the wallet:
$ bitcoin-cli help encryptwallet

First we encrypt the wallet (this works for an unencrypted wallet, for an already encrypted wallet we need to use walletpassphrasechange call):
$ bitcoin-cli encryptwallet "my_pass_phrase"

After wallet is encrypted, server will stop.

We run the server again:
$ bitcoind -daemon

If we try to dump private key associated to an address of ours it fails because we have not set the passphrase yet:
$ bitcoin-cli dumpprivkey "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
error code: -13
error message:
Error: Please enter the wallet passphrase with walletpassphrase first.

We enable the passphrase for 300 seconds:
$ bitcoin-cli walletpassphrase "my_pass_phrase" 300

Now we can dump the private key if we want to:
$ bitcoin-cli dumpprivkey "XXXXXXXXXXXXXXXXXXXXXXXX"

We can manually lock the wallet if we do not want to wait until timeout:
$ bitcoin-cli walletlock

How to perform a transaction

We will use sendtoaddress command:

$ bitcoin-cli help sendtoaddress
sendtoaddress "address" amount ( "comment" "comment_to" subtractfeefromamount )

Send an amount to a given address.

Requires wallet passphrase to be set with walletpassphrase call.
1. "address" (string, required) The bitcoin address to send to.
2. "amount" (numeric or string, required) The amount in BTC to send. eg 0.1
3. "comment" (string, optional) A comment used to store what the transaction is for.
This is not part of the transaction, just kept in your wallet.
4. "comment_to" (string, optional) A comment to store the name of the person or organization
to which you're sending the transaction. This is not part of the
transaction, just kept in your wallet.
5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.
The recipient will receive less bitcoins than you enter in the amount field.

"txid" (string) The transaction id.

> bitcoin-cli sendtoaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1
> bitcoin-cli sendtoaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1 "donation" "seans outpost"
> bitcoin-cli sendtoaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1 "" "" true
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd", 0.1, "donation", "seans outpost"] }' -H 'content-type: text/plain;'

First we introduce wallet pass phrase if our wallet is encrypted:
$ bitcoin-cli walletpassphrase "my_wallet_pass_phrase" 500

We need to set a transaction fee amount in Bitcoins per kilo byte:
$ bitcoin-cli help settxfee
settxfee amount

Set the transaction fee per kB. Overwrites the paytxfee parameter.

1. amount (numeric or string, required) The transaction fee in BTC/kB

true|false (boolean) Returns true if successful

> bitcoin-cli settxfee 0.00001
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "settxfee", "params": [0.00001] }' -H 'content-type: text/plain;'

URLs to find a suitable transaction fee:

Convert satoshis per byte into BTC per kB

When writing this article 200 satoshis per byte was a good value.

100000000 satoshis equal 1 Bitcoin.

200 satoshis per byte == 200000 satoshis per kB == 0.002 BTC per kB

As a general rule:
X satoshis per byte == X*1000 satoshis per kB == X/100000 BTC per kB

$ bitcoin-cli settxfee 0.002

$ bitcoin-cli getbalance

True in the end means fee will substract from transfered value so less than 0.05 BTC will arrive.

$ bitcoin-cli sendtoaddress "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 0.05 "test" "to_destiny" true

It returns the transfer Id. You can use that Id to show info about the transaction

After transaction completed we can check balance:
$ bitcoin-cli getbalance

To show amount of bitcoins each of your addresses currently contains:
$ bitcoin-cli listunspent

You can find info about your address, transfer, etc in this URL:


How to run a bitcoin full node:

Secure your wallet:

Download bitcoin core:

Original Bitcoin client/API calls list: