Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contrib/init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Sample configuration files for:

SystemD: bitcoind.service
Upstart: bitcoind.conf
OpenRC: bitcoind.openrc
bitcoind.openrcconf

have been made available to assist packagers in creating node packages here.

See doc/init.md for more information.
65 changes: 65 additions & 0 deletions contrib/init/bitcoind.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
description "Bitcoin Core Daemon"

start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]

env BITCOIND_BIN="/usr/bin/bitcoind"
env BITCOIND_USER="bitcoin"
env BITCOIND_GROUP="bitcoin"
env BITCOIND_PIDDIR="/var/run/bitcoind"
# upstart can't handle variables constructed with other variables
env BITCOIND_PIDFILE="/var/run/bitcoind/bitcoind.pid"
env BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf"
env BITCOIND_DATADIR="/var/lib/bitcoind"

expect fork

respawn
respawn limit 5 120
kill timeout 60

pre-start script
# this will catch non-existent config files
# bitcoind will check and exit with this very warning, but it can do so
# long after forking, leaving upstart to think everything started fine.
# since this is a commonly encountered case on install, just check and
# warn here.
if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then
echo "ERROR: You must set a secure rpcpassword to run bitcoind."
echo "The setting must appear in $BITCOIND_CONFIGFILE"
echo
echo "This password is security critical to securing wallets "
echo "and must not be the same as the rpcuser setting."
echo "You can generate a suitable random password using the following"
echo "command from the shell:"
echo
echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
echo
echo "It is also recommended that you also set alertnotify so you are "
echo "notified of problems:"
echo
echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
"admin@foo.com"
echo
exit 1
fi

mkdir -p "$BITCOIND_PIDDIR"
chmod 0755 "$BITCOIND_PIDDIR"
chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_PIDDIR"
chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_CONFIGFILE"
chmod 0660 "$BITCOIND_CONFIGFILE"
end script

exec start-stop-daemon \
--start \
--pidfile "$BITCOIND_PIDFILE" \
--chuid $BITCOIND_USER:$BITCOIND_GROUP \
--exec "$BITCOIND_BIN" \
-- \
-pid="$BITCOIND_PIDFILE" \
-conf="$BITCOIND_CONFIGFILE" \
-datadir="$BITCOIND_DATADIR" \
-disablewallet \
-daemon

86 changes: 86 additions & 0 deletions contrib/init/bitcoind.openrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/sbin/runscript

# backward compatibility for existing gentoo layout
#
if [ -d "/var/lib/bitcoin/.bitcoin" ]; then
BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin"
else
BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoind"
fi

BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/bitcoin/bitcoin.conf}
BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/bitcoind}
BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/bitcoind.pid}
BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}}
BITCOIND_USER=${BITCOIND_USER:-bitcoin}
BITCOIND_GROUP=${BITCOIND_GROUP:-bitcoin}
BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/bitcoind}

name="Bitcoin Core Daemon"
description="Bitcoin crypto-currency p2p network daemon"

command="/usr/bin/bitcoind"
command_args="-pid=\"${BITCOIND_PIDFILE}\" \
-conf=\"${BITCOIND_CONFIGFILE}\" \
-datadir=\"${BITCOIND_DATADIR}\" \
-daemon \
${BITCOIND_OPTS}"

required_files="${BITCOIND_CONFIGFILE}"
start_stop_daemon_args="-u ${BITCOIND_USER} \
-N ${BITCOIND_NICE:-0} -w 2000"
pidfile="${BITCOIND_PIDFILE}"
retry=60

depend() {
need localmount net
}

# verify
# 1) that the datadir exists and is writable (or create it)
# 2) that a directory for the pid exists and is writable
# 3) ownership and permissions on the config file
start_pre() {
checkpath \
-d \
--mode 0750 \
--owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
"${BITCOIND_DATADIR}"

checkpath \
-d \
--mode 0755 \
--owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
"${BITCOIND_PIDDIR}"

checkpath -f \
-o ${BITCOIND_USER}:${BITCOIND_GROUP} \
-m 0660 \
${BITCOIND_CONFIGFILE}

checkconfig || return 1
}

checkconfig()
{
if ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then
eerror ""
eerror "ERROR: You must set a secure rpcpassword to run bitcoind."
eerror "The setting must appear in ${BITCOIND_CONFIGFILE}"
eerror ""
eerror "This password is security critical to securing wallets "
eerror "and must not be the same as the rpcuser setting."
eerror "You can generate a suitable random password using the following"
eerror "command from the shell:"
eerror ""
eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
eerror ""
eerror "It is also recommended that you also set alertnotify so you are "
eerror "notified of problems:"
eerror ""
eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
"admin@foo.com"
eerror ""
return 1
fi
}
27 changes: 27 additions & 0 deletions contrib/init/bitcoind.openrcconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# /etc/conf.d/bitcoind: config file for /etc/init.d/bitcoind

