A REST api for bitcoin rpc.
- Python 2.7
- virtualenv
./setup_venv.sh
cp oss_server/oss_server/settings/setting.py.default oss_server/oss_server/settings/setting.py
<SECRET_KEY>
This is used to provide cryptographic signing, and should be set to a unique, unpredictable value.
<ENV>
Fill in develop
will enable oss_server/oss_server/settings/develop.py
for debug information while running the project.
test
: oss_server/oss_server/settings/test.py
It is designed for a standalone unit test process using a in-memory database.
production
: oss_server/oss_server/settings/production.py
It disable debug information for production environment.
<ALLOW_DOMAIN>
Replacing it with *
means it allowed requests from everywhere.
Use *
for develop and subdomain format for production environment.
Set up connection of bitcoin rpc
BITCOIN_RPC = {
'user': '<BITCOIN_RPC_USER>',
'password': '<BITCOIN_RPC_PASSWORD>',
'host': '<BITCOIN_RPC_HOST>',
'port': '<BITCOIN_RPC_PORT>',
}
OSS uses mariadb to store blockchain data. Make sure to create a database named the same as <EXPLORER_DB_NAME>
, then migrate with:
./manage.py migrate
DATABASES = {
'default': {
'NAME': '<EXPLORER_DB_NAME>',
'ENGINE': 'django.db.backends.mysql',
'HOST': '<EXPLORER_DB_HOST>',
'PORT': '<EXPLORER_DB_PORT>',
'USER': '<EXPLORER_DB_USER>',
'PASSWORD': '<EXPLORER_DB_PSSWORD>',
'CONN_MAX_AGE': 20
}
}
<NET>
Set MAINNET
to update blocks of bitcoin mainnet and TESTNET
for testnet.
Notice: Set MAINNET
if you want to run unit test.
<BTC_DIR>
The data forlder, which are usually located under ~/.bitcoin
It is the key point for entire OSS project. The Django command called blockupdate
will read all the blockchain data under this forlder every second by default and save these data to specified database.
Run ./manage.py blockupdate
to sync blockchain indefinitely.
Run ./manage.py test --settings=oss_server.settings.test
for a standalone unit test.
Run ./manage.py test
will create a test database specified in setting.py and destroy it after compeleting the test.
Notice: You need to set <NET>
of setting.py to MAINNET
at first.
./oss_server/manage.py runserver <address>:<port>
./manage.py blockupdate
./manage.py txnotify
./manage.py addressnotify