# Config file location
#BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf"

# What directory to write pidfile to? (created and owned by $BITCOIND_USER)
#BITCOIND_PIDDIR="/var/run/bitcoind"

# What filename to give the pidfile
#BITCOIND_PIDFILE="${BITCOIND_PIDDIR}/bitcoind.pid"

# Where to write bitcoind data (be mindful that the blockchain is large)
#BITCOIND_DATADIR="/var/lib/bitcoind"

# User and group to own bitcoind process
#BITCOIND_USER="bitcoin"
#BITCOIND_GROUP="bitcoin"

# Path to bitcoind executable
#BITCOIND_BIN="/usr/bin/bitcoind"

# Nice value to run bitcoind under
#BITCOIND_NICE=0

# Additional options (avoid -conf and -datadir, use flags above)
BITCOIND_OPTS="-disablewallet"

22 changes: 22 additions & 0 deletions contrib/init/bitcoind.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[Unit]
Description=Bitcoin's distributed currency daemon
After=network.target

[Service]
User=bitcoin
Group=bitcoin

Type=forking
PIDFile=/var/lib/bitcoind/bitcoind.pid
ExecStart=/usr/bin/bitcoind -daemon -pid=/var/lib/bitcoind/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind -disablewallet

Restart=always
PrivateTmp=true
TimeoutStopSec=60s
TimeoutStartSec=2s
StartLimitInterval=120s
StartLimitBurst=5

[Install]
WantedBy=multi-user.target
43 changes: 43 additions & 0 deletions contrib/msc-ubuntu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Master Core Upstart support for Ubuntu (tested on 14.04 LTS)

To install:

1. Build Master Core

./autogen.sh
./configure
make

1. Run the install script

sudo ./contrib/msc-ubuntu/install-mastercore-upstart.sh

Running `bitcoin-cli` for a quick test:

1. Add your user to the `bitcoin` group so you can read `/etc/bitcoin/bitcoin.conf`

sudo usermod -a -G bitcoin <username>

1. Use `getinfo` to make sure RPC is working

/usr/sbin/bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getinfo


This is based upon upstream work that is documented in these links:

* [Issue #4124](https://github.com/bitcoin/bitcoin/issues/4124)
* [Issue #4611](https://github.com/bitcoin/bitcoin/pull/4611)

This branch/PR used `git cherry-pick` to pull some of that code so it can be added to the `michael-0921` branch of Master Core.

Doc on the files from the "Cherry Pick" can be found:

* [init/README.md](../init/README.md)
* [doc/init.md](../../doc/init.md)

It has been tested on Ubuntu 14.04 LTS.

There is a Vagrant script to install it here:
[https://github.com/msgilligan/install-msc/tree/vagrant](https://github.com/msgilligan/install-msc/tree/vagrant)


87 changes: 87 additions & 0 deletions contrib/msc-ubuntu/bitcoin.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# bitcoin.conf configuration file. Lines beginning with # are comments.


# Network-related settings:

# Run on the test network instead of the real bitcoin network.
#testnet=1

# Connect via a socks4 proxy
#proxy=127.0.0.1:9050

# Use as many addnode= settings as you like to connect to specific peers
#addnode=69.164.218.197
#addnode=10.0.0.2:8333

# ... or use as many connect= settings as you like to connect ONLY
# to specific peers:
#connect=69.164.218.197
#connect=10.0.0.1:8333

# Maximum number of inbound+outbound connections.
#maxconnections=


# JSON-RPC options (for controlling a running Bitcoin/bitcoind process)

# server=1 tells Bitcoin to accept JSON-RPC commands.
#server=1

# You must set rpcuser and rpcpassword to secure the JSON-RPC api
#rpcuser=Ulysseys
#rpcpassword=YourSuperGreatPasswordNumber_385593

# By default, only RPC connections from localhost are allowed. Specify
# as many rpcallowip= settings as you like to allow connections from
# other hosts (and you may use * as a wildcard character):
#rpcallowip=10.1.1.34
#rpcallowip=192.168.1.*

# Listen for RPC connections on this TCP port:
rpcport=8332

# You can use Bitcoin or bitcoind to send commands to Bitcoin/bitcoind
# running on another host using this option:
rpcconnect=127.0.0.1

# Use Secure Sockets Layer (also known as TLS or HTTPS) to communicate
# with Bitcoin -server or bitcoind
#rpcssl=1

# OpenSSL settings used when rpcssl=1
rpcsslciphers=TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH
rpcsslcertificatechainfile=server.cert
rpcsslprivatekeyfile=server.pem


# Miscellaneous options

# Set gen=1 to attempt to generate bitcoins
gen=0

# Use SSE instructions to try to generate bitcoins faster.
#4way=1

# Pre-generate this many public/private key pairs, so wallet backups will be valid for
# both prior transactions and several dozen future transactions.
keypool=100

# Pay an optional transaction fee every time you send bitcoins. Transactions with fees
# are more likely than free transactions to be included in generated blocks, so may
# be validated sooner.
paytxfee=0.00
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems risky. I already raised the hardcoded default, but overwriting this here annihilates the effect.

Fees are chosen this way: max(paytxfee, mintxfee)

I suggest to either #comment this or use a sane minimum such as 0.0001 or 0.00001 -- just for the case the mintxfee is for some reason overwritten somehow.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @dexX7 I will fix this in my branch.

I created this pull request to get exactly this kind of feedback, but it has been closed without comment.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in contact with @m21, but I think this was no manual close, but related to the 0.0.7 release and the branch restructure - mastercoin-MSC:michael-0921 was deleted and I assume this disconnects associated PRs?

The new dev branch is https://github.com/mastercoin-MSC/mastercore/tree/0.0.8 and you might keep an eye on #130 where I suggested to use a more telling branch/release name - just for the case 0.0.8 will be deleted as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope that is the case. I can resubmit on a new branch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dexX7, why did you raise nMinRelayTxFee from 1000 to 1001? (I'm working on submitting a new PR and want to incorporate your suggestions and understand the issues better.) It seems to me that the best solution is to comment this line out, though.

This bitcoin.conf file should be the default for Master Core and should be secure and have the best general purpose settings for bitcoind running in background mode. I'm happy to take any suggestions -- or complete configuration files -- for what its contents should be.

(Note: I created this bitcoin.conf file by copying contrib/debian/examples/bitcoin.conf and adding txindex=1 as required by Master Core.)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is already clear, but just to be sure some background information which might be handy to know: there is a difference between min-X-fee and X-fee. The min-X-fee defines the absolute minimum whereby the X-fee is never less than the min-X-fee. The hardcoded default is overwritten by a config value. To be more specific: there is the mintxfee which is either defined by the client's hardcoded default or config/startup arguments and there is the paytxfee which can be set via config/startup as well, but also on the fly via RPC command settxfee. The actual fee is max(mintxfee, paytxfee). The relayTxFee has a hardcoded default and can be set via config/startup arguments, too. - Unfortunally there is no RPC call to change this value on the fly.

Related to nMinRelayTxFee: at the beginning a magic number was used for all output amounts and this number was changed from time to time to identify and differentiate between clients and versions. This is currently done with Omni as well and you can identify transactions that are created by Omni on it's output amounts of 0.00005757. Switching to an approach which yields output amounts derived from script length and based on minRelayTxFee sort of killed the ability to "tag" clients, but I later realized it's still possible, even without static magic number. I used 1001 basically to make my point and suggested to change this number, if a new "tag" is required.

Given how the nMinRelayTxFee is [ab]used for client identification purposes, I think commenting the line in bitcoin.conf is the way to go at the moment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @dexX7! The comment to this line has been added to my branch and is in the updated and re-submitted PR.


# Allow direct connections for the 'pay via IP address' feature.
#allowreceivebyip=1


# User interface options

# Start Bitcoin minimized
#min=1

# Minimize to the system tray
#minimizetotray=1

# txindex is required for Master Core
txindex=1
30 changes: 30 additions & 0 deletions contrib/msc-ubuntu/install-mastercore-upstart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Copy the executable
cp src/bitcoind /usr/bin/bitcoind
cp src/bitcoin-cli /usr/bin/bitcoin-cli

# Set up directories, users, and permissions as standardized by Bitcoin Core
mkdir -p /etc/bitcoin
mkdir -p /var/lib/bitcoind
mkdir -p /var/run/bitcoind

groupadd --force --system bitcoin
useradd -M --system --shell /usr/sbin/nologin --home /var/lib/bitcoind --gid bitcoin bitcoin

chown bitcoin:bitcoin /var/lib/bitcoind
chmod 750 /var/lib/bitcoind

chown bitcoin:bitcoin /var/run/bitcoind
chmod 755 /var/run/bitcoind

# Copy Bitcoin configuration file
cp contrib/msc-ubuntu/bitcoin.conf /etc/bitcoin
chown bitcoin:bitcoin /etc/bitcoin/bitcoin.conf
chmod 660 /etc/bitcoin/bitcoin.conf

# Copy Upstart configuration file/script
cp contrib/init/bitcoind.conf /etc/init

echo "Set rpcuser and rpcpassword in /etc/bitcoin/bitcoin.conf, then type: 'service bitcoind start' (as root/sudo)"

1 change: 1 addition & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The Bitcoin repo's [root README](https://github.com/bitcoin/bitcoin/blob/master/
- [Assets Attribution](assets-attribution.md)
- [Files](files.md)
- [Tor Support](tor.md)
- [Init Scripts (systemd/upstart/openrc)](init.md)

License
---------------------
Expand Down
Loading