├── tutorials ├── __init__.py ├── utils │ └── __init__.py ├── constants │ ├── __init__.py │ ├── application_constants.py │ ├── application_constants.js │ └── api_urls.js ├── 02_assets_unspents │ ├── __init__.py │ └── assets_unspents.html ├── 01_simple_transactions │ ├── __init__.py │ └── simple_transactions.html ├── 03_divisible_transactions │ ├── __init__.py │ └── divisible_transactions.html ├── 04_cryptoconditions_transactions │ └── __init__.py ├── .eslintignore ├── .eslintrc.json ├── .babelrc └── package.json ├── examples ├── client │ ├── __init__.py │ ├── .eslintignore │ ├── .eslintrc.json │ ├── js │ │ ├── react │ │ │ ├── alt.js │ │ │ ├── actions │ │ │ │ ├── vote_actions.js │ │ │ │ ├── block_actions.js │ │ │ │ ├── account_actions.js │ │ │ │ └── transaction_actions.js │ │ │ ├── sources │ │ │ │ ├── vote_source.js │ │ │ │ ├── block_source.js │ │ │ │ └── transaction_source.js │ │ │ ├── components │ │ │ │ ├── account_detail.js │ │ │ │ ├── spinner.js │ │ │ │ └── bigchaindb_connection.js │ │ │ └── stores │ │ │ │ ├── vote_store.js │ │ │ │ └── block_store.js │ │ ├── utils │ │ │ ├── cryptoconditions │ │ │ │ ├── type_ids.js │ │ │ │ ├── filter_by_type.js │ │ │ │ └── parse_escrow_data.js │ │ │ ├── bigchaindb │ │ │ │ └── transactions.js │ │ │ └── request.js │ │ ├── constants │ │ │ ├── application_constants.js │ │ │ └── api_urls.js │ │ └── plugins │ │ │ └── ledger_utils.js │ ├── scss │ │ ├── _icons.scss │ │ ├── _layout.scss │ │ ├── _search.scss │ │ ├── _asset.scss │ │ ├── main.scss │ │ ├── _logo.scss │ │ ├── _mixins.scss │ │ ├── _account.scss │ │ ├── _sidebar.scss │ │ ├── _menu.scss │ │ ├── _modal.scss │ │ ├── _card.scss │ │ ├── _code.scss │ │ └── _transaction.scss │ ├── browserlist │ ├── audio_lock │ │ ├── scss │ │ │ ├── _dictaphone.scss │ │ │ ├── _audiobar.scss │ │ │ └── _assets.scss │ │ └── js │ │ │ ├── app.js │ │ │ └── components │ │ │ └── utils.js │ ├── interledger │ │ ├── js │ │ │ ├── app.js │ │ │ └── components │ │ │ │ ├── assets.js │ │ │ │ ├── account_detail.js │ │ │ │ └── interledger.js │ │ └── scss │ │ │ └── custom_style.scss │ ├── tx_explorer │ │ ├── js │ │ │ ├── app.js │ │ │ └── components │ │ │ │ └── transaction_panel.js │ │ └── scss │ │ │ └── custom_style.scss │ ├── share_trader │ │ ├── js │ │ │ ├── app.js │ │ │ └── components │ │ │ │ └── assets.js │ │ └── scss │ │ │ └── custom_style.scss │ ├── .babelrc │ ├── demo │ │ └── styles.css │ ├── server.demo.js │ └── app_index_template.html ├── server │ ├── __init__.py │ ├── views │ │ ├── __init__.py │ │ ├── info.py │ │ └── accounts.py │ ├── models │ │ └── __init__.py │ ├── routes.py │ └── server_flask.py ├── commands │ └── __init__.py ├── .dockerignore ├── docs │ ├── share_trade.md │ ├── on_the_record.md │ ├── img │ │ ├── on_the_record_v0.0.1.png │ │ └── share_trader_v0.0.1.png │ └── source │ │ ├── _static │ │ ├── ontherecord.png │ │ └── sharetrader.png │ │ ├── structure.rst │ │ ├── ack.rst │ │ ├── index.rst │ │ ├── ontherecord.rst │ │ ├── sharetrader.rst │ │ ├── troubleshooting.rst │ │ ├── conf.py │ │ ├── docs.rst │ │ ├── interledger.rst │ │ └── run.rst ├── iot_bdb_ethereum_bseh17 │ ├── app │ │ ├── iot │ │ │ ├── __init__.py │ │ │ ├── utils │ │ │ │ └── __init__.py │ │ │ ├── mock_data_sharge.py │ │ │ └── connection.py │ │ ├── .gitignore │ │ ├── migrations │ │ │ ├── 1_initial_migration.js │ │ │ └── 2_deploy_contracts.js │ │ ├── contracts │ │ │ ├── TokenMock.sol │ │ │ ├── Migrations.sol │ │ │ └── Token.sol │ │ ├── truffle.js │ │ ├── README.md │ │ └── test │ │ │ └── MobileEnergy.js │ └── images │ │ ├── redsys.png │ │ ├── bstoken.png │ │ ├── monitor.png │ │ └── network.png ├── .env_template ├── compose │ ├── server │ │ └── Dockerfile │ └── frontend │ │ └── Dockerfile ├── docs.yml ├── Makefile ├── .gitignore ├── apps_config.py └── setup.py ├── drivers ├── python │ ├── docs │ │ ├── authors.rst │ │ ├── readme.rst │ │ ├── changelog.rst │ │ ├── contributing.rst │ │ ├── _static │ │ │ ├── cc_escrow_execute_abort.png │ │ │ ├── tx_escrow_execute_abort.png │ │ │ ├── tx_multi_condition_multi_fulfillment_v1.png │ │ │ └── tx_single_condition_single_fulfillment_v1.png │ │ ├── requirements.txt │ │ ├── upgrading.rst │ │ ├── index.rst │ │ ├── aboutthedocs.rst │ │ ├── conf.py │ │ └── libref.rst │ ├── tests │ │ ├── __init__.py │ │ ├── test_crypto.py │ │ ├── test_pool.py │ │ ├── test_transport.py │ │ ├── test_exceptions.py │ │ └── test_connection.py │ ├── .coveragerc │ ├── pytest.ini │ ├── .ci │ │ ├── travis-after-success.sh │ │ ├── travis-install.sh │ │ ├── travis-before-install.sh │ │ └── travis-before-script.sh │ ├── requirements_dev.txt │ ├── bigchaindb_driver │ │ ├── __init__.py │ │ ├── crypto.py │ │ ├── utils.py │ │ ├── exceptions.py │ │ ├── transport.py │ │ ├── connection.py │ │ └── pool.py │ ├── AUTHORS.rst │ ├── codecov.yml │ ├── compose │ │ ├── server │ │ │ └── Dockerfile │ │ └── driver │ │ │ └── Dockerfile │ ├── MANIFEST.in │ ├── docs.yml │ ├── .editorconfig │ ├── .travis.yml │ ├── .github │ │ └── ISSUE_TEMPLATE.md │ ├── HACKING.rst │ ├── setup.cfg │ ├── tox.ini │ ├── LICENSES.md │ ├── dev.yml │ ├── .gitignore │ ├── docker-compose.yml │ ├── CHANGELOG.rst │ ├── setup.py │ ├── README.rst │ └── Makefile └── javascript │ ├── .eslintignore │ ├── .eslintrc.json │ ├── src │ ├── index.js │ ├── sha256Hash.js │ ├── transaction │ │ ├── makeInputTemplate.js │ │ ├── hashTransaction.js │ │ ├── index.js │ │ ├── makeOutput.js │ │ ├── serializeTransactionIntoCanonicalString.js │ │ ├── makeTransaction.js │ │ ├── makeSha256Condition.js │ │ ├── makeEd25519Condition.js │ │ ├── makeThresholdCondition.js │ │ ├── signTransaction.js │ │ ├── makeCreateTransaction.js │ │ ├── utils │ │ │ ├── ccJsonLoad.js │ │ │ └── ccJsonify.js │ │ └── makeTransferTransaction.js │ ├── connection │ │ ├── getStatus.js │ │ ├── listVotes.js │ │ ├── getTransaction.js │ │ ├── postTransaction.js │ │ ├── getBlock.js │ │ ├── listBlocks.js │ │ ├── getApiUrls.js │ │ ├── index.js │ │ ├── listTransactions.js │ │ ├── listOutputs.js │ │ └── pollStatusAndFetchTransaction.js │ ├── Ed25519Keypair.js │ ├── request.js │ ├── stringify_as_query_param.js │ └── sanitize.js │ ├── .gitignore │ ├── constants │ ├── application_constants.js │ └── api_urls.js │ ├── dist │ ├── README.md │ └── node │ │ └── index.js │ ├── .babelrc │ ├── utils │ ├── request.js │ └── bigchaindb_utils.js │ ├── webpack.config.js │ └── package.json ├── .gitmodules ├── Dockerfile ├── compose ├── bigchaindb-driver-kyber │ └── Dockerfile ├── examples-server │ └── Dockerfile └── examples-frontend │ └── Dockerfile ├── Makefile ├── nginx.conf ├── .gitignore └── LICENSE.md /tutorials/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/client/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/server/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tutorials/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/server/views/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tutorials/constants/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/server/models/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /examples/docs/share_trade.md: -------------------------------------------------------------------------------- 1 | # Share Trade -------------------------------------------------------------------------------- /tutorials/02_assets_unspents/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/docs/on_the_record.md: -------------------------------------------------------------------------------- 1 | # On The Record -------------------------------------------------------------------------------- /tutorials/01_simple_transactions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tutorials/03_divisible_transactions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/iot/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/iot/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tutorials/04_cryptoconditions_transactions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /drivers/python/docs/authors.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../AUTHORS.rst 2 | -------------------------------------------------------------------------------- /drivers/python/docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /drivers/python/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /drivers/python/docs/changelog.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CHANGELOG.rst 2 | -------------------------------------------------------------------------------- /tutorials/.eslintignore: -------------------------------------------------------------------------------- 1 | build/* 2 | dist/* 3 | node_modules/* 4 | -------------------------------------------------------------------------------- /drivers/python/docs/contributing.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../CONTRIBUTING.rst 2 | -------------------------------------------------------------------------------- /examples/client/.eslintignore: -------------------------------------------------------------------------------- 1 | build/* 2 | dist/* 3 | node_modules/* 4 | -------------------------------------------------------------------------------- /tutorials/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "ascribe-react" 3 | } 4 | -------------------------------------------------------------------------------- /drivers/javascript/.eslintignore: -------------------------------------------------------------------------------- 1 | build/* 2 | dist/* 3 | node_modules/* 4 | -------------------------------------------------------------------------------- /drivers/javascript/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "ascribe" 3 | } 4 | -------------------------------------------------------------------------------- /examples/client/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "ascribe-react" 3 | } 4 | -------------------------------------------------------------------------------- /drivers/python/.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | source = . 3 | omit = *test*, docs/*, setup.py 4 | -------------------------------------------------------------------------------- /examples/client/js/react/alt.js: -------------------------------------------------------------------------------- 1 | import Alt from 'alt'; 2 | 3 | 4 | const alt = new Alt(); 5 | 6 | export default alt; 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "bigchaindb-server"] 2 | path = bigchaindb-server 3 | url = https://github.com/bigchaindb/bigchaindb/ 4 | -------------------------------------------------------------------------------- /drivers/python/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | env = 3 | D:BIGCHAINDB_KEYPAIR_PUBLIC=GW1nrdZm4mbVC8ePeiGWz6DqHexqewqy5teURVHi3RG4 4 | -------------------------------------------------------------------------------- /examples/docs/img/on_the_record_v0.0.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/docs/img/on_the_record_v0.0.1.png -------------------------------------------------------------------------------- /examples/docs/img/share_trader_v0.0.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/docs/img/share_trader_v0.0.1.png -------------------------------------------------------------------------------- /tutorials/constants/application_constants.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BDB_SERVER_URL = os.getenv('BDB_SERVER_URL', 'http://localhost:9984') 4 | -------------------------------------------------------------------------------- /examples/docs/source/_static/ontherecord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/docs/source/_static/ontherecord.png -------------------------------------------------------------------------------- /examples/docs/source/_static/sharetrader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/docs/source/_static/sharetrader.png -------------------------------------------------------------------------------- /drivers/python/.ci/travis-after-success.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x 4 | 5 | if [ "${TOXENV}" == "py35" ]; then 6 | codecov 7 | fi 8 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/images/redsys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/iot_bdb_ethereum_bseh17/images/redsys.png -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/images/bstoken.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/iot_bdb_ethereum_bseh17/images/bstoken.png -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/images/monitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/iot_bdb_ethereum_bseh17/images/monitor.png -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/images/network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/examples/iot_bdb_ethereum_bseh17/images/network.png -------------------------------------------------------------------------------- /drivers/python/docs/_static/cc_escrow_execute_abort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/drivers/python/docs/_static/cc_escrow_execute_abort.png -------------------------------------------------------------------------------- /drivers/python/docs/_static/tx_escrow_execute_abort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/drivers/python/docs/_static/tx_escrow_execute_abort.png -------------------------------------------------------------------------------- /drivers/python/requirements_dev.txt: -------------------------------------------------------------------------------- 1 | pip==8.1.2 2 | bumpversion==0.5.3 3 | wheel==0.29.0 4 | git+https://github.com/bigchaindb/bigchaindb.git 5 | 6 | -e .[dev] 7 | -------------------------------------------------------------------------------- /drivers/javascript/src/index.js: -------------------------------------------------------------------------------- 1 | 2 | export Ed25519Keypair from './Ed25519Keypair'; 3 | 4 | export * as Transaction from './transaction'; 5 | export * as Connection from './connection'; -------------------------------------------------------------------------------- /drivers/python/bigchaindb_driver/__init__.py: -------------------------------------------------------------------------------- 1 | from .driver import BigchainDB # noqa 2 | 3 | 4 | __author__ = 'BigchainDB' 5 | __email__ = 'dev@bigchaindb.com' 6 | __version__ = '0.2.1' 7 | -------------------------------------------------------------------------------- /drivers/python/docs/_static/tx_multi_condition_multi_fulfillment_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/drivers/python/docs/_static/tx_multi_condition_multi_fulfillment_v1.png -------------------------------------------------------------------------------- /drivers/python/docs/_static/tx_single_condition_single_fulfillment_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bigchaindb/kyber/HEAD/drivers/python/docs/_static/tx_single_condition_single_fulfillment_v1.png -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | #FROM openresty/openresty:xenial 2 | FROM nginx:alpine 3 | MAINTAINER krish@bigchaindb.com 4 | WORKDIR / 5 | 6 | COPY nginx.conf /etc/nginx/nginx.conf 7 | 8 | EXPOSE 80 9 | ENTRYPOINT ["nginx"] 10 | -------------------------------------------------------------------------------- /drivers/javascript/src/sha256Hash.js: -------------------------------------------------------------------------------- 1 | import sha3 from 'js-sha3'; 2 | 3 | export default function sha256Hash(data) { 4 | return sha3.sha3_256 5 | .create() 6 | .update(data) 7 | .hex(); 8 | } 9 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /drivers/javascript/.gitignore: -------------------------------------------------------------------------------- 1 | *.seed 2 | *.log 3 | *.dat 4 | *.out 5 | *.pid 6 | *.gz 7 | .idea 8 | *.sublime-project 9 | *.sublime-workspace 10 | *.sublime-workspace 11 | 12 | .env 13 | 14 | build/* 15 | 16 | node_modules/* 17 | -------------------------------------------------------------------------------- /examples/.env_template: -------------------------------------------------------------------------------- 1 | # App settings 2 | CLIENT_HOST=localhost 3 | CLIENT_PORT=3000 4 | FLASK_HOST=localhost 5 | FLASK_PORT=8000 6 | TORNADO_HOST=localhost 7 | TORNADO_PORT=8888 8 | 9 | # Docker settings 10 | DOCKER_MACHINE_IP= 11 | -------------------------------------------------------------------------------- /drivers/python/AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Credits 3 | ======= 4 | 5 | Development Lead 6 | ---------------- 7 | 8 | * BigchainDB 9 | 10 | Contributors 11 | ------------ 12 | 13 | None yet. Why not be the first? 14 | -------------------------------------------------------------------------------- /examples/docs/source/structure.rst: -------------------------------------------------------------------------------- 1 | Structure 2 | ========= 3 | 4 | The apps are structured as follows: 5 | 6 | * Client: ReactJS 7 | * Server: Python Flask REST API server 8 | * DB: BigchainDB 9 | 10 | All messages are JSON based. 11 | -------------------------------------------------------------------------------- /drivers/python/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # we need this for readthedocs 2 | 3 | sphinx 4 | sphinx-autobuild 5 | sphinxcontrib-autorun 6 | sphinxcontrib-httpdomain 7 | sphinxcontrib-napoleon 8 | sphinx_rtd_theme 9 | ipython 10 | matplotlib 11 | -------------------------------------------------------------------------------- /examples/client/scss/_icons.scss: -------------------------------------------------------------------------------- 1 | .icon { 2 | fill: none; 3 | stroke: $brand-main-blue; 4 | stroke-width: 1; 5 | stroke-linecap: round; 6 | stroke-linejoin: round; 7 | width: $font-size-base; 8 | height: $font-size-base; 9 | } -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeInputTemplate.js: -------------------------------------------------------------------------------- 1 | export default function makeInputTemplate(publicKeys = [], fulfills = null, fulfillment = null) { 2 | return { 3 | fulfillment, 4 | fulfills, 5 | 'owners_before': publicKeys, 6 | }; 7 | } -------------------------------------------------------------------------------- /drivers/python/codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | branch: master 3 | 4 | coverage: 5 | range: "95...100" 6 | 7 | ignore: 8 | - "docs/*" 9 | - "tests/*" 10 | 11 | comment: 12 | layout: "header, diff, changes, sunburst, uncovered" 13 | behavior: default 14 | -------------------------------------------------------------------------------- /examples/client/browserlist: -------------------------------------------------------------------------------- 1 | # Supported browsers by this project. 2 | # For format, see https://github.com/ai/browserslist 3 | Chrome >= 30 4 | Safari >= 6.1 5 | Firefox >= 35 6 | Opera >= 32 7 | Explorer >= 10 8 | iOS >= 8 9 | Android >= 2.3 10 | Last 2 versions 11 | -------------------------------------------------------------------------------- /examples/compose/server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | RUN mkdir -p /usr/src/app 4 | WORKDIR /usr/src/app 5 | 6 | COPY setup.py /usr/src/app/ 7 | COPY server /usr/src/app/server 8 | 9 | RUN pip install --upgrade pip 10 | RUN pip install --no-cache-dir -e .[dev] 11 | -------------------------------------------------------------------------------- /tutorials/02_assets_unspents/assets_unspents.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /examples/server/views/info.py: -------------------------------------------------------------------------------- 1 | """ API Index endpoint """ 2 | 3 | import flask 4 | from flask_restful import Resource 5 | 6 | 7 | class RootIndex(Resource): 8 | def get(self): 9 | return flask.jsonify({ 10 | 'version': 'examples' 11 | }) 12 | -------------------------------------------------------------------------------- /examples/client/js/utils/cryptoconditions/type_ids.js: -------------------------------------------------------------------------------- 1 | 2 | const TypeIds = { 3 | 'preimage': 0, 4 | 'prefix': 1, 5 | 'threshold': 2, 6 | 'rsa': 3, 7 | 'ed25519': 4, 8 | 'inverter': 98, 9 | 'timeout': 99 10 | }; 11 | 12 | 13 | export default TypeIds; 14 | -------------------------------------------------------------------------------- /tutorials/01_simple_transactions/simple_transactions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tutorials/constants/application_constants.js: -------------------------------------------------------------------------------- 1 | export const FLASK_BASE_URL = process.env.FLASK_BASE_URL; 2 | export const BDB_SERVER_URL = process.env.BDB_SERVER_URL; 3 | export const API_PATH = `${BDB_SERVER_URL}/api/v1/`; 4 | 5 | export default { 6 | API_PATH, 7 | FLASK_BASE_URL, 8 | }; 9 | -------------------------------------------------------------------------------- /tutorials/03_divisible_transactions/divisible_transactions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /drivers/javascript/constants/application_constants.js: -------------------------------------------------------------------------------- 1 | export const FLASK_BASE_URL = process.env.FLASK_BASE_URL; 2 | export const BDB_SERVER_URL = process.env.BDB_SERVER_URL; 3 | export const API_PATH = `${BDB_SERVER_URL}/api/v1/`; 4 | 5 | export default { 6 | API_PATH, 7 | FLASK_BASE_URL, 8 | }; 9 | -------------------------------------------------------------------------------- /drivers/python/compose/server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.5 2 | 3 | RUN apt-get update && apt-get install -y vim 4 | 5 | RUN mkdir -p /usr/src/app 6 | WORKDIR /usr/src/app 7 | 8 | RUN pip install --upgrade pip ipdb ipython 9 | 10 | COPY . /usr/src/app/ 11 | 12 | RUN pip install bigchaindb==0.9.1 13 | -------------------------------------------------------------------------------- /compose/bigchaindb-driver-kyber/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.5 2 | 3 | RUN apt-get update && apt-get install -y vim 4 | 5 | RUN mkdir -p /usr/src/app 6 | WORKDIR /usr/src/app 7 | 8 | RUN pip install --upgrade pip ipdb ipython 9 | 10 | COPY . /usr/src/app/ 11 | 12 | RUN pip install bigchaindb-driver 13 | -------------------------------------------------------------------------------- /drivers/python/.ci/travis-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x 4 | 5 | pip install --upgrade pip 6 | pip install --upgrade tox 7 | 8 | if [ "${TOXENV}" == "py35" ]; then 9 | sudo apt-get install rethinkdb 10 | pip install bigchaindb==0.9.1 11 | pip install --upgrade codecov 12 | fi 13 | -------------------------------------------------------------------------------- /drivers/python/compose/driver/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.5 2 | 3 | RUN apt-get update && apt-get install -y vim 4 | 5 | RUN mkdir -p /usr/src/app 6 | WORKDIR /usr/src/app 7 | 8 | RUN pip install --upgrade pip 9 | 10 | COPY . /usr/src/app/ 11 | 12 | RUN pip install --no-cache-dir --process-dependency-links -e .[dev] 13 | -------------------------------------------------------------------------------- /examples/client/js/constants/application_constants.js: -------------------------------------------------------------------------------- 1 | export const FLASK_BASE_URL = process.env.FLASK_BASE_URL; 2 | export const BDB_SERVER_URL = process.env.BDB_SERVER_URL; 3 | 4 | console.log(process.env); 5 | export const API_PATH = `${BDB_SERVER_URL}/api/v1/`; 6 | 7 | export default { 8 | API_PATH, 9 | FLASK_BASE_URL, 10 | }; 11 | -------------------------------------------------------------------------------- /drivers/python/tests/test_crypto.py: -------------------------------------------------------------------------------- 1 | def test_generate_keypair(): 2 | from bigchaindb_driver.crypto import CryptoKeypair, generate_keypair 3 | keypair = generate_keypair() 4 | assert len(keypair) == 2 5 | assert isinstance(keypair, CryptoKeypair) 6 | assert isinstance(keypair.private_key, str) 7 | assert isinstance(keypair.public_key, str) 8 | -------------------------------------------------------------------------------- /drivers/python/.ci/travis-before-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "${TOXENV}" == "py35" ]; then 4 | source /etc/lsb-release 5 | echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | tee -a /etc/apt/sources.list.d/rethinkdb.list 6 | wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | apt-key add - 7 | apt-get update -qq 8 | fi 9 | -------------------------------------------------------------------------------- /drivers/python/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS.rst 2 | include CONTRIBUTING.rst 3 | include CHANGELOG.rst 4 | include LICENSE 5 | include HACKING.rst 6 | include README.rst 7 | 8 | recursive-include tests * 9 | recursive-exclude * __pycache__ 10 | recursive-exclude * *.py[co] 11 | 12 | recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif 13 | -------------------------------------------------------------------------------- /drivers/python/tests/test_pool.py: -------------------------------------------------------------------------------- 1 | def test_get_connection(): 2 | from bigchaindb_driver.pool import Pool 3 | pool = Pool((0, 1)) 4 | connection = pool.get_connection() 5 | assert connection == 0 6 | connection = pool.get_connection() 7 | assert connection == 1 8 | connection = pool.get_connection() 9 | assert connection == 0 10 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | var TokenMock = artifacts.require("./TokenMock.sol"); 2 | var MobileEnergy = artifacts.require("./MobileEnergy.sol"); 3 | 4 | module.exports = function(deployer) { 5 | deployer.deploy(TokenMock).then(function() { 6 | return deployer.deploy(MobileEnergy, TokenMock.address); 7 | }); 8 | }; 9 | -------------------------------------------------------------------------------- /examples/client/js/react/actions/vote_actions.js: -------------------------------------------------------------------------------- 1 | import alt from '../alt'; 2 | 3 | 4 | class VoteActions { 5 | constructor() { 6 | this.generateActions( 7 | 'fetchVoteList', 8 | 'successFetchVoteList', 9 | 'flushVoteList' 10 | ); 11 | } 12 | } 13 | 14 | export default alt.createActions(VoteActions); 15 | -------------------------------------------------------------------------------- /drivers/python/docs/upgrading.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Upgrading 3 | ========= 4 | 5 | Upgrading Using pip 6 | ------------------- 7 | 8 | If you installed the BigchainDB Python Driver using ``pip install bigchaindb_driver``, then you can upgrade it to the latest version using: 9 | 10 | .. code-block:: bash 11 | 12 | pip install --upgrade bigchaindb_driver 13 | 14 | -------------------------------------------------------------------------------- /drivers/python/docs.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | bdocs: 5 | build: 6 | context: . 7 | dockerfile: ./compose/driver/Dockerfile 8 | volumes: 9 | - .:/usr/src/app/ 10 | command: make -C docs html 11 | vdocs: 12 | image: nginx 13 | ports: 14 | - '55555:80' 15 | volumes: 16 | - ./docs/_build/html:/usr/share/nginx/html 17 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/contracts/TokenMock.sol: -------------------------------------------------------------------------------- 1 | // Abstract contract for the full ERC 20 Token standard 2 | // https://github.com/ethereum/EIPs/issues/20 3 | pragma solidity ^0.4.6; 4 | 5 | contract TokenMock { 6 | function transferFrom(address _from, address _to, uint256 _value) 7 | returns (bool success) 8 | { 9 | return false; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/truffle.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | networks: { 3 | development: { 4 | host: "localhost", 5 | port: 8545, 6 | network_id: "*" // Match any network id 7 | }, 8 | bs: { 9 | host: "hackathon-team6.ukwest.cloudapp.azure.com", 10 | port: 8545, 11 | network_id: "*" // Match any network id 12 | } 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/getStatus.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * @param tx_id 7 | * @param API_PATH 8 | */ 9 | export default function getStatus(tx_id, API_PATH) { 10 | return request(getApiUrls(API_PATH)['statuses'], { 11 | query: { 12 | tx_id 13 | } 14 | }); 15 | } -------------------------------------------------------------------------------- /tutorials/constants/api_urls.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable prefer-template */ 2 | import { API_PATH } from './application_constants'; 3 | 4 | 5 | const ApiUrls = { 6 | 'transactions': API_PATH + 'transactions', 7 | 'transactions_detail': API_PATH + 'transactions/%(txId)s', 8 | 'outputs': API_PATH + 'outputs', 9 | 'statuses': API_PATH + 'statuses' 10 | }; 11 | 12 | 13 | export default ApiUrls; 14 | -------------------------------------------------------------------------------- /drivers/python/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 4 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | charset = utf-8 11 | end_of_line = lf 12 | 13 | [*.bat] 14 | indent_style = tab 15 | end_of_line = crlf 16 | 17 | [LICENSE] 18 | insert_final_newline = false 19 | 20 | [Makefile] 21 | indent_style = tab 22 | -------------------------------------------------------------------------------- /examples/docs.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | 5 | bdocs: 6 | build: 7 | context: . 8 | dockerfile: Dockerfile-bdb 9 | volumes: 10 | - .:/usr/src/app/ 11 | working_dir: /usr/src/app/docs 12 | command: make html 13 | 14 | vdocs: 15 | image: nginx 16 | ports: 17 | - '41234:80' 18 | volumes: 19 | - ./docs/build/html:/usr/share/nginx/html 20 | -------------------------------------------------------------------------------- /drivers/javascript/constants/api_urls.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable prefer-template */ 2 | import { API_PATH } from './application_constants'; 3 | 4 | 5 | const ApiUrls = { 6 | 'transactions': API_PATH + 'transactions', 7 | 'transactions_detail': API_PATH + 'transactions/%(txId)s', 8 | 'outputs': API_PATH + 'outputs', 9 | 'statuses': API_PATH + 'statuses' 10 | }; 11 | 12 | 13 | export default ApiUrls; 14 | -------------------------------------------------------------------------------- /drivers/python/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3.5 3 | 4 | env: 5 | - TOXENV=py35 6 | - TOXENV=flake8 7 | - TOXENV=docs 8 | 9 | before_install: 10 | - sudo .ci/travis-before-install.sh 11 | 12 | install: 13 | - .ci/travis-install.sh 14 | 15 | before_script: 16 | - .ci/travis-before-script.sh 17 | 18 | script: tox -e ${TOXENV} 19 | 20 | after_success: 21 | - .ci/travis-after-success.sh 22 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/listVotes.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * @param block_id 7 | * @param API_PATH 8 | */ 9 | export default function listVotes(block_id, API_PATH) { 10 | return request(getApiUrls(API_PATH)['votes'], { 11 | query: { 12 | block_id 13 | } 14 | }); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /drivers/python/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * bigchaindb-driver version: 2 | * Python version: 3 | * Operating System: 4 | 5 | ### Description 6 | 7 | Describe what you were trying to get done. 8 | Tell us what happened, what went wrong, and what you expected to happen. 9 | 10 | ### What I Did 11 | 12 | ``` 13 | Paste the command(s) you ran and the output. 14 | If there was a crash, please include the traceback here. 15 | ``` 16 | -------------------------------------------------------------------------------- /compose/examples-server/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | RUN mkdir -p /usr/src/app 4 | WORKDIR /usr/src/app 5 | 6 | RUN pip install --upgrade pip 7 | 8 | COPY examples /usr/src/app/examples 9 | COPY bigchaindb-server /usr/src/app/bigchaindb-server 10 | 11 | WORKDIR /usr/src/app/bigchaindb-server 12 | 13 | RUN pip install -e .[dev] 14 | 15 | WORKDIR /usr/src/app/examples 16 | 17 | RUN pip install --no-cache-dir -e .[dev] 18 | 19 | -------------------------------------------------------------------------------- /drivers/javascript/dist/README.md: -------------------------------------------------------------------------------- 1 | # Built files, for your convenience 2 | 3 | ~Voila~ ma boies, built files so you don't have to do a thing! Just copy pasta, and get on your way. 4 | 5 | ### `/bundled` 6 | 7 | Babelified, packaged with dependencies, and built (if you'd like), so you can drop it in anywhere 8 | you want. 9 | 10 | ### `/node` 11 | 12 | Babelified into a CommonJS module, so you can drop it in on any node project. 13 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/getTransaction.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * @param txId 7 | * @param API_PATH 8 | */ 9 | export default function getTransaction(txId, API_PATH) { 10 | return request(getApiUrls(API_PATH)['transactions_detail'], { 11 | urlTemplateSpec: { 12 | txId 13 | } 14 | }); 15 | } 16 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/postTransaction.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * 7 | * @param transaction 8 | * @param API_PATH 9 | */ 10 | export default function postTransaction(transaction, API_PATH) { 11 | return request(getApiUrls(API_PATH)['transactions'], { 12 | method: 'POST', 13 | jsonBody: transaction 14 | }) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /drivers/python/.ci/travis-before-script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x 4 | 5 | if [ "${TOXENV}" == "py35" ]; then 6 | rethinkdb --daemon 7 | export BIGCHAINDB_KEYPAIR_PUBLIC=GW1nrdZm4mbVC8ePeiGWz6DqHexqewqy5teURVHi3RG4 8 | export BIGCHAINDB_KEYPAIR_PRIVATE=2kQgBtQnHoauw8QchKM7xYvEBW1QDoHzhBsCL9Vi1AzB 9 | 10 | # Start BigchainDB in the background and ignore any output 11 | bigchaindb start >/dev/null 2>&1 & 12 | fi 13 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/getBlock.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * @param blockId 7 | * @param API_PATH 8 | */ 9 | export default function getBlock(blockId, API_PATH) { 10 | return request(getApiUrls(API_PATH)['blocks_detail'], { 11 | urlTemplateSpec: { 12 | blockId 13 | } 14 | }); 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/client/scss/_layout.scss: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // More sane box model 4 | // 5 | *, 6 | *:before, 7 | *:after { 8 | box-sizing: border-box; 9 | } 10 | 11 | 12 | // 13 | // Body reset 14 | // 15 | html, 16 | body, 17 | .app, 18 | .app > div, 19 | .app > div > div, 20 | .app__content { 21 | margin: 0; 22 | padding: 0; 23 | width: 100%; 24 | min-height: 100vh; 25 | } 26 | 27 | .app__content { 28 | padding-top: $menu-height; 29 | } -------------------------------------------------------------------------------- /examples/client/js/react/actions/block_actions.js: -------------------------------------------------------------------------------- 1 | import alt from '../alt'; 2 | 3 | 4 | class BlockActions { 5 | constructor() { 6 | this.generateActions( 7 | 'fetchBlockList', 8 | 'successFetchBlockList', 9 | 'flushBlockList', 10 | 'flushBlock', 11 | 'fetchBlock', 12 | 'successFetchBlock' 13 | ); 14 | } 15 | } 16 | 17 | export default alt.createActions(BlockActions); 18 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/hashTransaction.js: -------------------------------------------------------------------------------- 1 | import serializeTransactionIntoCanonicalString from './serializeTransactionIntoCanonicalString'; 2 | import sha256Hash from '../sha256Hash'; 3 | 4 | export default function hashTransaction(transaction) { 5 | // Safely remove any tx id from the given transaction for hashing 6 | const tx = { ...transaction }; 7 | delete tx.id; 8 | 9 | return sha256Hash(serializeTransactionIntoCanonicalString(tx)); 10 | } -------------------------------------------------------------------------------- /drivers/javascript/src/connection/listBlocks.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * @param tx_id 7 | * @param status 8 | * @param API_PATH 9 | */ 10 | export default function listBlocks({tx_id, status}, API_PATH) { 11 | return request(getApiUrls(API_PATH)['blocks'], { 12 | query: { 13 | tx_id, 14 | status 15 | } 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/getApiUrls.js: -------------------------------------------------------------------------------- 1 | export default function getApiUrls(API_PATH) { 2 | return { 3 | 'blocks': API_PATH + 'blocks', 4 | 'blocks_detail': API_PATH + 'blocks/%(blockId)s', 5 | 'outputs': API_PATH + 'outputs', 6 | 'statuses': API_PATH + 'statuses', 7 | 'transactions': API_PATH + 'transactions', 8 | 'transactions_detail': API_PATH + 'transactions/%(txId)s', 9 | 'votes': API_PATH + 'votes' 10 | }; 11 | } -------------------------------------------------------------------------------- /drivers/javascript/src/connection/index.js: -------------------------------------------------------------------------------- 1 | export getBlock from './getBlock'; 2 | export getTransaction from './getTransaction'; 3 | export getStatus from './getStatus'; 4 | export listBlocks from './listBlocks'; 5 | export listOutputs from './listOutputs'; 6 | export listTransactions from './listTransactions'; 7 | export listVotes from './listVotes'; 8 | export pollStatusAndFetchTransaction from './pollStatusAndFetchTransaction'; 9 | export postTransaction from './postTransaction'; 10 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/listTransactions.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * @param asset_id 7 | * @param operation 8 | * @param API_PATH 9 | */ 10 | export default function listTransactions({ asset_id, operation }, API_PATH) { 11 | return request(getApiUrls(API_PATH)['transactions'], { 12 | query: { 13 | asset_id, 14 | operation 15 | } 16 | }) 17 | } -------------------------------------------------------------------------------- /drivers/python/tests/test_transport.py: -------------------------------------------------------------------------------- 1 | from requests.utils import default_headers 2 | 3 | 4 | def test_init_with_headers(): 5 | from bigchaindb_driver.transport import Transport 6 | headers = {'app_id': 'id'} 7 | transport = Transport('node1', 'node2', headers=headers) 8 | expected_headers = default_headers() 9 | expected_headers.update(headers) 10 | assert transport.pool.connections[0].session.headers == expected_headers 11 | assert transport.pool.connections[1].session.headers == expected_headers 12 | -------------------------------------------------------------------------------- /drivers/javascript/src/connection/listOutputs.js: -------------------------------------------------------------------------------- 1 | import getApiUrls from './getApiUrls'; 2 | import request from '../request'; 3 | 4 | /** 5 | * @public 6 | * @param public_key 7 | * @param unspent 8 | * @param API_PATH 9 | * @param onlyJsonResponse 10 | */ 11 | export default function listOutputs({ public_key, unspent }, API_PATH, onlyJsonResponse=true) { 12 | return request(getApiUrls(API_PATH)['outputs'], { 13 | query: { 14 | public_key, 15 | unspent 16 | } 17 | }, onlyJsonResponse) 18 | } -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/README.md: -------------------------------------------------------------------------------- 1 | # Energy as a Service 2 | 3 | ## Vision: 4 | 5 | "A platform to share __mobile electricity assets__" between peers 6 | 7 | ## Benefits: 8 | 9 | - Pay as you use: No need for a monthly contract with an utility company 10 | - Access to energy sources wherever you go 11 | - Monetization of your electricity assets 12 | - Service-based sharing economy 13 | 14 | ## References 15 | 16 | [Presentation](https://docs.google.com/presentation/d/1OQmSJz7KlWXO--5g4DlESI80t23Rk47Gk02qajEirTc/edit#slide=id.p) -------------------------------------------------------------------------------- /drivers/python/HACKING.rst: -------------------------------------------------------------------------------- 1 | Installing latest master with pip 2 | --------------------------------- 3 | In order to work with the latest BigchainDB (server) master branch: 4 | 5 | .. code-block:: bash 6 | 7 | $ pip install --process-dependency-links git+https://github.com/bigchaindb/bigchaindb-driver.git 8 | 9 | Point to some BigchainDB node, which is running BigchainDB server ``master``: 10 | 11 | .. code-block:: python 12 | 13 | from bigchaindb_driver import BigchainDB 14 | 15 | bdb = BigchainDB('http://here.be.dragons:9984') 16 | -------------------------------------------------------------------------------- /drivers/python/setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.2.1 3 | commit = True 4 | tag = True 5 | parse = (?P\d+)\.(?P\d+)\.(?P\d+) 6 | serialize = 7 | {major}.{minor}.{patch} 8 | 9 | [bumpversion:file:setup.py] 10 | search = version='{current_version}' 11 | replace = version='{new_version}' 12 | 13 | [bumpversion:file:bigchaindb_driver/__init__.py] 14 | search = __version__ = '{current_version}' 15 | replace = __version__ = '{new_version}' 16 | 17 | [wheel] 18 | universal = 0 19 | 20 | [flake8] 21 | exclude = docs 22 | 23 | -------------------------------------------------------------------------------- /examples/client/audio_lock/scss/_dictaphone.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Speak input feedback 3 | // 4 | .dictaphone { 5 | margin-top: $spacer; 6 | min-height: $font-size-base; 7 | } 8 | 9 | .dictaphone__word, 10 | .dictaphone__interim { 11 | font-family: $font-family-monospace; 12 | color: $text-color; 13 | } 14 | 15 | .dictaphone__word { 16 | padding: 0 .5rem; 17 | opacity: .5; 18 | 19 | &.active { 20 | color: $brand-main-green; 21 | opacity: 1; 22 | } 23 | } 24 | 25 | .dictaphone__interim { 26 | display: none; 27 | } -------------------------------------------------------------------------------- /examples/client/scss/_search.scss: -------------------------------------------------------------------------------- 1 | .searchbar { 2 | margin: 0 auto; 3 | } 4 | 5 | .searchbar input[type="url"] { 6 | width: 80%; 7 | display: inline-block; 8 | @media (max-width: 480px) { 9 | width: 70%; 10 | } 11 | } 12 | 13 | .searchbar input[type="submit"] { 14 | width: calc(20% - 15px); 15 | padding-left: 0; 16 | padding-right: 0; 17 | margin-left: 15px; 18 | margin-right: 0; 19 | display: inline-block; 20 | @media (max-width: 480px) { 21 | width: 30%; 22 | margin-left: 0px; 23 | } 24 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build init start 2 | 3 | build: 4 | docker-compose build rdb 5 | docker-compose build bdb-server 6 | docker-compose build examples-client-frontend 7 | 8 | init: reinit_db 9 | 10 | start: 11 | docker-compose up -d bdb-server 12 | docker-compose up -d examples-client-frontend 13 | 14 | restart: init start 15 | 16 | drop_db: 17 | docker-compose stop rdb 18 | docker-compose rm -f rdb 19 | 20 | start_db: 21 | docker-compose up -d rdb 22 | 23 | run: init start 24 | 25 | reinit_db: drop_db start_db 26 | sleep 10 27 | 28 | stop: 29 | docker-compose down -------------------------------------------------------------------------------- /examples/client/interledger/js/app.js: -------------------------------------------------------------------------------- 1 | // Install necessary polyfills (see supported browsers) into global 2 | import 'core-js/es6'; 3 | import 'core-js/stage/4'; 4 | import 'isomorphic-fetch'; 5 | 6 | import React from 'react'; 7 | import ReactDOM from 'react-dom'; 8 | 9 | import Interledger from './components/interledger'; 10 | 11 | import '../../scss/main.scss'; 12 | 13 | 14 | const App = () => ( 15 |
16 | 17 |
18 | ); 19 | 20 | ReactDOM.render(, document.getElementsByClassName('app')[0]); 21 | -------------------------------------------------------------------------------- /examples/client/tx_explorer/js/app.js: -------------------------------------------------------------------------------- 1 | // Install necessary polyfills (see supported browsers) into global 2 | import 'core-js/es6'; 3 | import 'core-js/stage/4'; 4 | import 'isomorphic-fetch'; 5 | 6 | import React from 'react'; 7 | import ReactDOM from 'react-dom'; 8 | 9 | import TxExplorer from './components/tx_explorer'; 10 | 11 | import '../../scss/main.scss'; 12 | 13 | 14 | const App = () => ( 15 |
16 | 17 |
18 | ); 19 | 20 | ReactDOM.render(, document.getElementsByClassName('app')[0]); 21 | -------------------------------------------------------------------------------- /examples/client/share_trader/js/app.js: -------------------------------------------------------------------------------- 1 | // Install necessary polyfills (see supported browsers) into global 2 | import 'core-js/es6'; 3 | import 'core-js/stage/4'; 4 | import 'isomorphic-fetch'; 5 | 6 | import React from 'react'; 7 | import ReactDOM from 'react-dom'; 8 | 9 | import ShareTrader from './components/share_trader'; 10 | 11 | import '../../scss/main.scss'; 12 | 13 | 14 | const App = () => ( 15 |
16 | 17 |
18 | ); 19 | 20 | ReactDOM.render(, document.getElementsByClassName('app')[0]); 21 | -------------------------------------------------------------------------------- /examples/client/js/react/actions/account_actions.js: -------------------------------------------------------------------------------- 1 | import alt from '../alt'; 2 | 3 | 4 | class AccountActions { 5 | constructor() { 6 | this.generateActions( 7 | 'flushAccount', 8 | 'fetchAccount', 9 | 'successFetchAccount', 10 | 'flushAccountList', 11 | 'fetchAccountList', 12 | 'successFetchAccountList', 13 | 'errorAccount', 14 | 'postAccount', 15 | 'successPostAccount' 16 | ); 17 | } 18 | } 19 | 20 | export default alt.createActions(AccountActions); 21 | -------------------------------------------------------------------------------- /examples/client/audio_lock/js/app.js: -------------------------------------------------------------------------------- 1 | // Install necessary polyfills (see supported browsers) into global 2 | import './components/audiocontext-polyfill'; 3 | 4 | import 'core-js/es6'; 5 | import 'core-js/stage/4'; 6 | import 'isomorphic-fetch'; 7 | 8 | import React from 'react'; 9 | import ReactDOM from 'react-dom'; 10 | 11 | import AudioLock from './components/audio_lock' 12 | 13 | import '../../scss/main.scss'; 14 | 15 | 16 | const App = () => ( 17 |
18 | 19 |
20 | ); 21 | 22 | ReactDOM.render(, document.getElementsByClassName('app')[0]); -------------------------------------------------------------------------------- /examples/docs/source/ack.rst: -------------------------------------------------------------------------------- 1 | Acknowledgements 2 | ================ 3 | Special thanks to the BigchainDB/ascribe.io team for their insights and code 4 | contributions: 5 | 6 | `@r-marques`_, `@vrde`_, `@ttmc`_, `@rhsimplex`_, `@SohKai`_, `@sbellem`_, `@TimDaub`_, `@diminator`_ 7 | 8 | 9 | .. _@r-marques: https://github.com/r-marques 10 | .. _@vrde: https://github.com/vrde 11 | .. _@ttmc: https://github.com/ttmc 12 | .. _@rhsimplex: https://github.com/rhsimplex 13 | .. _@SohKai: https://github.com/SohKai 14 | .. _@sbellem: https://github.com/sbellem 15 | .. _@TimDaub: https://github.com/TimDaub 16 | .. _@diminator: https://github.com/diminator 17 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.4; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | modifier restricted() { 8 | if (msg.sender == owner) _; 9 | } 10 | 11 | function Migrations() { 12 | owner = msg.sender; 13 | } 14 | 15 | function setCompleted(uint completed) restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/client/js/constants/api_urls.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable prefer-template */ 2 | import { API_PATH } from './application_constants'; 3 | 4 | 5 | const ApiUrls = { 6 | 'accounts': API_PATH + 'accounts', 7 | 'accounts_detail': API_PATH + 'accounts/%(accountId)s/', 8 | 'assets': API_PATH + 'assets', 9 | 'assets_detail': API_PATH + 'assets/%(assetId)s/', 10 | 'assets_transfer': API_PATH + 'assets/%(assetId)s/%(cid)s/transfer/', 11 | 'assets_escrow': API_PATH + 'assets/%(assetId)s/%(cid)s/escrow/', 12 | 'assets_escrow_fulfill': API_PATH + 'assets/%(assetId)s/%(cid)s/escrow/fulfill/' 13 | }; 14 | 15 | 16 | export default ApiUrls; 17 | -------------------------------------------------------------------------------- /examples/client/js/react/sources/vote_source.js: -------------------------------------------------------------------------------- 1 | import * as driver from 'js-bigchaindb-quickstart'; 2 | 3 | import { API_PATH } from '../../constants/application_constants'; 4 | 5 | import VoteActions from '../actions/vote_actions'; 6 | 7 | 8 | const VoteSource = { 9 | lookupVoteList: { 10 | remote(state) { 11 | const {block_id} = state.voteMeta; 12 | // fetch votes for block 13 | return driver.Connection.listVotes(block_id, API_PATH); 14 | }, 15 | 16 | success: VoteActions.successFetchVoteList, 17 | error: VoteActions.errorVoteList 18 | } 19 | }; 20 | 21 | export default VoteSource; 22 | -------------------------------------------------------------------------------- /examples/client/js/react/actions/transaction_actions.js: -------------------------------------------------------------------------------- 1 | import alt from '../alt'; 2 | 3 | 4 | class TransactionActions { 5 | constructor() { 6 | this.generateActions( 7 | 'fetchTransactionList', 8 | 'successFetchTransactionList', 9 | 'flushTransactionList', 10 | 'postTransaction', 11 | 'successPostTransaction', 12 | 'flushTransaction', 13 | 'fetchTransaction', 14 | 'successFetchTransaction', 15 | 'fetchOutputList', 16 | 'successFetchOutputList' 17 | ); 18 | } 19 | } 20 | 21 | export default alt.createActions(TransactionActions); 22 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/index.js: -------------------------------------------------------------------------------- 1 | export makeEd25519Condition from './makeEd25519Condition'; 2 | export makeSha256Condition from './makeSha256Condition'; 3 | export makeThresholdCondition from './makeThresholdCondition'; 4 | export makeCreateTransaction from './makeCreateTransaction'; 5 | export makeOutput from './makeOutput'; 6 | export makeTransaction from './makeTransaction'; 7 | export makeTransferTransaction from './makeTransferTransaction'; 8 | export serializeTransactionIntoCanonicalString from './serializeTransactionIntoCanonicalString'; 9 | export signTransaction from './signTransaction'; 10 | export ccJsonLoad from './utils/ccJsonLoad'; 11 | export ccJsonify from './utils/ccJsonify'; 12 | -------------------------------------------------------------------------------- /examples/client/scss/_asset.scss: -------------------------------------------------------------------------------- 1 | .asset-container { 2 | border-bottom: 1px solid lighten($fg-color, 50%); 3 | border-left: 5px solid transparent; 4 | padding: 1em; 5 | } 6 | 7 | .asset-container-actions { 8 | margin-top: 1em 9 | } 10 | 11 | .asset-container-id, 12 | .asset-container-timestamp { 13 | font-size: 0.8em; 14 | text-transform: uppercase; 15 | } 16 | 17 | .asset-container-id { 18 | margin-bottom: 1em; 19 | overflow: hidden; 20 | font-size: 0.75em; 21 | font-style: italic; 22 | text-overflow: ellipsis; 23 | } 24 | 25 | .asset-container-timestamp { 26 | color: lighten($fg-color, 50%); 27 | margin-bottom: -.6em; 28 | text-align: right; 29 | } -------------------------------------------------------------------------------- /drivers/python/bigchaindb_driver/crypto.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | 3 | from cryptoconditions import crypto 4 | 5 | 6 | CryptoKeypair = namedtuple('CryptoKeypair', ('private_key', 'public_key')) 7 | 8 | 9 | def generate_keypair(): 10 | """Generates a cryptographic key pair. 11 | 12 | Returns: 13 | :class:`~bigchaindb_driver.crypto.CryptoKeypair`: A 14 | :obj:`collections.namedtuple` with named fields 15 | :attr:`~bigchaindb_driver.crypto.CryptoKeypair.private_key` and 16 | :attr:`~bigchaindb_driver.crypto.CryptoKeypair.public_key`. 17 | 18 | """ 19 | return CryptoKeypair( 20 | *(k.decode() for k in crypto.ed25519_generate_key_pair())) 21 | -------------------------------------------------------------------------------- /drivers/python/tests/test_exceptions.py: -------------------------------------------------------------------------------- 1 | class TestTransportError: 2 | 3 | def test_status_code_property(self): 4 | from bigchaindb_driver.exceptions import TransportError 5 | err = TransportError(404) 6 | assert err.status_code == 404 7 | 8 | def test_error_property(self): 9 | from bigchaindb_driver.exceptions import TransportError 10 | err = TransportError(404, 'not found') 11 | assert err.error == 'not found' 12 | 13 | def test_info_property(self): 14 | from bigchaindb_driver.exceptions import TransportError 15 | err = TransportError(404, 'not found', {'error': 'not found'}) 16 | assert err.info == {'error': 'not found'} 17 | -------------------------------------------------------------------------------- /drivers/javascript/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | 'presets': ['es2015-no-commonjs'], 3 | 'plugins': [ 4 | 'transform-export-extensions', 5 | 'transform-object-assign', 6 | 'transform-object-rest-spread' 7 | ], 8 | 'sourceMaps': true, 9 | 10 | 'env': { 11 | 'bundle': { 12 | 'plugins': [ 13 | ['transform-runtime', { 14 | 'polyfill': true, 15 | 'regenerator': false 16 | }] 17 | ] 18 | }, 19 | 'cjs': { 20 | 'plugins': [ 21 | 'add-module-exports', 22 | 'transform-es2015-modules-commonjs' 23 | ] 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeOutput.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @public 3 | * Create an Output from a Condition. 4 | * Note: Assumes the given Condition was generated from a single public key (e.g. a Ed25519 Condition) 5 | * @param {object} condition Condition (e.g. a Ed25519 Condition from `makeEd25519Condition()`) 6 | * @param {number} amount Amount of the output 7 | * @returns {object} An Output usable in a Transaction 8 | */ 9 | export default function makeOutput(condition, amount = 1) { 10 | return { 11 | amount: JSON.stringify(amount), 12 | condition, 13 | 'public_keys': condition.details.hasOwnProperty('public_key') ? 14 | [condition.details.public_key] : [], 15 | }; 16 | } -------------------------------------------------------------------------------- /examples/compose/frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:6 2 | 3 | RUN mkdir -p /usr/src/app 4 | WORKDIR /usr/src/app/client 5 | 6 | COPY client /usr/src/app/client 7 | 8 | # Adds fs-extra to npm and replaces the fs.rename method with the fs.extra 9 | # move method that now automatic chooses what to do (rename/move). 10 | # See https://github.com/npm/npm/issues/9863. 11 | RUN cd $(npm root -g)/npm \ 12 | && npm install fs-extra \ 13 | && sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs\.move/ ./lib/utils/rename.js 14 | 15 | # On some platforms, the .dockerignore file is being ignored in some versions of docker-compose 16 | # See https://github.com/docker/compose/issues/1607. 17 | RUN rm -rf node_modules 18 | 19 | RUN npm install 20 | -------------------------------------------------------------------------------- /examples/docs/source/index.rst: -------------------------------------------------------------------------------- 1 | ******************* 2 | BigchainDB Examples 3 | ******************* 4 | 5 | Documentation for the BigchainDB examples and tutorials found under 6 | https://github.com/bigchaindb/bigchaindb-examples 7 | 8 | .. warning:: These examples are for demonstration purpose and should not be 9 | used for production 10 | 11 | 12 | 13 | Contents 14 | ======== 15 | 16 | .. toctree:: 17 | :maxdepth: 2 18 | 19 | structure 20 | install 21 | run 22 | ontherecord 23 | sharetrader 24 | interledger 25 | troubleshooting 26 | docs 27 | ack 28 | 29 | 30 | Indices and tables 31 | ================== 32 | 33 | * :ref:`genindex` 34 | * :ref:`modindex` 35 | * :ref:`search` 36 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/serializeTransactionIntoCanonicalString.js: -------------------------------------------------------------------------------- 1 | import stableStringify from 'json-stable-stringify'; 2 | import clone from 'clone'; 3 | 4 | 5 | /** 6 | * @public 7 | * Canonically serializes a transaction into a string by sorting the keys 8 | * @param {object} (transaction) 9 | * @return {string} a canonically serialized Transaction 10 | */ 11 | export default function serializeTransactionIntoCanonicalString(transaction) { 12 | // BigchainDB signs fulfillments by serializing transactions into a "canonical" format where 13 | const tx = clone(transaction); 14 | // TODO: set fulfillments to null 15 | // Sort the keys 16 | return stableStringify(tx, (a, b) => (a.key > b.key ? 1 : -1)); 17 | } -------------------------------------------------------------------------------- /tutorials/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | 'presets': ['react', 'es2015'], 3 | 'plugins': [ 4 | 'transform-object-assign', 5 | 'transform-react-display-name', 6 | [ 'transform-runtime', { 7 | 'polyfill': false, 8 | 'regenerator': true 9 | } ] 10 | ], 11 | 'sourceMaps': true, 12 | 13 | 'env': { 14 | 'demo': { 15 | 'plugins': [ 16 | [ 'react-transform', { 17 | 'transforms': [{ 18 | 'transform': 'react-transform-hmr', 19 | 'imports': ['react'], 20 | 'locals': ['module'] 21 | }] 22 | } ] 23 | ] 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /drivers/python/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py35, flake8, docs 3 | 4 | [base] 5 | deps = pip>=9.0.1 6 | 7 | [testenv:flake8] 8 | basepython=python 9 | deps = 10 | flake8 11 | {[base]deps} 12 | commands=flake8 bigchaindb_driver 13 | 14 | [testenv:docs] 15 | basepython=python 16 | changedir=docs 17 | deps = 18 | -r{toxinidir}/docs/requirements.txt 19 | {[base]deps} 20 | commands= 21 | sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html 22 | 23 | [testenv] 24 | setenv = 25 | PYTHONPATH = {toxinidir}:{toxinidir}/bigchaindb_driver 26 | deps = 27 | {[base]deps} 28 | install_command = pip install {opts} {packages} .[test] 29 | commands = 30 | py.test -v -n auto --cov=bigchaindb_driver --basetemp={envtmpdir} 31 | -------------------------------------------------------------------------------- /examples/client/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | 'presets': ['react', 'es2015'], 3 | 'plugins': [ 4 | 'transform-object-assign', 5 | 'transform-react-display-name', 6 | [ 'transform-runtime', { 7 | 'polyfill': false, 8 | 'regenerator': true 9 | } ] 10 | ], 11 | 'sourceMaps': true, 12 | 13 | 'env': { 14 | 'demo': { 15 | 'plugins': [ 16 | [ 'react-transform', { 17 | 'transforms': [{ 18 | 'transform': 'react-transform-hmr', 19 | 'imports': ['react'], 20 | 'locals': ['module'] 21 | }] 22 | } ] 23 | ] 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/client/js/plugins/ledger_utils.js: -------------------------------------------------------------------------------- 1 | import BigchainDBLedgerPlugin from 'ilp-plugin-bigchaindb'; 2 | 3 | const connectToBigchainDBLedger = (account) => { 4 | const ledgerPlugin = new BigchainDBLedgerPlugin({ 5 | auth: { 6 | account: { 7 | id: account.vk, 8 | key: account.sk, 9 | uri: { 10 | api: `http://${account.ledger.api}`, 11 | ws: `ws://${account.ledger.ws}` 12 | } 13 | } 14 | }, 15 | ledgerId: account.ledger.id 16 | }); 17 | 18 | ledgerPlugin.connect() 19 | .catch(console.error); 20 | return ledgerPlugin; 21 | }; 22 | 23 | 24 | export default connectToBigchainDBLedger; 25 | -------------------------------------------------------------------------------- /examples/client/js/utils/cryptoconditions/filter_by_type.js: -------------------------------------------------------------------------------- 1 | 2 | const filterByType = ({ condition, typeId, maxDepth }) => { 3 | let res = []; 4 | if (condition.hasOwnProperty('type_id') && condition.type_id === typeId) { 5 | res.push(condition); 6 | } 7 | 8 | if (condition.hasOwnProperty('subfulfillments') && (maxDepth || maxDepth == null)) { 9 | res = res.concat(...Object.values(condition.subfulfillments).map((subcondition) => { 10 | return filterByType({ 11 | typeId, 12 | condition: subcondition, 13 | maxDepth: maxDepth && maxDepth - 1 14 | }); 15 | })); 16 | } 17 | 18 | return res; 19 | }; 20 | 21 | 22 | export default filterByType; 23 | -------------------------------------------------------------------------------- /examples/client/audio_lock/js/components/utils.js: -------------------------------------------------------------------------------- 1 | import * as driver from 'js-bigchaindb-quickstart'; 2 | 3 | import { API_PATH } from '../../../js/constants/application_constants'; 4 | import TransactionActions from '../../../js/react/actions/transaction_actions'; 5 | 6 | 7 | export function fetchAsset(id, publicKey) { 8 | setTimeout(() => { 9 | driver.Connection.pollStatusAndFetchTransaction(id, API_PATH) 10 | .then(() => { 11 | TransactionActions.fetchOutputList({ 12 | public_key: publicKey, 13 | unspent: true 14 | }); 15 | TransactionActions.fetchTransactionList({ 16 | assetId: id 17 | }); 18 | }) 19 | }, 1000); 20 | } -------------------------------------------------------------------------------- /examples/client/scss/main.scss: -------------------------------------------------------------------------------- 1 | @import '_normalize.css'; 2 | @import 'variables'; 3 | @import 'mixins'; 4 | 5 | 6 | // 7 | // Globals for all examples 8 | // 9 | @import 'typography'; 10 | @import 'layout'; 11 | @import 'menu'; 12 | @import 'icons'; 13 | @import 'buttons'; 14 | @import 'forms'; 15 | @import 'logo'; 16 | @import 'animations'; 17 | @import 'code'; 18 | @import 'modal'; 19 | 20 | @import 'account'; 21 | @import 'asset'; 22 | @import 'card'; 23 | @import 'search'; 24 | @import 'sidebar'; 25 | @import 'style'; 26 | @import 'transaction'; 27 | 28 | 29 | // 30 | // Specific example app styles 31 | // 32 | @import '../tx_explorer/scss/custom_style'; 33 | @import '../audio_lock/scss/custom_style'; 34 | @import '../share_trader/scss/custom_style'; 35 | @import '../interledger/scss/custom_style'; 36 | -------------------------------------------------------------------------------- /examples/docs/source/ontherecord.rst: -------------------------------------------------------------------------------- 1 | .. _ontherecord: 2 | 3 | On the Record 4 | ============= 5 | 6 | "On the Record" is a simple logging app, wrapped as a messaging board. 7 | 8 | .. image:: /_static/ontherecord.png 9 | 10 | 11 | Use cases 12 | --------- 13 | 14 | - Immutable logging of data 15 | - Notarization of data, text, emails 16 | 17 | Functionality 18 | ------------- 19 | 20 | Create assets 21 | ^^^^^^^^^^^^^ 22 | 23 | - With arbitrary payload 24 | - And an unlimited amount 25 | 26 | Retrieve assets 27 | *************** 28 | 29 | - That you currently own (like UTXO's) 30 | - By searching the asset data/payload 31 | - State indicator (in backlog vs. on bigchain) 32 | 33 | What this app doesn't provide 34 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | - Proper user and key management 37 | - Transfer of assets 38 | -------------------------------------------------------------------------------- /drivers/python/LICENSES.md: -------------------------------------------------------------------------------- 1 | # Code Licenses 2 | 3 | All code in _this_ repository (including short code snippets embedded in the official BigchainDB _documentation_) is licensed under the Apache Software License 2.0, the full text of which can be found at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0). 4 | 5 | For the licenses on all other BigchainDB-related code, see the license file in the associated repository. 6 | 7 | # Documentation Licenses 8 | 9 | The official BigchainDB documentation, _except for the short code snippets embedded within it_, is licensed under a Creative Commons Attribution-ShareAlike 4.0 International license, the full text of which can be found at [http://creativecommons.org/licenses/by-sa/4.0/legalcode](http://creativecommons.org/licenses/by-sa/4.0/legalcode). 10 | -------------------------------------------------------------------------------- /examples/client/scss/_logo.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Logo 3 | // --- 4 | // bigchain.io 5 | // 6 | 7 | // default logo 8 | .logo { 9 | fill: $brand-main-green; 10 | color: $brand-main-blue; // the fill="currentColor" trick 11 | width: 300px; 12 | height: 60px; 13 | display: block; 14 | } 15 | 16 | 17 | // 18 | // Color modifiers 19 | // 20 | .logo--white { 21 | fill: #fff; 22 | color: #fff; 23 | } 24 | 25 | .logo--white--green { 26 | fill:$brand-main-green; 27 | color: #fff; 28 | } 29 | 30 | 31 | // 32 | // size modifiers 33 | // 34 | .logo--sm { 35 | width: 140px; 36 | height: 25px; 37 | } 38 | 39 | .logo--full { 40 | display: block; 41 | width: 100%; 42 | height: auto; 43 | } 44 | 45 | 46 | // 47 | // color modifiers 48 | // 49 | .logo--dark { 50 | fill: $brand-main-blue-dark; 51 | } 52 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeTransaction.js: -------------------------------------------------------------------------------- 1 | import hashTransaction from './hashTransaction'; 2 | 3 | 4 | function makeTransactionTemplate() { 5 | return { 6 | 'id': null, 7 | 'operation': null, 8 | 'outputs': [], 9 | 'inputs': [], 10 | 'metadata': null, 11 | 'asset': null, 12 | 'version': '0.9', 13 | }; 14 | } 15 | 16 | 17 | export default function makeTransaction(operation, asset, metadata = null, outputs = [], inputs = []) { 18 | const tx = makeTransactionTemplate(); 19 | tx.operation = operation; 20 | tx.asset = asset; 21 | tx.metadata = metadata; 22 | tx.inputs = inputs; 23 | tx.outputs = outputs; 24 | 25 | // Hashing must be done after, as the hash is of the Transaction (up to now) 26 | tx.id = hashTransaction(tx); 27 | return tx; 28 | } 29 | -------------------------------------------------------------------------------- /drivers/python/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. bigchaindb_driver documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | BigchainDB Python Driver 7 | ======================== 8 | 9 | .. important:: **Development Status: Alpha** 10 | 11 | .. toctree:: 12 | :maxdepth: 1 13 | 14 | ← Back to All BigchainDB Docs 15 | readme 16 | quickstart 17 | connect 18 | usage 19 | advanced-usage 20 | handcraft 21 | upgrading 22 | libref 23 | aboutthedocs 24 | contributing 25 | authors 26 | changelog 27 | 28 | Indices and tables 29 | ================== 30 | 31 | * :ref:`genindex` 32 | * :ref:`modindex` 33 | * :ref:`search` 34 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/contracts/Token.sol: -------------------------------------------------------------------------------- 1 | // Abstract contract for the full ERC 20 Token standard 2 | // https://github.com/ethereum/EIPs/issues/20 3 | pragma solidity ^0.4.6; 4 | 5 | contract Token { 6 | function totalSupply() constant returns (uint256); 7 | function balanceOf(address _owner) constant returns (uint256 balance); 8 | function transfer(address _to, uint256 _value) returns (bool success); 9 | function transferFrom(address _from, address _to, uint256 _value) returns (bool success); 10 | function approve(address _spender, uint256 _value) returns (bool success); 11 | function allowance(address _owner, address _spender) constant returns (uint256 remaining); 12 | 13 | event Transfer(address indexed _from, address indexed _to, uint256 _value); 14 | event Approval(address indexed _owner, address indexed _spender, uint256 _value); 15 | } 16 | -------------------------------------------------------------------------------- /examples/server/routes.py: -------------------------------------------------------------------------------- 1 | """ API routes definition """ 2 | from flask_restful import Api 3 | from server.views import ( 4 | accounts, 5 | assets, 6 | info 7 | ) 8 | 9 | 10 | def add_routes(app): 11 | """ Add the routes to an app """ 12 | for (prefix, routes) in API_SECTIONS: 13 | api = Api(app, prefix=prefix) 14 | for ((pattern, resource, *args), kwargs) in routes: 15 | kwargs.setdefault('strict_slashes', False) 16 | api.add_resource(resource, pattern, *args, **kwargs) 17 | 18 | 19 | def r(*args, **kwargs): 20 | return (args, kwargs) 21 | 22 | 23 | ROUTES_API_V1 = [ 24 | r('/', info.RootIndex), 25 | r('accounts', accounts.AccountListApi), 26 | r('assets', assets.AssetListApi), 27 | r('connectors', accounts.ConnectorListApi) 28 | ] 29 | 30 | 31 | API_SECTIONS = [ 32 | ('/api/examples/', ROUTES_API_V1), 33 | ] 34 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeSha256Condition.js: -------------------------------------------------------------------------------- 1 | import { Buffer } from 'buffer'; 2 | 3 | import cc from 'five-bells-condition'; 4 | 5 | import ccJsonify from './utils/ccJsonify'; 6 | 7 | 8 | /** 9 | * @public 10 | * Create a Preimage-Sha256 Cryptocondition from a secret to put into an Output of a Transaction 11 | * @param {string} preimage Preimage to be hashed and wrapped in a crypto-condition 12 | * @param {boolean} [json=true] If true returns a json object otherwise a crypto-condition type 13 | * @returns {object} Preimage-Sha256 Condition (that will need to wrapped in an Output) 14 | */ 15 | export default function makeSha256Condition(preimage, json=true) { 16 | const sha256Fulfillment = new cc.PreimageSha256(); 17 | sha256Fulfillment.preimage = new Buffer(preimage); 18 | 19 | if (json) { 20 | return ccJsonify(sha256Fulfillment) 21 | } 22 | return sha256Fulfillment; 23 | } 24 | -------------------------------------------------------------------------------- /drivers/python/dev.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | client-dev: 5 | build: 6 | context: . 7 | dockerfile: ./compose/driver/Dockerfile 8 | volumes: 9 | - ./docs:/usr/src/app/docs 10 | - ./tests:/usr/src/app/tests 11 | - ./bigchaindb_driver:/usr/src/app/bigchaindb_driver 12 | - ./setup.py:/usr/src/app/setup.py 13 | - ./tox.ini:/usr/src/app/tox.ini 14 | environment: 15 | BDB_HOST: node-dev 16 | command: pytest -v 17 | rdb-dev: 18 | image: rethinkdb 19 | ports: 20 | - "8080" 21 | - "28015" 22 | node-dev: 23 | build: 24 | context: ../bigchaindb/ 25 | dockerfile: Dockerfile-dev 26 | volumes: 27 | - ../bigchaindb/bigchaindb:/usr/src/app/bigchaindb/ 28 | environment: 29 | BIGCHAINDB_DATABASE_HOST: rdb-dev 30 | BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984 31 | ports: 32 | - "9984" 33 | command: bigchaindb start 34 | -------------------------------------------------------------------------------- /examples/client/js/react/components/account_detail.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import classnames from 'classnames'; 4 | import { Row } from 'react-bootstrap/lib'; 5 | 6 | 7 | const AccountDetail = ({ 8 | account, 9 | isActive, 10 | handleClick 11 | }) => { 12 | return ( 13 | 16 |
17 | {account.name} 18 |
19 |
20 | {account.vk} 21 |
22 |
23 | ); 24 | }; 25 | 26 | AccountDetail.propTypes = { 27 | account: React.PropTypes.object, 28 | assetList: React.PropTypes.array, 29 | handleClick: React.PropTypes.func, 30 | isActive: React.PropTypes.bool 31 | }; 32 | 33 | export default AccountDetail; -------------------------------------------------------------------------------- /examples/client/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Button variants 3 | // 4 | @mixin button-variant($color, $background) { 5 | $active-background: lighten($background, 5%); 6 | color: $color !important; 7 | background: $background; 8 | 9 | &:hover, 10 | &:focus { 11 | color: $color !important; 12 | background-color: $active-background; 13 | } 14 | &:active { 15 | color: $color !important; 16 | background: darken($background, 2%); 17 | transition: none; 18 | } 19 | &.disabled, 20 | &:disabled { 21 | &:focus { 22 | background-color: $background; 23 | } 24 | } 25 | 26 | .icon { fill: $color; } 27 | } 28 | 29 | // Button sizes 30 | @mixin button-size($padding-y, $padding-x, $font-size, $line-height, $border-radius) { 31 | padding: $padding-y $padding-x; 32 | font-size: $font-size; 33 | line-height: $line-height; 34 | border-radius: $border-radius; 35 | } -------------------------------------------------------------------------------- /examples/client/scss/_account.scss: -------------------------------------------------------------------------------- 1 | .account-wrapper:first-child { 2 | border-top: 1px solid darken(aquamarine, 40%); 3 | } 4 | 5 | .list-row, 6 | .list-item { 7 | font-size: .9em; 8 | text-transform: uppercase; 9 | padding: 1em; 10 | border-bottom: 1px solid darken(aquamarine, 40%); 11 | color: lighten($fg-color, 30%); 12 | } 13 | 14 | .list-row { 15 | &:hover { 16 | background-color: lighten(aquamarine, 20%); 17 | cursor: pointer; 18 | } 19 | } 20 | 21 | .list-row.active { 22 | background: lighten(aquamarine, 10%); 23 | .list-row-name, 24 | .list-row-detail { 25 | color: #109; 26 | } 27 | } 28 | 29 | .list-row-name { 30 | font-weight: bold; 31 | } 32 | 33 | .list-row-detail { 34 | font-size: 0.8em; 35 | color: lighten($fg-color, 50%); 36 | } 37 | 38 | .list-row-name, 39 | .list-row-detail { 40 | text-overflow: ellipsis; 41 | overflow: hidden; 42 | color: darken(aquamarine, 50%) 43 | } -------------------------------------------------------------------------------- /compose/examples-frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:6 2 | 3 | RUN mkdir -p /usr/src/app 4 | WORKDIR /usr/src/app 5 | 6 | COPY examples /usr/src/app/examples 7 | 8 | # Adds fs-extra to npm and replaces the fs.rename method with the fs.extra 9 | # move method that now automatic chooses what to do (rename/move). 10 | # See https://github.com/npm/npm/issues/9863. 11 | RUN cd $(npm root -g)/npm \ 12 | && npm install fs-extra \ 13 | && sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs\.move/ ./lib/utils/rename.js 14 | 15 | COPY drivers/javascript /usr/src/app/drivers/javascript 16 | 17 | WORKDIR /usr/src/app/drivers/javascript 18 | 19 | RUN npm install 20 | RUN npm link 21 | 22 | WORKDIR /usr/src/app/examples/client 23 | 24 | # On some platforms, the .dockerignore file is being ignored in some versions of docker-compose 25 | # See https://github.com/docker/compose/issues/1607. 26 | RUN rm -rf node_modules 27 | 28 | RUN npm link js-bigchaindb-quickstart 29 | 30 | RUN npm install 31 | -------------------------------------------------------------------------------- /examples/client/js/react/sources/block_source.js: -------------------------------------------------------------------------------- 1 | import * as driver from 'js-bigchaindb-quickstart'; 2 | 3 | import { API_PATH } from '../../constants/application_constants'; 4 | 5 | import BlockActions from '../actions/block_actions'; 6 | 7 | 8 | const BlockSource = { 9 | lookupBlockList: { 10 | remote(state) { 11 | const {tx_id, status} = state.blockMeta; 12 | // fetch blocks for transaction 13 | return driver.Connection.listBlocks({tx_id, status}, API_PATH); 14 | }, 15 | 16 | success: BlockActions.successFetchBlockList, 17 | error: BlockActions.errorBlock 18 | }, 19 | 20 | lookupBlock: { 21 | remote(state) { 22 | const { block_id } = state.blockMeta; 23 | return driver.Connection.getBlock(block_id, API_PATH) 24 | }, 25 | 26 | success: BlockActions.successFetchBlock, 27 | error: BlockActions.errorBlock 28 | }, 29 | }; 30 | 31 | export default BlockSource; 32 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeEd25519Condition.js: -------------------------------------------------------------------------------- 1 | import { Buffer } from 'buffer'; 2 | 3 | import base58 from 'bs58'; 4 | import cc from 'five-bells-condition'; 5 | 6 | import ccJsonify from './utils/ccJsonify'; 7 | 8 | 9 | /** 10 | * @public 11 | * Create an Ed25519 Cryptocondition from an Ed25519 public key to put into an Output of a Transaction 12 | * @param {string} publicKey base58 encoded Ed25519 public key for the recipient of the Transaction 13 | * @param {boolean} [json=true] If true returns a json object otherwise a crypto-condition type 14 | * @returns {object} Ed25519 Condition (that will need to wrapped in an Output) 15 | */ 16 | export default function makeEd25519Condition(publicKey, json=true) { 17 | const publicKeyBuffer = new Buffer(base58.decode(publicKey)); 18 | 19 | const ed25519Fulfillment = new cc.Ed25519(); 20 | ed25519Fulfillment.setPublicKey(publicKeyBuffer); 21 | 22 | if (json) { 23 | return ccJsonify(ed25519Fulfillment) 24 | } 25 | 26 | return ed25519Fulfillment; 27 | } 28 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/test/MobileEnergy.js: -------------------------------------------------------------------------------- 1 | var MobileEnergy = artifacts.require('./MobileEnergy.sol'); 2 | 3 | contract('MobileEnergy', function(accounts) { 4 | const oracleAddress = accounts[0]; 5 | const sellerAddress = accounts[1]; 6 | const buyerAddress = accounts[2]; 7 | 8 | it('should work',function() { 9 | return MobileEnergy.deployed() 10 | .then(function(instance) { 11 | return instance.publishOffer(100, 15, {from: sellerAddress}) 12 | .then(function() { 13 | return instance.acceptOffer(sellerAddress, {from: buyerAddress}) 14 | }) 15 | .then(function(tx) { 16 | assert.equal('NewContract', tx.logs[0].event); 17 | return instance.close(tx.logs[0].args.hash, 12345, 12345678, {from: oracleAddress}) 18 | }) 19 | .then(function(tx) { 20 | assert.equal('NewInvoice', tx.logs[0].event); 21 | return instance.withdraw(tx.logs[0].args.hash, {from: sellerAddress}) 22 | }); 23 | }); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /drivers/python/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | # bigchaindb configuration 62 | .bigchaindb 63 | -------------------------------------------------------------------------------- /drivers/python/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | bdb-driver: 5 | build: 6 | context: . 7 | dockerfile: ./compose/driver/Dockerfile 8 | volumes: 9 | - ./docs:/usr/src/app/docs 10 | - ./tests:/usr/src/app/tests 11 | - ./bigchaindb_driver:/usr/src/app/bigchaindb_driver 12 | - ./setup.py:/usr/src/app/setup.py 13 | - ./tox.ini:/usr/src/app/tox.ini 14 | environment: 15 | BDB_HOST: bdb-server 16 | BIGCHAINDB_KEYPAIR_PUBLIC: GW1nrdZm4mbVC8ePeiGWz6DqHexqewqy5teURVHi3RG4 17 | command: pytest -v 18 | rdb: 19 | image: rethinkdb 20 | ports: 21 | - "58585:8080" 22 | - "28015" 23 | bdb-server: 24 | build: ./compose/server 25 | environment: 26 | BIGCHAINDB_DATABASE_HOST: rdb 27 | BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984 28 | BIGCHAINDB_KEYPAIR_PUBLIC: GW1nrdZm4mbVC8ePeiGWz6DqHexqewqy5teURVHi3RG4 29 | BIGCHAINDB_KEYPAIR_PRIVATE: 2kQgBtQnHoauw8QchKM7xYvEBW1QDoHzhBsCL9Vi1AzB 30 | ports: 31 | - "9984" 32 | command: bigchaindb start 33 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeThresholdCondition.js: -------------------------------------------------------------------------------- 1 | import cc from 'five-bells-condition'; 2 | 3 | import ccJsonify from './utils/ccJsonify'; 4 | 5 | 6 | /** 7 | * @public 8 | * Create an Sha256 Threshold Cryptocondition from threshold to put into an Output of a Transaction 9 | * @param {number} threshold 10 | * @param {Array} [subconditions=[]] 11 | * @param {boolean} [json=true] If true returns a json object otherwise a crypto-condition type 12 | * @returns {object} Sha256 Threshold Condition (that will need to wrapped in an Output) 13 | */ 14 | export default function makeThresholdCondition(threshold, subconditions=[], json=true) { 15 | const thresholdCondition = new cc.ThresholdSha256(); 16 | thresholdCondition.threshold = threshold; 17 | 18 | subconditions.forEach((subcondition) => { 19 | // TODO: add support for Condition and URIs 20 | thresholdCondition.addSubfulfillment(subcondition); 21 | }); 22 | 23 | if (json) { 24 | return ccJsonify(thresholdCondition) 25 | } 26 | 27 | return thresholdCondition 28 | } 29 | -------------------------------------------------------------------------------- /drivers/javascript/dist/node/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: true 5 | }); 6 | exports.Connection = exports.Transaction = exports.Ed25519Keypair = undefined; 7 | 8 | var _Ed25519Keypair2 = require('./Ed25519Keypair'); 9 | 10 | var _Ed25519Keypair3 = _interopRequireDefault(_Ed25519Keypair2); 11 | 12 | var _transaction = require('./transaction'); 13 | 14 | var _Transaction = _interopRequireWildcard(_transaction); 15 | 16 | var _connection = require('./connection'); 17 | 18 | var _Connection = _interopRequireWildcard(_connection); 19 | 20 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } 21 | 22 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23 | 24 | exports.Ed25519Keypair = _Ed25519Keypair3.default; 25 | exports.Transaction = _Transaction; 26 | exports.Connection = _Connection; -------------------------------------------------------------------------------- /drivers/javascript/src/Ed25519Keypair.js: -------------------------------------------------------------------------------- 1 | import base58 from 'bs58'; 2 | import nacl from 'tweetnacl'; 3 | import sha3 from 'js-sha3'; 4 | 5 | /** 6 | * @public 7 | * @class Keypair Ed25519 keypair in base58 (as BigchainDB expects base58 keys) 8 | * @type {Object} 9 | * @param {number} [secret] A seed that will be used as a key derivation function 10 | * @property {string} publicKey 11 | * @property {string} privateKey 12 | */ 13 | export default function Ed25519Keypair(secret) { 14 | let keyPair; 15 | if (secret) { 16 | // Quick and dirty: use key derivation function instead 17 | const secretHash = sha3.sha3_256 18 | .create() 19 | .update(secret) 20 | .array(); 21 | keyPair = nacl.sign.keyPair.fromSeed(new Uint8Array(secretHash)) 22 | } else { 23 | keyPair = nacl.sign.keyPair(); 24 | } 25 | this.publicKey = base58.encode(keyPair.publicKey); 26 | // tweetnacl's generated secret key is the secret key + public key (resulting in a 64-byte buffer) 27 | this.privateKey = base58.encode(keyPair.secretKey.slice(0, 32)); 28 | } 29 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/iot/mock_data_sharge.py: -------------------------------------------------------------------------------- 1 | # time, id_plug, id_mobile, door_control, plugged, charge_control 2 | import random 3 | 4 | import pprint 5 | from bigchaindb_driver.crypto import generate_keypair 6 | from bigchaindb.common.utils import gen_timestamp 7 | 8 | 9 | def generate_mock_data(): 10 | mobile = generate_keypair() 11 | plug = generate_keypair() 12 | 13 | now = int(gen_timestamp()) 14 | data = [] 15 | 16 | num_samples = 6 17 | for i in range(num_samples+1): 18 | door_control = 1 if i in [0, num_samples] else 0 19 | plugged = 0 if i in [0, num_samples] else 1 20 | charge_control = random.randint(2, 10) 21 | 22 | data.append({ 23 | 'id_plug': plug.public_key, 24 | 'id_mobile': mobile.public_key, 25 | 'time': str(now + i*60), 26 | 'door_control': str(door_control), 27 | 'plugged': str(plugged), 28 | 'charge_control_kw': str(charge_control) 29 | }) 30 | pprint.pprint(data) 31 | 32 | return data, plug, mobile 33 | 34 | if __name__ == '__main__': 35 | generate_mock_data() -------------------------------------------------------------------------------- /drivers/javascript/src/connection/pollStatusAndFetchTransaction.js: -------------------------------------------------------------------------------- 1 | import getTransaction from './getTransaction'; 2 | import getStatus from './getStatus'; 3 | 4 | /** 5 | * @public 6 | * @param tx_id 7 | * @param API_PATH 8 | * @return {Promise} 9 | */ 10 | export default function (tx_id, API_PATH) { 11 | return new Promise((resolve, reject) => { 12 | const timer = setInterval(() => { 13 | getStatus(tx_id, API_PATH) 14 | .then((res) => { 15 | console.log('Fetched transaction status:', res); 16 | if (res.status === 'valid') { 17 | clearInterval(timer); 18 | getTransaction(tx_id, API_PATH) 19 | .then((res) => { 20 | console.log('Fetched transaction:', res); 21 | resolve(res); 22 | }); 23 | } 24 | }) 25 | .catch((err) => { 26 | clearInterval(timer); 27 | reject(err); 28 | }); 29 | }, 500) 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /examples/client/scss/_sidebar.scss: -------------------------------------------------------------------------------- 1 | #wrapper { 2 | padding-left: $sidebar--wide; 3 | transition: all 0.4s ease 0s; 4 | margin-top: $navbar-height; 5 | } 6 | 7 | #sidebar-wrapper { 8 | margin-left: -$sidebar--wide; 9 | left: $sidebar--wide; 10 | width: $sidebar--wide; 11 | height: 100%; 12 | overflow-y: auto; 13 | z-index: 900; 14 | transition: all 0.4s ease 0s; 15 | } 16 | 17 | .sidebar-nav { 18 | position: fixed; 19 | top: $navbar-height; 20 | width: $sidebar--wide; 21 | margin: 0; 22 | padding: 2em 0; 23 | z-index: 1100; 24 | height: 100vh; 25 | border-right: 2px solid darken(aquamarine, 40%); 26 | ul { 27 | list-style: none; 28 | padding: 0; 29 | } 30 | .dropdown-menu { 31 | overflow-y: scroll; 32 | max-height: 50vh; 33 | } 34 | 35 | } 36 | 37 | @media (max-width: 930px) { 38 | 39 | #wrapper { 40 | padding-left: 0; 41 | } 42 | 43 | #sidebar-wrapper { 44 | left: 0; 45 | } 46 | 47 | #wrapper.active { 48 | position: relative; 49 | left: $sidebar--wide; 50 | } 51 | 52 | #wrapper.active #sidebar-wrapper { 53 | left: $sidebar--wide; 54 | width: $sidebar--wide; 55 | transition: all 0.4s ease 0s; 56 | } 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /examples/docs/source/sharetrader.rst: -------------------------------------------------------------------------------- 1 | .. _sharetrader: 2 | 3 | Share Trader 4 | ============ 5 | 6 | Share Trader is a simple share allocation and trade app. Each square represents 7 | an asset that can be traded amongst accounts. 8 | 9 | .. image:: /_static/sharetrader.png 10 | 11 | 12 | Use cases 13 | --------- 14 | 15 | - Reservation of tickets, seats in a concert/transport, ... 16 | - Trade of limited issued assets 17 | 18 | Functionality 19 | ------------- 20 | 21 | Create assets 22 | ^^^^^^^^^^^^^ 23 | 24 | - Assets are created following a structured payload 25 | - The amount is limited 26 | 27 | Transfer assets 28 | ^^^^^^^^^^^^^^^ 29 | 30 | - Easy transfer of assets between accounts by: 31 | - Clicking on an account first. This will give the assets for that account 32 | - Clicking on an asset of that account. Transfer actions will appear on the 33 | right side. 34 | 35 | Retrieve assets 36 | ^^^^^^^^^^^^^^^ 37 | 38 | - That you currently own (like UTXO's) 39 | - All assets on bigchain 40 | - State indicator (blinks if asset has various owners) 41 | 42 | What this app doesn't provide 43 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | - Proper user and key management 45 | - Proper signing of transfers 46 | - Proper search by payload 47 | -------------------------------------------------------------------------------- /examples/client/js/react/components/spinner.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import classNames from 'classnames'; 3 | 4 | 5 | const Spinner = React.createClass({ 6 | propTypes: { 7 | classNames: React.PropTypes.string, 8 | color: React.PropTypes.oneOf( 9 | ['black', 'blue', 'dark-blue', 'light-blue', 'pink', 'white', 'loop'] 10 | ), 11 | size: React.PropTypes.oneOf( 12 | ['sm', 'md', 'lg'] 13 | ) 14 | }, 15 | 16 | getDefaultProps() { 17 | return { 18 | inline: false, 19 | size: 'md', 20 | color: 'black' 21 | }; 22 | }, 23 | 24 | render() { 25 | const { 26 | classNames: classes, 27 | color, 28 | size 29 | } = this.props; 30 | 31 | return ( 32 |
36 |
37 |
A
38 |
39 | ); 40 | } 41 | }); 42 | 43 | export default Spinner; 44 | -------------------------------------------------------------------------------- /examples/client/js/react/stores/vote_store.js: -------------------------------------------------------------------------------- 1 | import alt from '../alt'; 2 | 3 | import VoteActions from '../actions/vote_actions'; 4 | import VoteSource from '../sources/vote_source'; 5 | 6 | class VoteStore { 7 | constructor() { 8 | this.voteMap = {}; 9 | this.voteMeta = { 10 | block_id: null, 11 | err: null, 12 | }; 13 | this.bindActions(VoteActions); 14 | this.registerAsync(VoteSource); 15 | } 16 | 17 | onFetchVoteList(blockId) { 18 | this.voteMeta.block_id = blockId; 19 | this.getInstance().lookupVoteList(); 20 | } 21 | 22 | onSuccessFetchVoteList(voteList) { 23 | if (voteList) { 24 | const { block_id } = this.voteMeta; 25 | this.voteMap[block_id] = voteList; 26 | this.voteMeta.err = null; 27 | this.voteMeta.block_id = null; 28 | } else { 29 | this.voteMeta.err = new Error('Problem fetching the vote list'); 30 | } 31 | } 32 | 33 | onFlushVoteList() { 34 | this.voteMap = []; 35 | this.voteMeta.block_id = null; 36 | } 37 | 38 | 39 | onErrorVoteList(err) { 40 | this.voteMeta.err = err; 41 | } 42 | } 43 | 44 | export default alt.createStore(VoteStore, 'VoteStore'); 45 | -------------------------------------------------------------------------------- /examples/client/scss/_menu.scss: -------------------------------------------------------------------------------- 1 | .menu { 2 | background: rgba($brand-main-blue-dark, .75); 3 | backdrop-filter: saturate(150%) blur(10px); 4 | padding-left: 2rem; 5 | padding-right: 2rem; 6 | display: flex; 7 | align-items: center; 8 | justify-content: space-between; 9 | 10 | position: fixed; 11 | width: 100%; 12 | z-index: 1; 13 | min-height: $menu-height; 14 | 15 | .logo { 16 | @extend .logo--sm, .logo--white--green; 17 | } 18 | } 19 | 20 | .menu__link, 21 | .menu .logo, 22 | .menu__title { 23 | flex-basis: (100%/3); 24 | } 25 | 26 | .menu__link, 27 | .menu__title { 28 | font-size: $font-size-sm; 29 | } 30 | 31 | .menu .logo { 32 | @extend .logo--sm; 33 | margin-right: -$spacer; 34 | } 35 | 36 | .menu__link { 37 | padding-top: .5rem; 38 | padding-bottom: .5rem; 39 | display: inline-block; 40 | transition: .2s ease-out; 41 | opacity: .8; 42 | 43 | .icon { 44 | stroke-width: 2; 45 | width: $font-size-xs; 46 | height: $font-size-xs; 47 | margin-right: $spacer / 4; 48 | } 49 | } 50 | 51 | .menu__link:hover { 52 | opacity: 1; 53 | } 54 | 55 | .menu__title { 56 | @extend .h4; 57 | margin: 0; 58 | color: #fff; 59 | text-align: right; 60 | } -------------------------------------------------------------------------------- /examples/client/scss/_modal.scss: -------------------------------------------------------------------------------- 1 | .ReactModal__Body--open { 2 | overflow: hidden; 3 | } 4 | 5 | .modal__overlay { 6 | @extend .transition; 7 | position: fixed; 8 | left: 0; right: 0; top: 0; bottom: 0; 9 | padding-top: $menu-height + $spacer; 10 | padding-bottom: $spacer * 2; 11 | background: rgba($brand-main-gray, .6); 12 | backdrop-filter: blur(3px); 13 | overflow-x: hidden; 14 | overflow-y: auto; 15 | -webkit-overflow-scrolling: touch; 16 | 17 | display: flex; 18 | align-items: center; 19 | justify-content: center; 20 | } 21 | 22 | .modal__content { 23 | @extend .animation-slide-in-from-bottom; 24 | margin: auto $spacer * 2; 25 | padding: $spacer; 26 | max-width: 100%; 27 | background: $brand-main-gray-light; 28 | border: 1px solid darken($brand-main-gray-light, 10%); 29 | border-radius: $border-radius; 30 | outline: 0; 31 | 32 | @media ($screen-sm) { 33 | max-width: $screen-sm-min; 34 | min-width: $screen-sm-min / 2; 35 | } 36 | 37 | // sledghammer overwrites for react-syntax-highlighter 38 | pre { 39 | max-height: none; 40 | background-color: $code-bg !important; 41 | margin-bottom: 0; 42 | padding: $spacer !important; 43 | } 44 | } -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | all: build init start 2 | 3 | build: 4 | docker-compose -f ledgers.yml build 5 | 6 | init: reinit_db config accounts assets 7 | 8 | start: 9 | docker-compose -f ledgers.yml up 10 | 11 | restart: init start 12 | 13 | config: 14 | rm -rf .bigchaindb_examples_docker .bigchaindb_examples_docker_connector 15 | touch .bigchaindb_examples_docker .bigchaindb_examples_docker_connector 16 | docker-compose -f ledgers.yml run --rm bdb-0 bigchaindb -yc .bigchaindb_examples configure 17 | docker-compose -f ledgers.yml run --rm bdb-0 bigchaindb -c .bigchaindb_examples init 18 | docker-compose -f ledgers.yml run --rm bdb-1 bigchaindb -yc .bigchaindb_examples configure 19 | docker-compose -f ledgers.yml run --rm bdb-1 bigchaindb -c .bigchaindb_examples init 20 | docker-compose -f ledgers.yml run --rm connector bigchaindb -yc .bigchaindb_examples configure 21 | 22 | accounts: 23 | docker-compose -f ledgers.yml run --rm bdb-0 python init_accounts.py 24 | 25 | assets: 26 | docker-compose -f ledgers.yml run --rm bdb-0 python init_assets.py 27 | 28 | 29 | drop_db: 30 | docker-compose -f ledgers.yml stop rdb 31 | docker-compose -f ledgers.yml rm -f rdb 32 | 33 | start_db: 34 | docker-compose -f ledgers.yml up -d rdb 35 | 36 | reinit_db: drop_db start_db 37 | sleep 10 38 | 39 | stop: 40 | docker-compose -f ledgers.yml down 41 | -------------------------------------------------------------------------------- /examples/docs/source/troubleshooting.rst: -------------------------------------------------------------------------------- 1 | Troubleshooting 2 | =============== 3 | 4 | Oops ¯\\\_(ツ)\_/¯ 5 | ------------------ 6 | 7 | My installation fails with: 8 | 9 | .. code-block:: bash 10 | 11 | error: Setup script exited with error in BigchainDB setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers 12 | 13 | * **Solution**: update the ``setuptools``, see `PR fix `_ 14 | 15 | 16 | OMG: I've messed up my database 17 | ------------------------------- 18 | 19 | * **Solution**: reset your bigchaindb_examples database 20 | * **Warning**: the following resets your bigchaindb database to its default initialized state! 21 | 22 | Via Docker 23 | ^^^^^^^^^^ 24 | 25 | .. code-block:: bash 26 | 27 | $ make init 28 | 29 | Or, to reinitialize and restart: 30 | 31 | .. code-block:: bash 32 | 33 | $ make restart 34 | 35 | 36 | Via the CLI 37 | ^^^^^^^^^^^ 38 | 39 | .. code-block:: bash 40 | 41 | $ bigchaindb-examples init --all 42 | 43 | Or, to reinitialize and restart: 44 | 45 | .. code-block:: bash 46 | 47 | $ bigchaindb-examples start --init --all 48 | 49 | 50 | Manually 51 | ^^^^^^^^ 52 | 53 | Restart your RethinkDB instance and follow the initialization steps in 54 | :ref:`manual-setup`. 55 | -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 2; 2 | user nobody nogroup; 3 | pid /tmp/nginx.pid; 4 | error_log /nginx.error.log; 5 | 6 | events { 7 | worker_connections 256; 8 | accept_mutex on; 9 | use epoll; 10 | } 11 | 12 | http { 13 | server_names_hash_bucket_size 128; 14 | resolver 8.8.8.8 8.8.4.4; 15 | access_log /nginx.access.log combined; 16 | 17 | limit_req_zone $binary_remote_addr zone=one:10m rate=100r/s; 18 | limit_req_log_level notice; 19 | limit_req_status 429; 20 | 21 | server { 22 | listen 80; 23 | client_max_body_size 15k; 24 | keepalive_timeout 20s; 25 | client_body_timeout 10s; 26 | client_header_timeout 10s; 27 | 28 | location / { 29 | proxy_set_header Host $http_host; 30 | proxy_redirect off; 31 | proxy_pass http://bdb-server:9984; 32 | limit_req zone=one burst=200 nodelay; 33 | } 34 | 35 | location ^~ /api/v1/ { 36 | proxy_set_header Host $http_host; 37 | proxy_redirect off; 38 | proxy_pass http://bdb-server:9984; 39 | limit_req zone=one burst=200 nodelay; 40 | } 41 | 42 | location ^~ /api/kyber/ { 43 | proxy_set_header Host $http_host; 44 | proxy_redirect off; 45 | proxy_pass http://bdb-server-kyber:9985; 46 | limit_req zone=one burst=200 nodelay; 47 | } 48 | 49 | error_page 500 502 503 504 /50x.html; 50 | location = /50x.html { 51 | root /usr/local/openresty/nginx/html/50x.html; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | venv/ 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | node_modules 20 | rethinkdb_data 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | bundles/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | .env 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | .hypothesis/ 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | local_settings.py 59 | 60 | # Sphinx documentation 61 | docs/build/ 62 | 63 | # PyBuilder 64 | target/ 65 | 66 | # Ipython Notebook 67 | .ipynb_checkpoints 68 | 69 | # pyenv 70 | .python-version 71 | 72 | # Private key files from AWS 73 | *.pem 74 | 75 | # Some files created when deploying a cluster on AWS 76 | deploy-cluster-aws/conf/rethinkdb.conf 77 | deploy-cluster-aws/hostlist.py 78 | 79 | # bigchaindb-examples 80 | .bigchaindb* 81 | .bigchaindb_examples 82 | server/static/ 83 | -------------------------------------------------------------------------------- /drivers/javascript/src/request.js: -------------------------------------------------------------------------------- 1 | import baseRequest from './baseRequest'; 2 | import sanitize from './sanitize'; 3 | 4 | 5 | const DEFAULT_REQUEST_CONFIG = { 6 | credentials: 'include', 7 | headers: { 8 | 'Accept': 'application/json' 9 | } 10 | }; 11 | 12 | /** 13 | * Small wrapper around js-utility-belt's request that provides url resolving, default settings, and 14 | * response handling. 15 | */ 16 | export default function request(url, config = {}, onlyJsonResponse=true) { 17 | // Load default fetch configuration and remove any falsy query parameters 18 | const requestConfig = Object.assign({}, DEFAULT_REQUEST_CONFIG, config, { 19 | query: config.query && sanitize(config.query) 20 | }); 21 | let apiUrl = url; 22 | 23 | if (requestConfig.jsonBody) { 24 | requestConfig.headers = Object.assign({}, requestConfig.headers, { 25 | 'Content-Type': 'application/json' 26 | }); 27 | } 28 | if (!url) { 29 | return Promise.reject(new Error('Request was not given a url.')); 30 | } 31 | 32 | return baseRequest(apiUrl, requestConfig) 33 | .then((res) => { 34 | return onlyJsonResponse ? res.json() : 35 | { 36 | json: res.json(), 37 | url: res.url 38 | }; 39 | }) 40 | .catch((err) => { 41 | console.error(err); 42 | throw err; 43 | }); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .idea/ 11 | .Python 12 | env/ 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | node_modules/ 27 | yarn.lock 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .coverage 43 | .coverage.* 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | *,cover 48 | .hypothesis/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | 58 | # Flask stuff: 59 | instance/ 60 | .webassets-cache 61 | 62 | # Scrapy stuff: 63 | .scrapy 64 | 65 | # Sphinx documentation 66 | docs/_build/ 67 | 68 | # PyBuilder 69 | target/ 70 | 71 | # IPython Notebook 72 | .ipynb_checkpoints 73 | 74 | # pyenv 75 | .python-version 76 | 77 | # celery beat schedule file 78 | celerybeat-schedule 79 | 80 | # dotenv 81 | .env 82 | 83 | # virtualenv 84 | venv/ 85 | ENV/ 86 | 87 | # Spyder project settings 88 | .spyderproject 89 | 90 | # Rope project settings 91 | .ropeproject 92 | -------------------------------------------------------------------------------- /examples/client/js/utils/bigchaindb/transactions.js: -------------------------------------------------------------------------------- 1 | 2 | export function getAssetIdFromTransaction(transaction){ 3 | let asset_id; 4 | if (transaction && transaction.asset) { 5 | if (transaction.asset.id) { 6 | asset_id = transaction.asset.id; 7 | } else { 8 | asset_id = transaction.id; 9 | } 10 | } 11 | return asset_id; 12 | } 13 | 14 | export function resolveAssetFromTransaction(transaction){ 15 | // if create, return asset 16 | // if transfer, fetch asset and return 17 | } 18 | 19 | export function transactionContains(transaction, value){ 20 | 21 | } 22 | 23 | export function assetContains(asset, value){ 24 | 25 | } 26 | 27 | export function metadataContains(metadata, value){ 28 | 29 | } 30 | 31 | export function outputListContains(outputList, field, value){ 32 | const result = outputList.map((output) => { 33 | if (outputContains(output, field, value)) { 34 | return true; 35 | } 36 | }); 37 | return result.length > 0; 38 | } 39 | 40 | export function outputContains(output, field, value) { 41 | if (!output || !value || !field) return false; 42 | if (field == 'public_keys' && output.public_keys.indexOf(value) > -1) return true; 43 | if (field == 'amount' && output.amount === value) return true; 44 | return false; 45 | } 46 | 47 | 48 | export function inputListContains(inputList, value){ 49 | 50 | } 51 | 52 | export function inputContains(input, value){ 53 | 54 | } -------------------------------------------------------------------------------- /drivers/javascript/utils/request.js: -------------------------------------------------------------------------------- 1 | import { request as baseRequest, sanitize } from 'js-utility-belt/es6'; 2 | 3 | import ApiUrls from '../constants/api_urls'; 4 | 5 | 6 | const DEFAULT_REQUEST_CONFIG = { 7 | credentials: 'include', 8 | headers: { 9 | 'Accept': 'application/json' 10 | } 11 | }; 12 | 13 | /** 14 | * Small wrapper around js-utility-belt's request that provides url resolving, default settings, and 15 | * response handling. 16 | */ 17 | export default function request(url, config = {}) { 18 | // Load default fetch configuration and remove any falsy query parameters 19 | const requestConfig = Object.assign({}, DEFAULT_REQUEST_CONFIG, config, { 20 | query: config.query && sanitize(config.query) 21 | }); 22 | let apiUrl = url; 23 | 24 | if (requestConfig.jsonBody) { 25 | requestConfig.headers = Object.assign({}, requestConfig.headers, { 26 | 'Content-Type': 'application/json' 27 | }); 28 | } 29 | if (!url) { 30 | return Promise.reject(new Error('Request was not given a url.')); 31 | } else if (!url.match(/^http/)) { 32 | apiUrl = ApiUrls[url]; 33 | if (!apiUrl) { 34 | return Promise.reject(new Error(`Request could not find a url mapping for "${url}"`)); 35 | } 36 | } 37 | 38 | return baseRequest(apiUrl, requestConfig) 39 | .then((res) => res.json()) 40 | .catch((err) => { 41 | console.error(err); 42 | throw err; 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /examples/client/js/utils/request.js: -------------------------------------------------------------------------------- 1 | import { request as baseRequest, sanitize } from 'js-utility-belt/es6'; 2 | 3 | import ApiUrls from '../constants/api_urls'; 4 | 5 | 6 | const DEFAULT_REQUEST_CONFIG = { 7 | credentials: 'include', 8 | headers: { 9 | 'Accept': 'application/json' 10 | } 11 | }; 12 | 13 | /** 14 | * Small wrapper around js-utility-belt's request that provides url resolving, default settings, and 15 | * response handling. 16 | */ 17 | export default function request(url, config = {}) { 18 | // Load default fetch configuration and remove any falsy query parameters 19 | const requestConfig = Object.assign({}, DEFAULT_REQUEST_CONFIG, config, { 20 | query: config.query && sanitize(config.query) 21 | }); 22 | let apiUrl = url; 23 | 24 | if (requestConfig.jsonBody) { 25 | requestConfig.headers = Object.assign({}, requestConfig.headers, { 26 | 'Content-Type': 'application/json' 27 | }); 28 | } 29 | if (!url) { 30 | return Promise.reject(new Error('Request was not given a url.')); 31 | } else if (!url.match(/^http/)) { 32 | apiUrl = ApiUrls[url]; 33 | if (!apiUrl) { 34 | return Promise.reject(new Error(`Request could not find a url mapping for "${url}"`)); 35 | } 36 | } 37 | 38 | return baseRequest(apiUrl, requestConfig) 39 | .then((res) => res.json()) 40 | .catch((err) => { 41 | console.error(err); 42 | throw err; 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /examples/docs/source/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import sphinx_rtd_theme 5 | 6 | 7 | extensions = [ 8 | 'sphinx.ext.autodoc', 9 | 'sphinx.ext.doctest', 10 | 'sphinx.ext.intersphinx', 11 | 'sphinx.ext.todo', 12 | 'sphinx.ext.coverage', 13 | 'sphinx.ext.viewcode', 14 | 'sphinx.ext.napoleon', 15 | ] 16 | 17 | templates_path = ['_templates'] 18 | source_suffix = '.rst' 19 | master_doc = 'index' 20 | project = 'BigchainDB Examples' 21 | copyright = '2016, BigchainDB Contributors' 22 | author = 'BigchainDB Contributors' 23 | version = '0.0.2' 24 | release = '0.0.2' 25 | language = None 26 | exclude_patterns = [] 27 | pygments_style = 'sphinx' 28 | todo_include_todos = True 29 | html_theme = 'sphinx_rtd_theme' 30 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 31 | html_static_path = ['_static'] 32 | htmlhelp_basename = 'BigchainDBExamplesdoc' 33 | 34 | latex_elements = {} 35 | latex_documents = [ 36 | (master_doc, 'BigchainDBExamples.tex', 'BigchainDB Examples Documentation', 37 | 'BigchainDB Contributors', 'manual'), 38 | ] 39 | 40 | man_pages = [ 41 | (master_doc, 'bigchaindbexamples', 'BigchainDB Examples Documentation', 42 | [author], 1) 43 | ] 44 | 45 | texinfo_documents = [ 46 | (master_doc, 'BigchainDBExamples', 'BigchainDB Examples Documentation', 47 | author, 'BigchainDBExamples', 'One line description of project.', 48 | 'Miscellaneous'), 49 | ] 50 | 51 | intersphinx_mapping = {'https://docs.python.org/': None} 52 | -------------------------------------------------------------------------------- /examples/docs/source/docs.rst: -------------------------------------------------------------------------------- 1 | About this Documentation 2 | ======================== 3 | 4 | This section contains instructions to build and view the documentation locally, 5 | using the ``docs.yml`` file of the `bigchaindb-examples`_ repository. 6 | 7 | If you do not have a clone of the repo, you need to get one. 8 | 9 | 10 | Building the documentation 11 | -------------------------- 12 | To build the docs, simply run 13 | 14 | .. code-block:: bash 15 | 16 | $ docker-compose -f docs.yml up bdocs 17 | 18 | Or if you prefer, start a ``bash`` session, 19 | 20 | .. code-block:: bash 21 | 22 | $ docker-compose -f docs.yml run --rm bdocs bash 23 | 24 | and build the docs: 25 | 26 | .. code-block:: bash 27 | 28 | root@a651959a1f2d:/usr/src/app/docs# make html 29 | 30 | 31 | Viewing the documentation 32 | ------------------------- 33 | You can start a little web server to view the docs at http://localhost:41234/ 34 | 35 | .. code-block:: bash 36 | 37 | $ docker-compose -f docs.yml up -d vdocs 38 | 39 | .. note:: If you are using ``docker-machine`` you need to replace ``localhost`` 40 | with the ``ip`` of the machine (e.g.: ``docker-machine ip tm`` if your 41 | machine is named ``tm``). 42 | 43 | 44 | Making changes 45 | -------------- 46 | The necessary source code is mounted, which allows you to make modifications, 47 | and view the changes by simply re-building the docs, and refreshing the 48 | browser. 49 | 50 | 51 | .. _bigchaindb-examples: https://github.com/bigchaindb/bigchaindb-examples 52 | -------------------------------------------------------------------------------- /drivers/python/docs/aboutthedocs.rst: -------------------------------------------------------------------------------- 1 | About this Documentation 2 | ======================== 3 | 4 | This section contains instructions to build and view the documentation locally, 5 | using the ``docker-compose`` ``docs.yml`` file of the ``bigchaindb-driver`` 6 | repository: https://github.com/bigchaindb/bigchaindb-driver. 7 | 8 | If you do not have a clone of the repo, you need to get one. 9 | 10 | 11 | Building the documentation 12 | -------------------------- 13 | To build the docs, simply run 14 | 15 | .. code-block:: bash 16 | 17 | $ docker-compose --file docs.yml up -d bdocs 18 | 19 | Or if you prefer, start a ``bash`` session, 20 | 21 | .. code-block:: bash 22 | 23 | $ docker-compose --file docs.yml run --rm bdocs bash 24 | 25 | and build the docs: 26 | 27 | .. code-block:: bash 28 | 29 | root@a651959a1f2d:/usr/src/app# make -C docs html 30 | 31 | 32 | Viewing the documentation 33 | ------------------------- 34 | You can start a little web server to view the docs at http://localhost:55555/ 35 | 36 | .. code-block:: bash 37 | 38 | $ docker-compose --file docs.yml up -d vdocs 39 | 40 | .. note:: If you are using ``docker-machine`` you need to replace ``localhost`` 41 | with the ``ip`` of the machine (e.g.: ``docker-machine ip tm`` if your 42 | machine is named ``tm``). 43 | 44 | 45 | Making changes 46 | -------------- 47 | The necessary source code is mounted, which allows you to make modifications, 48 | and view the changes by simply re-building the docs, and refreshing the 49 | browser. 50 | -------------------------------------------------------------------------------- /drivers/javascript/src/stringify_as_query_param.js: -------------------------------------------------------------------------------- 1 | import coreObjectEntries from 'core-js/library/fn/object/entries'; 2 | import decamelize from 'decamelize'; 3 | import queryString from 'query-string'; 4 | 5 | 6 | /** 7 | * imported from https://github.com/bigchaindb/js-utility-belt/ 8 | * 9 | * Takes a key-value dictionary (ie. object) and converts it to a query-parameter string that you 10 | * can directly append into a URL. 11 | * 12 | * Extends queryString.stringify by allowing you to specify a `transform` function that will be 13 | * invoked on each of the dictionary's keys before being stringified into the query-parameter 14 | * string. 15 | * 16 | * By default `transform` is `decamelize`, so a dictionary of the form: 17 | * 18 | * { 19 | * page: 1, 20 | * pageSize: 10 21 | * } 22 | * 23 | * will be converted to a string like: 24 | * 25 | * ?page=1&page_size=10 26 | * 27 | * @param {object} obj Query params dictionary 28 | * @param {function} [transform=decamelize] Transform function for each of the param keys 29 | * @return {string} Query param string 30 | */ 31 | export default function stringifyAsQueryParam(obj, transform = decamelize) { 32 | if (!obj || typeof obj !== 'object' || !Object.keys(obj).length) { 33 | return ''; 34 | } 35 | 36 | const transformedKeysObj = coreObjectEntries(obj).reduce((paramsObj, [key, value]) => { 37 | paramsObj[transform(key)] = value; 38 | return paramsObj; 39 | }, {}); 40 | 41 | return `?${queryString.stringify(transformedKeysObj)}`; 42 | } -------------------------------------------------------------------------------- /drivers/python/bigchaindb_driver/utils.py: -------------------------------------------------------------------------------- 1 | """Set of utilities to support various functionalities of the driver. 2 | 3 | Attributes: 4 | ops_map (dict): Mapping between operation strings and classes. 5 | E.g.: The string ``'CREATE'`` is mapped to 6 | :class:`~.CreateOperation`. 7 | """ 8 | 9 | 10 | class CreateOperation: 11 | """Class representing the ``'CREATE'`` transaction operation.""" 12 | 13 | 14 | class TransferOperation: 15 | """Class representing the ``'TRANSFER'`` transaction operation.""" 16 | 17 | 18 | ops_map = { 19 | 'CREATE': CreateOperation, 20 | 'TRANSFER': TransferOperation, 21 | } 22 | 23 | 24 | def _normalize_operation(operation): 25 | """ 26 | Normalizes the given operation string. For now, this simply means 27 | converting the given string to uppercase, looking it up in 28 | :attr:`~.ops_map`, and returning the corresponding class if 29 | present. 30 | 31 | Args: 32 | operation (str): The operation string to convert. 33 | 34 | Returns: 35 | The class corresponding to the given string, 36 | :class:`~.CreateOperation` or :class:`~TransferOperation`. 37 | 38 | .. important:: If the :meth:`str.upper` step, or the 39 | :attr:`~.ops_map` lookup fails, the given ``operation`` 40 | argument is returned. 41 | 42 | """ 43 | try: 44 | operation = operation.upper() 45 | except AttributeError: 46 | pass 47 | 48 | try: 49 | operation = ops_map[operation]() 50 | except KeyError: 51 | pass 52 | 53 | return operation 54 | -------------------------------------------------------------------------------- /examples/client/interledger/scss/custom_style.scss: -------------------------------------------------------------------------------- 1 | @import "../../scss/variables"; 2 | 3 | .app--interledger { 4 | 5 | .asset-container { 6 | border: 1px solid lighten($fg-color, 70%); 7 | box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2); 8 | margin-top: 1em; 9 | 10 | &:hover { 11 | border: 1px solid $ascribe-pink; 12 | cursor: pointer; 13 | } 14 | 15 | &.inBacklog { 16 | background: rgba(black, .05); 17 | &:hover { 18 | border: 1px solid lighten($ascribe-pink, 50%); 19 | cursor: default; 20 | } 21 | } 22 | } 23 | 24 | .asset-container-actions { 25 | margin-top: 1.7em 26 | } 27 | 28 | .asset-container-id { 29 | color: lighten($fg-color, 50%); 30 | } 31 | 32 | .asset-escrow-details { 33 | color: rgba(black, 0.8); 34 | font-size: 0.8em; 35 | font-style: italic; 36 | margin-bottom: -1em; 37 | margin-top: 1em; 38 | text-align: right; 39 | 40 | &.isExpired { 41 | color: rgba(red, 0.8); 42 | } 43 | } 44 | 45 | .card { 46 | overflow: visible; 47 | } 48 | 49 | .ledger-0 { 50 | color: darken($ascribe-blue, 10%); 51 | } 52 | .ledger-1 { 53 | color: $ascribe-pink; 54 | } 55 | .ledger-2 { 56 | color: $ascribe-dark-blue; 57 | } 58 | .ledger-3 { 59 | color: $ascribe-black; 60 | } 61 | 62 | #wrapper { 63 | margin-top: 80px; 64 | padding-left: 0 !important; 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /examples/client/scss/_card.scss: -------------------------------------------------------------------------------- 1 | .card { 2 | max-width: $row--wide; 3 | background: $bg-color; 4 | box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.4); 5 | padding: 20px 40px; 6 | margin: 0 auto 40px; 7 | overflow: hidden; 8 | 9 | .desc { 10 | font-size: 35px; 11 | line-height: 150%; 12 | margin: 0 0 25px 0; 13 | 14 | @media (max-width: 600px) { 15 | font-size: 20px; 16 | } 17 | 18 | strong { 19 | background-color: black; 20 | color: $fg-color; 21 | padding: 4px 20px; 22 | } 23 | } 24 | } 25 | 26 | .card--summary { 27 | .desc { 28 | float: left; 29 | width: 60%; 30 | @media (max-width: 600px) { 31 | float: none; 32 | width: 100%; 33 | display: block; 34 | margin-left: auto; 35 | margin-right: auto; 36 | } 37 | } 38 | 39 | .preview { 40 | margin-top: -10px; 41 | float: right; 42 | width: 30%; 43 | max-width: 400px; 44 | @media (max-width: 600px) { 45 | float: none; 46 | width: 100%; 47 | margin-bottom: 30px; 48 | } 49 | } 50 | } 51 | 52 | .card { 53 | .disclaimer { 54 | padding-top: 30px; 55 | text-align: right; 56 | font-size: 12px; 57 | } 58 | } 59 | 60 | .card--claim { 61 | box-shadow: none; 62 | background-color: transparent; 63 | .desc { 64 | font-size: 20px; 65 | text-align: center; 66 | a { 67 | color: inherit; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /examples/server/views/accounts.py: -------------------------------------------------------------------------------- 1 | """This module provides the blueprint for some basic API endpoints. 2 | 3 | For more information please refer to the documentation in Apiary: 4 | - http://docs.bigchaindb.apiary.io/ 5 | """ 6 | import flask 7 | from flask_restful import Resource, reqparse 8 | 9 | import bigchaindb 10 | from server.models import accounts 11 | 12 | 13 | bigchain = bigchaindb.Bigchain() 14 | 15 | 16 | class AccountListApi(Resource): 17 | def get(self): 18 | parser = reqparse.RequestParser() 19 | parser.add_argument('app', type=str, 20 | choices=('ontherecord', ), 21 | location='args', 22 | required=True) 23 | app = parser.parse_args()['app'] 24 | result = accounts.retrieve_accounts(bigchain, app) 25 | return flask.jsonify({ 26 | 'accounts': result 27 | }) 28 | 29 | 30 | class ConnectorListApi(Resource): 31 | def get(self): 32 | parser = reqparse.RequestParser() 33 | parser.add_argument('app', type=str, 34 | choices=('ontherecord',), 35 | location='args', 36 | required=True) 37 | parser.add_argument('ledger', type=int, 38 | location='args', 39 | required=True) 40 | app = parser.parse_args()['app'] 41 | ledger = parser.parse_args()['ledger'] 42 | result = accounts.get_connectors(bigchain, ledger, app) 43 | return flask.jsonify({ 44 | 'connectors': result 45 | }) 46 | -------------------------------------------------------------------------------- /examples/client/audio_lock/scss/_audiobar.scss: -------------------------------------------------------------------------------- 1 | 2 | $blue: lighten($brand-main-blue, 20%); 3 | $yellow: lighten($brand-warning, 20%); 4 | 5 | .audiobar { 6 | display: flex; 7 | width: 100%; 8 | height: $spacer * 4; 9 | margin-top: -($spacer * 2); 10 | position: relative; 11 | 12 | &:before { 13 | content: ""; 14 | display: block; 15 | position: absolute; 16 | left: 0; right: 0; 17 | bottom: 0; 18 | height: 1px; 19 | background: linear-gradient(to right, $blue, $yellow); 20 | z-index: -1; 21 | opacity: .8; 22 | } 23 | } 24 | 25 | .audiobar__step { 26 | @extend .transition; 27 | flex: 1; 28 | margin-left: 2%; 29 | cursor: pointer; 30 | opacity: .8; 31 | border-radius: 2px; 32 | transform-origin: bottom; 33 | 34 | &:nth-child(1) { background: $blue; margin-left: 0; } 35 | &:nth-child(2) { background: rgba($blue, .9); } 36 | &:nth-child(3) { background: rgba($blue, .8); } 37 | &:nth-child(4) { background: rgba($blue, .7); } 38 | &:nth-child(5) { background: rgba($blue, .6); } 39 | &:nth-child(6) { background: rgba($blue, .5); } 40 | &:nth-child(7) { background: rgba($yellow, .5); } 41 | &:nth-child(8) { background: rgba($yellow, .6); } 42 | &:nth-child(9) { background: rgba($yellow, .7); } 43 | &:nth-child(10) { background: rgba($yellow, .8); } 44 | &:nth-child(11) { background: rgba($yellow, .9); } 45 | &:nth-child(12) { background: $yellow; } 46 | 47 | &:hover, 48 | &.target { 49 | opacity: 1; 50 | } 51 | 52 | &.target { 53 | background: $brand-main-green; 54 | } 55 | } -------------------------------------------------------------------------------- /examples/server/server_flask.py: -------------------------------------------------------------------------------- 1 | """This module contains basic functions to instantiate the BigchainDB API. 2 | 3 | The application is implemented in Flask and runs using Gunicorn. 4 | """ 5 | import os 6 | 7 | from flask import Flask 8 | from flask.ext.cors import CORS 9 | 10 | from server.routes import add_routes 11 | 12 | 13 | def create_app(debug): 14 | """Return an instance of the Flask application. 15 | 16 | Args: 17 | debug (bool): a flag to activate the debug mode for the app 18 | (default: False). 19 | """ 20 | 21 | app = Flask(__name__) 22 | hostname = os.environ.get('DOCKER_MACHINE_IP', 'localhost') 23 | if not hostname: 24 | hostname = 'localhost' 25 | origins = ('^(https?://)?(www\.)?({}|0|0.0.0.0|dimi-bat.local|' 26 | 'localhost|127.0.0.1)(\.com)?:\d{{1,5}}$').format(hostname), 27 | CORS(app, 28 | origins=origins, 29 | headers=( 30 | 'x-requested-with', 31 | 'content-type', 32 | 'accept', 33 | 'origin', 34 | 'authorization', 35 | 'x-csrftoken', 36 | 'withcredentials', 37 | 'cache-control', 38 | 'cookie', 39 | 'session-id', 40 | ), 41 | supports_credentials=True, 42 | ) 43 | 44 | app.debug = debug 45 | 46 | add_routes(app) 47 | return app 48 | 49 | 50 | def run_flask_server(): 51 | app = create_app(debug=True) 52 | app.run(host=os.environ.get('FLASK_HOST', '127.0.0.1'), port=int(os.environ.get('FLASK_PORT', 8000))) 53 | app.run(use_reloader=False) 54 | 55 | if __name__ == '__main__': 56 | run_flask_server() 57 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/signTransaction.js: -------------------------------------------------------------------------------- 1 | import { Buffer } from 'buffer'; 2 | import base58 from 'bs58'; 3 | import cc from 'five-bells-condition'; 4 | import clone from 'clone'; 5 | 6 | import serializeTransactionIntoCanonicalString from './serializeTransactionIntoCanonicalString'; 7 | 8 | 9 | /** 10 | * @public 11 | * Sign the given `transaction` with the given `privateKey`s, returning a new copy of `transaction` 12 | * that's been signed. 13 | * Note: Only generates Ed25519 Fulfillments. Thresholds and other types of Fulfillments are left as 14 | * an exercise for the user. 15 | * @param {object} transaction Transaction to sign. `transaction` is not modified. 16 | * @param {...string} privateKeys Private keys associated with the issuers of the `transaction`. 17 | * Looped through to iteratively sign any Input Fulfillments found in 18 | * the `transaction`. 19 | * @returns {object} The signed version of `transaction`. 20 | */ 21 | export default function signTransaction(transaction, ...privateKeys) { 22 | const signedTx = clone(transaction); 23 | signedTx.inputs.forEach((input, index) => { 24 | const privateKey = privateKeys[index]; 25 | const privateKeyBuffer = new Buffer(base58.decode(privateKey)); 26 | const serializedTransaction = serializeTransactionIntoCanonicalString(transaction); 27 | const ed25519Fulfillment = new cc.Ed25519(); 28 | ed25519Fulfillment.sign(new Buffer(serializedTransaction), privateKeyBuffer); 29 | const fulfillmentUri = ed25519Fulfillment.serializeUri(); 30 | 31 | input.fulfillment = fulfillmentUri; 32 | }); 33 | 34 | return signedTx; 35 | } 36 | -------------------------------------------------------------------------------- /examples/client/audio_lock/scss/_assets.scss: -------------------------------------------------------------------------------- 1 | .assets { 2 | display: flex; 3 | flex-wrap: wrap; 4 | align-items: center; 5 | } 6 | 7 | .asset { 8 | flex: 0 0 100%; 9 | padding: $spacer; 10 | background: $brand-main-violet; 11 | color: #fff; 12 | border: 2px solid $body-bg; 13 | 14 | @media ($screen-sm) { 15 | flex: 0 1 (100% / 3); 16 | } 17 | 18 | &:hover, 19 | &:active { 20 | background: $gray; 21 | } 22 | 23 | .icon { 24 | stroke: #fff; 25 | stroke-width: .75; 26 | width: 3rem; 27 | height: 3rem; 28 | max-width: 100%; 29 | } 30 | } 31 | 32 | .asset--create { 33 | background: #fff; 34 | color: $brand-main-green; 35 | 36 | &:hover, 37 | &:active { 38 | background: $brand-main-green; 39 | color: $brand-main-gray-lighter; 40 | 41 | .icon { 42 | stroke: $brand-main-gray-lighter; 43 | } 44 | } 45 | 46 | .icon, 47 | .loader { 48 | stroke: $brand-main-green; 49 | width: 2.8rem; 50 | height: 2.8rem; 51 | } 52 | 53 | .asset__title { 54 | @extend .transition; 55 | font-size: $font-size-sm; 56 | } 57 | } 58 | 59 | .asset--create--loading { 60 | pointer-events: none; 61 | 62 | .asset__title { 63 | opacity: 0; 64 | } 65 | } 66 | 67 | .asset__title { 68 | font-size: $font-size-xs; 69 | display: block; 70 | margin: auto; 71 | 72 | // truncate text 73 | white-space: nowrap; 74 | overflow: hidden; 75 | text-overflow: ellipsis; 76 | width: 200px; 77 | 78 | @media ($screen-sm) { 79 | width: 130px; 80 | } 81 | } -------------------------------------------------------------------------------- /examples/client/demo/styles.css: -------------------------------------------------------------------------------- 1 | /* General styles */ 2 | html { 3 | font-size: 18px; 4 | -webkit-tap-highlight-color: transparent; 5 | } 6 | 7 | body { 8 | margin: 0; 9 | font-family: europa, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif; 10 | font-size: 1rem; 11 | font-weight: 400; 12 | line-height: 1.5; 13 | color: #CAD2DA; 14 | background-color: #445261; 15 | overflow-wrap: break-word; 16 | word-wrap: break-word; 17 | word-break: break-word; 18 | text-rendering: optimizeLegibility; 19 | -webkit-font-smoothing: antialiased; 20 | -moz-osx-font-smoothing: grayscale; 21 | -webkit-font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "pnum" 1, "tnum" 0, "onum" 0, "lnum" 0, "dlig" 1; 22 | font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "pnum" 1, "tnum" 0, "onum" 0, "lnum" 0, "dlig" 1 23 | } 24 | 25 | h1, h2, h3, h4, h5, h6 { 26 | font-weight: 300; 27 | font-family: inherit; 28 | line-height: 1.2; 29 | } 30 | 31 | h1, h2, h3 { 32 | margin-top: 2rem; 33 | margin-bottom: 2rem; 34 | } 35 | 36 | h1 { 37 | font-size: 2.7rem; 38 | } 39 | 40 | h2 { 41 | font-size: 2.3rem; 42 | } 43 | 44 | h3 { 45 | font-size: 1.8rem; 46 | } 47 | 48 | a { 49 | color: inherit; 50 | text-decoration: none; 51 | box-shadow: inset 0 -2px 0 #39ba91; 52 | } 53 | 54 | .app { 55 | display: flex; 56 | flex-wrap: wrap; 57 | align-items: center; 58 | justify-content: center; 59 | min-height: 100vh; 60 | } 61 | 62 | .app__content { 63 | max-width: 480px; 64 | padding: 2rem; 65 | } 66 | 67 | .logo { 68 | width: 140px; 69 | height: 30px; 70 | fill: #CAD2DA; 71 | color: #39ba91; 72 | } -------------------------------------------------------------------------------- /drivers/python/bigchaindb_driver/exceptions.py: -------------------------------------------------------------------------------- 1 | """Exceptions used by :mod:`bigchaindb_driver`.""" 2 | 3 | 4 | class BigchaindbException(Exception): 5 | """Base exception for all Bigchaindb exceptions.""" 6 | 7 | 8 | class KeypairNotFoundException(BigchaindbException): 9 | """Raised if an operation cannot proceed because the keypair was not given. 10 | """ 11 | 12 | 13 | class InvalidPrivateKey(BigchaindbException): 14 | """Raised if a private key is invalid. E.g.: :obj:`None`.""" 15 | 16 | 17 | class InvalidPublicKey(BigchaindbException): 18 | """Raised if a public key is invalid. E.g.: :obj:`None`.""" 19 | 20 | 21 | class MissingPrivateKeyError(BigchaindbException): 22 | """Raised if a private key is missing.""" 23 | 24 | 25 | class TransportError(BigchaindbException): 26 | """Base exception for transport related errors. 27 | 28 | This is mainly for cases where the status code denotes an HTTP error, and 29 | for cases in which there was a connection error. 30 | 31 | """ 32 | @property 33 | def status_code(self): 34 | return self.args[0] 35 | 36 | @property 37 | def error(self): 38 | return self.args[1] 39 | 40 | @property 41 | def info(self): 42 | return self.args[2] 43 | 44 | 45 | class ConnectionError(TransportError): 46 | """Exception for errors occurring when connecting, and/or making a request 47 | to Bigchaindb. 48 | 49 | """ 50 | 51 | 52 | class BadRequest(TransportError): 53 | """Exception for HTTP 400 errors.""" 54 | 55 | 56 | class NotFoundError(TransportError): 57 | """Exception for HTTP 404 errors.""" 58 | 59 | 60 | HTTP_EXCEPTIONS = { 61 | 400: BadRequest, 62 | 404: NotFoundError, 63 | } 64 | -------------------------------------------------------------------------------- /examples/client/interledger/js/components/assets.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import AssetRow from './asset_row'; 4 | import Spinner from '../../../js/react/components/spinner'; 5 | 6 | 7 | const Assets = ({ 8 | account, 9 | accountList, 10 | assetList, 11 | activeAsset, 12 | handleAccountClick, 13 | handleAssetClick 14 | }) => { 15 | if (assetList && assetList.length) { 16 | return ( 17 |
18 | {assetList.map((asset) => { 19 | const isActive = !!activeAsset && activeAsset.id === asset.id; 20 | 21 | return ( 22 | 30 | ); 31 | })} 32 |
33 | ); 34 | } else { 35 | return ( 36 |
37 | 38 |
39 | ); 40 | } 41 | }; 42 | 43 | Assets.propTypes = { 44 | account: React.PropTypes.object, 45 | accountList: React.PropTypes.array, 46 | activeAsset: React.PropTypes.object, 47 | assetClasses: React.PropTypes.object, 48 | assetList: React.PropTypes.array, 49 | handleAccountClick: React.PropTypes.func, 50 | handleAssetClick: React.PropTypes.func 51 | }; 52 | 53 | export default Assets; 54 | -------------------------------------------------------------------------------- /examples/client/tx_explorer/js/components/transaction_panel.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { safeInvoke } from 'js-utility-belt/es6'; 4 | import TransactionDetail from '../../../js/react/components/transactions/transaction_detail'; 5 | import InputTransaction from './input_transaction'; 6 | 7 | const TransactionPanel = React.createClass({ 8 | propTypes: { 9 | activeAccount: React.PropTypes.object, 10 | accountList: React.PropTypes.array, 11 | transaction: React.PropTypes.object, 12 | transactionStatuses: React.PropTypes.object, 13 | className: React.PropTypes.string, 14 | handleAssetClick: React.PropTypes.func 15 | }, 16 | 17 | render() { 18 | const { 19 | activeAccount, 20 | accountList, 21 | transaction, 22 | transactionStatuses, 23 | className, 24 | handleAssetClick 25 | } = this.props; 26 | 27 | return ( 28 |
29 | 34 | 40 |
41 | ) 42 | } 43 | }); 44 | 45 | export default TransactionPanel; 46 | -------------------------------------------------------------------------------- /examples/client/scss/_code.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Code (inline and block) 3 | // -------------- 4 | // bigchain.io 5 | // 6 | code, 7 | kbd, 8 | pre, 9 | samp { 10 | font-family: $font-family-monospace; 11 | font-size: $font-size-xs; 12 | hyphens: none; 13 | } 14 | 15 | // Inline code 16 | code { 17 | padding: 2px 4px; 18 | color: $code-color; 19 | background-color: $code-bg; 20 | border-radius: $border-radius; 21 | } 22 | 23 | // User input typically entered via keyboard 24 | kbd { 25 | padding: 2px 4px; 26 | color: $kbd-color; 27 | background-color: $kbd-bg; 28 | border-radius: $border-radius-sm; 29 | box-shadow: inset 0 -1px 0 rgba(0,0,0,.25); 30 | kbd { 31 | padding: 0; 32 | font-size: 100%; 33 | font-weight: bold; 34 | box-shadow: none; 35 | } 36 | } 37 | 38 | // Blocks of code 39 | pre { 40 | display: block; 41 | padding: $spacer; 42 | margin: 0 0 $spacer; 43 | line-height: $line-height; 44 | word-break: break-all; 45 | word-wrap: break-word; 46 | color: $pre-color; 47 | background-color: $pre-bg; 48 | border-radius: $border-radius; 49 | 50 | // make 'em scrollable 51 | overflow: scroll; 52 | -webkit-overflow-scrolling: touch; 53 | max-height: $pre-scrollable-max-height; 54 | 55 | // Account for some code outputs that place code tags in pre tags 56 | code { 57 | padding: 0; 58 | font-size: inherit; 59 | color: inherit; 60 | white-space: pre; 61 | overflow-wrap: normal; 62 | word-wrap: normal; 63 | word-break: normal; 64 | overflow: auto; 65 | background-color: transparent; 66 | border-radius: 0; 67 | } 68 | } 69 | 70 | .react-syntax-highlighter-line-number { 71 | opacity: .5; 72 | } -------------------------------------------------------------------------------- /examples/client/scss/_transaction.scss: -------------------------------------------------------------------------------- 1 | .transaction-container { 2 | 3 | } 4 | 5 | .transaction-container-actions { 6 | margin-top: 1em 7 | } 8 | 9 | .transaction-header { 10 | background: lighten(aquamarine, 20%); 11 | border-bottom: 1px solid darken(aquamarine, 40%); 12 | border-top: 1px solid darken(aquamarine, 40%); 13 | margin-bottom: 1em; 14 | } 15 | 16 | .transaction-header, 17 | .transaction-body { 18 | padding: 0.4em 1em; 19 | } 20 | 21 | .transaction-link { 22 | cursor: pointer; 23 | &:hover { 24 | text-decoration: underline; 25 | } 26 | } 27 | 28 | .transaction-row-label, 29 | .transaction-row-value { 30 | text-overflow: ellipsis; 31 | overflow-x: hidden; 32 | } 33 | 34 | .transaction-flow-row { 35 | margin: 1em; 36 | } 37 | 38 | .transaction-flow-col { 39 | padding: 0; 40 | } 41 | 42 | .transaction-flow-title { 43 | margin-bottom: 1em; 44 | text-align: center; 45 | } 46 | 47 | .transaction-flow-body { 48 | text-overflow: ellipsis; 49 | overflow-x: hidden; 50 | padding-right: 2em 51 | } 52 | 53 | .transaction-flow-glyph-right { 54 | position: absolute; 55 | left: -15px; 56 | } 57 | 58 | .transaction-list-null { 59 | margin-top: 60px; 60 | text-align: center; 61 | } 62 | 63 | .transaction-panel { 64 | border-bottom: 1px solid darken(aquamarine, 40%); 65 | border-left: 1px solid rgba(0, 0, 0, 0); 66 | border-right: 1px solid rgba(0, 0, 0, 0); 67 | border-top: 1px solid rgba(0, 0, 0, 0); 68 | &:hover { 69 | background: white; 70 | border: 1px solid darken(aquamarine, 40%); 71 | } 72 | &.hit { 73 | background: lighten(red, 40%) !important; 74 | border: 1px solid lighten(red, 20%); 75 | } 76 | margin-bottom: 1em; 77 | max-width: 800px; 78 | } -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeCreateTransaction.js: -------------------------------------------------------------------------------- 1 | import makeInputTemplate from './makeInputTemplate'; 2 | import makeTransaction from './makeTransaction'; 3 | 4 | 5 | /** 6 | * @public 7 | * Generate a `CREATE` transaction holding the `asset`, `metadata`, and `outputs`, to be signed by 8 | * the `issuers`. 9 | * @param {object} asset Created asset's data 10 | * @param {object} metadata Metadata for the Transaction 11 | * @param {object[]} outputs Array of Output objects to add to the Transaction. 12 | * Think of these as the recipients of the asset after the transaction. 13 | * For `CREATE` Transactions, this should usually just be a list of 14 | * Outputs wrapping Ed25519 Conditions generated from the issuers' public 15 | * keys (so that the issuers are the recipients of the created asset). 16 | * @param {...string[]} issuers Public key of one or more issuers to the asset being created by this 17 | * Transaction. 18 | * Note: Each of the private keys corresponding to the given public 19 | * keys MUST be used later (and in the same order) when signing the 20 | * Transaction (`signTransaction()`). 21 | * @returns {object} Unsigned transaction -- make sure to call signTransaction() on it before 22 | * sending it off! 23 | */ 24 | export default function makeCreateTransaction(asset, metadata, outputs, ...issuers) { 25 | const assetDefinition = { 26 | 'data': asset || null, 27 | }; 28 | const inputs = issuers.map((issuer) => makeInputTemplate([issuer])); 29 | 30 | return makeTransaction('CREATE', assetDefinition, metadata, outputs, inputs); 31 | } -------------------------------------------------------------------------------- /examples/client/server.demo.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable strict, no-console */ 2 | /* eslint-disable import/no-extraneous-dependencies, import/newline-after-import */ 3 | 'use strict'; 4 | 5 | const WebpackDevServer = require('webpack-dev-server'); 6 | const webpack = require('webpack'); 7 | const config = require('./webpack.config.js'); 8 | 9 | require('dotenv').load({ silent: true }); 10 | 11 | const HOST_NAME = process.env.CLIENT_HOST || 'localhost'; 12 | const PORT = process.env.CLIENT_PORT || 3000; 13 | 14 | // Enable hot reloading if on demo mode 15 | if (process.env.NODE_ENV === 'demo') { 16 | // Each entry must have the hot dev server included 17 | Object.keys(config.entry).forEach((entryName) => { 18 | config.entry[entryName] = [ 19 | config.entry[entryName], 20 | 'webpack/hot/dev-server', 21 | `webpack-dev-server/client?http://${HOST_NAME}:${PORT}/` 22 | ]; 23 | }); 24 | config.plugins.push(new webpack.HotModuleReplacementPlugin()); 25 | // React hot reloading is enabled through .babelrc and babel-react-transform 26 | } 27 | 28 | // Specify output location for bundled files 29 | config.output.publicPath = '/'; 30 | 31 | // Configure server 32 | const compiler = webpack(config); 33 | 34 | const server = new WebpackDevServer(compiler, { 35 | publicPath: config.output.publicPath, 36 | contentBase: './demo', 37 | hot: true, 38 | noInfo: true, 39 | stats: { colors: true } 40 | }); 41 | 42 | // Start server 43 | server.listen(PORT, HOST_NAME, (err) => { 44 | if (err) { 45 | console.error(`Demo server ran into ${err} while starting on ${HOST_NAME}:${PORT}.` + 46 | 'Shutting down...'); 47 | server.close(); 48 | } 49 | console.log(`Demo server running on ${HOST_NAME}:${PORT}`); 50 | }); 51 | -------------------------------------------------------------------------------- /examples/client/js/react/components/bigchaindb_connection.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { safeInvoke, safeMerge } from 'js-utility-belt/es6'; 4 | 5 | import AccountStore from '../stores/account_store'; 6 | import TransactionStore from '../stores/transaction_store'; 7 | 8 | 9 | export default function BigchainDBConnection(Component) { 10 | return React.createClass({ 11 | displayName: `BigchainDBConnection(${Component.displayName || Component})`, 12 | 13 | getInitialState() { 14 | const accountStore = AccountStore.getState(); 15 | const transactionStore = TransactionStore.getState(); 16 | 17 | return safeMerge( 18 | { 19 | activeAccount: null 20 | }, 21 | accountStore, 22 | transactionStore 23 | ); 24 | }, 25 | 26 | componentDidMount() { 27 | AccountStore.listen(this.onChange); 28 | TransactionStore.listen(this.onChange); 29 | }, 30 | 31 | componentWillUnmount() { 32 | AccountStore.unlisten(this.onChange); 33 | TransactionStore.unlisten(this.onChange) 34 | }, 35 | 36 | onChange(state) { 37 | this.setState(state); 38 | }, 39 | 40 | handleAccountChange(activeAccount) { 41 | this.setState({ 42 | activeAccount 43 | }); 44 | }, 45 | 46 | resetActiveAccount() { 47 | this.handleAccountChange(null); 48 | }, 49 | 50 | render() { 51 | return ( 52 | 57 | ); 58 | } 59 | }); 60 | } 61 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # Code Licenses 2 | 3 | For all code in this repository, BigchainDB GmbH ("We") either: 4 | 5 | 1. owns the copyright, or 6 | 2. owns the right to sublicense it (because all external contributors must agree to a Contributor License Agreement). 7 | 8 | Therefore We can choose how to license all the code in this repository. We can license it to Joe Xname under one license and Company Yname under a different license. 9 | 10 | The two general options are: 11 | 12 | 1. You can get it under a commercial license for a fee. We can negotiate the terms of that license. It's not like we have some standard take-it-or-leave it commercial license. If you want to modify it and keep your modifications private, then that's certainly possible. Just ask. 13 | 2. You can get it under the AGPLv3 license for free. You don't even have to ask us. That's because all code in _this_ repository is licensed under the GNU Affero General Public License version 3 (AGPLv3), the full text of which can be found at [http://www.gnu.org/licenses/agpl.html](http://www.gnu.org/licenses/agpl.html). 14 | 15 | If you don't like the AGPL license, then just ignore it. It doesn't affect any other license. 16 | 17 | All short code snippets embedded in the official BigchainDB _documentation_ are also licensed under the Apache License, Version 2.0, the full text of which can be found at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0). 18 | 19 | For the licenses on all other BigchainDB-related code, see the LICENSE file in the associated repository. 20 | 21 | # Documentation Licenses 22 | 23 | The official BigchainDB documentation, _except for the short code snippets embedded within it_, is licensed under a Creative Commons Attribution-ShareAlike 4.0 International license, the full text of which can be found at [http://creativecommons.org/licenses/by-sa/4.0/legalcode](http://creativecommons.org/licenses/by-sa/4.0/legalcode). 24 | -------------------------------------------------------------------------------- /drivers/javascript/utils/bigchaindb_utils.js: -------------------------------------------------------------------------------- 1 | import request from './request'; 2 | import ApiUrls from '../constants/api_urls'; 3 | 4 | 5 | export function requestTransaction(txId) { 6 | return request(ApiUrls['transactions_detail'], { 7 | urlTemplateSpec: { 8 | txId 9 | } 10 | }); 11 | } 12 | 13 | export function postTransaction(transaction) { 14 | return request(ApiUrls['transactions'], { 15 | method: 'POST', 16 | jsonBody: transaction 17 | }) 18 | } 19 | 20 | export function listTransactions({ asset_id, operation }) { 21 | return request(ApiUrls['transactions'], { 22 | query: { 23 | asset_id, 24 | operation 25 | } 26 | }) 27 | } 28 | 29 | export function pollStatusAndFetchTransaction(transaction) { 30 | return new Promise((resolve, reject) => { 31 | const timer = setInterval(() => { 32 | requestStatus(transaction.id) 33 | .then((res) => { 34 | console.log('Fetched transaction status:', res); 35 | if (res.status === 'valid') { 36 | clearInterval(timer); 37 | requestTransaction(transaction.id) 38 | .then((res) => { 39 | console.log('Fetched transaction:', res); 40 | resolve(); 41 | }); 42 | } 43 | }); 44 | }, 500) 45 | }) 46 | } 47 | 48 | export function listOutputs({ public_key, unspent }) { 49 | return request(ApiUrls['outputs'], { 50 | query: { 51 | public_key, 52 | unspent 53 | } 54 | }) 55 | } 56 | 57 | export function requestStatus(tx_id) { 58 | return request(ApiUrls['statuses'], { 59 | query: { 60 | tx_id 61 | } 62 | }); 63 | } 64 | -------------------------------------------------------------------------------- /examples/client/app_index_template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title || 'BigchainDB Examples' %> 9 | 10 | 11 | 12 | 22 | 23 | <% if (!htmlWebpackPlugin.options.PRODUCTION) { %> 24 | 31 | <% } %> 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /drivers/python/tests/test_connection.py: -------------------------------------------------------------------------------- 1 | from pytest import mark 2 | from requests.utils import default_headers 3 | from responses import RequestsMock 4 | 5 | 6 | class TestConnection: 7 | 8 | def test_init_with_custom_headers(self): 9 | from bigchaindb_driver.connection import Connection 10 | url = 'http://dummy' 11 | custom_headers = {'app_id': 'id_value', 'app_key': 'key_value'} 12 | connection = Connection(node_url=url, headers=custom_headers) 13 | expected_headers = default_headers() 14 | expected_headers.update(custom_headers) 15 | assert connection.session.headers == expected_headers 16 | 17 | @mark.parametrize('content_type,json,data', ( 18 | ('application/json', {'a': 1}, {'a': 1}), 19 | ('text/plain', {}, ''), 20 | )) 21 | def test_response_content_type_handling(self, content_type, json, data): 22 | from bigchaindb_driver.connection import Connection 23 | url = 'http://dummy' 24 | connection = Connection(node_url=url) 25 | with RequestsMock() as requests_mock: 26 | requests_mock.add('GET', url, json=json) 27 | response = connection.request('GET') 28 | assert response.status_code == 200 29 | assert response.headers['Content-Type'] == content_type 30 | assert response.data == data 31 | 32 | @mark.parametrize('headers', ( 33 | {}, {'app_name': 'name'}, {'app_id': 'id', 'app_key': 'key'} 34 | )) 35 | def test_request_with_headers(self, headers): 36 | from bigchaindb_driver.connection import Connection 37 | url = 'http://dummy' 38 | connection = Connection(node_url=url, headers=headers) 39 | with RequestsMock() as requests_mock: 40 | requests_mock.add('GET', url, adding_headers=headers) 41 | response = connection.request('GET') 42 | assert response.status_code == 200 43 | del response.headers['Content-type'] 44 | assert response.headers == headers 45 | -------------------------------------------------------------------------------- /examples/apps_config.py: -------------------------------------------------------------------------------- 1 | APPS = [ 2 | { 3 | 'name': 'ontherecord', 4 | 'num_accounts': 3, 5 | 'num_assets': 0, 6 | 'ledger': 0, 7 | 'payload_func': ( 8 | lambda x: { 9 | 'app': 'ontherecord', 10 | 'content': x 11 | } 12 | ) 13 | }, 14 | { 15 | 'name': 'sharetrader', 16 | 'num_accounts': 5, 17 | 'num_assets': 64, 18 | 'ledger': 0, 19 | 'payload_func': ( 20 | lambda i: { 21 | 'app': 'sharetrader', 22 | 'content': { 23 | 'x': int(i / 8), 24 | 'y': int(i % 8) 25 | } 26 | } 27 | ) 28 | }, 29 | # { 30 | # 'name': 'interledger', 31 | # 'accounts': [ 32 | # { 33 | # 'name': 'alice', 34 | # 'ledgers': [ 35 | # { 36 | # 'id': 0, 37 | # 'num_assets': 3 38 | # } 39 | # ] 40 | # }, 41 | # { 42 | # 'name': 'bob', 43 | # 'ledgers': [ 44 | # { 45 | # 'id': 1, 46 | # 'num_assets': 3 47 | # } 48 | # ] 49 | # }, 50 | # { 51 | # 'name': 'chloe', 52 | # 'ledgers': [ 53 | # { 54 | # 'id': 0, 55 | # 'num_assets': 3 56 | # }, 57 | # { 58 | # 'id': 1, 59 | # 'num_assets': 3 60 | # } 61 | # ] 62 | # } 63 | # ], 64 | # 'payload_func': ( 65 | # lambda x: { 66 | # 'app': 'interledger', 67 | # 'content': x 68 | # } 69 | # ) 70 | # } 71 | ] 72 | -------------------------------------------------------------------------------- /examples/client/tx_explorer/scss/custom_style.scss: -------------------------------------------------------------------------------- 1 | 2 | .app--tx_explorer { 3 | 4 | .blink { 5 | animation: blink-animation 1.5s steps(5, start) infinite; 6 | -webkit-animation: blink-animation 1.5s steps(5, start) infinite; 7 | } 8 | @keyframes blink-animation { 9 | to { 10 | visibility: hidden; 11 | } 12 | } 13 | @-webkit-keyframes blink-animation { 14 | to { 15 | visibility: hidden; 16 | } 17 | } 18 | 19 | .asset-container { 20 | background: lighten($fg-color, 95%); 21 | border: 1px solid lighten($fg-color, 50%); 22 | border-radius: .7em; 23 | margin-bottom: .5em; 24 | } 25 | 26 | .asset-container-id { 27 | color: lighten($fg-color, 50%); 28 | } 29 | 30 | .transaction-list { 31 | margin-top: 60px; 32 | } 33 | 34 | #transaction-history-wrapper { 35 | height: 100%; 36 | overflow-y: auto; 37 | } 38 | 39 | .transaction-history { 40 | position: fixed; 41 | right: 0; 42 | top: 0; 43 | height: 100vh; 44 | background: white; 45 | z-index: 2000; 46 | padding: 0 1em 5em; 47 | overflow-y: auto; 48 | border-left: 1px solid darken(aquamarine, 40%); 49 | border-top: 1px solid #00b276; 50 | .transaction-list { 51 | margin-top: 3em; 52 | .transaction-link:hover { 53 | text-decoration: none !important; 54 | cursor: default; 55 | } 56 | } 57 | margin-top: 60px; 58 | } 59 | 60 | .transaction-history-header { 61 | font-family: "Droid Sans Mono", Menlo, Monaco, Consolas, "Courier New", monospace; 62 | color: darken(aquamarine, 40%); 63 | padding: 0.5em 0 1em; 64 | position: fixed; 65 | background: white; 66 | width: 100%; 67 | z-index: 2001; 68 | &:hover { 69 | cursor: pointer; 70 | color: #109; 71 | } 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /drivers/javascript/webpack.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable strict, no-console, object-shorthand */ 2 | 3 | 'use strict'; 4 | 5 | const path = require('path'); 6 | 7 | const webpack = require('webpack'); 8 | 9 | const PRODUCTION = process.env.NODE_ENV === 'production'; 10 | 11 | const PATHS = { 12 | ENTRY: path.resolve(__dirname, './src/index.js'), 13 | BUNDLE: path.resolve(__dirname, 'dist/bundle'), 14 | NODE_MODULES: path.resolve(__dirname, 'node_modules'), 15 | }; 16 | 17 | 18 | /** PLUGINS **/ 19 | const PLUGINS = [ 20 | new webpack.NoEmitOnErrorsPlugin(), 21 | ]; 22 | 23 | const PROD_PLUGINS = [ 24 | new webpack.optimize.UglifyJsPlugin({ 25 | compress: { 26 | warnings: false, 27 | }, 28 | output: { 29 | comments: false, 30 | }, 31 | sourceMap: true, 32 | }), 33 | new webpack.LoaderOptionsPlugin({ 34 | debug: false, 35 | minimize: true, 36 | }), 37 | ]; 38 | 39 | if (PRODUCTION) { 40 | PLUGINS.push(...PROD_PLUGINS); 41 | } 42 | 43 | 44 | /** EXPORTED WEBPACK CONFIG **/ 45 | const config = { 46 | entry: [PATHS.ENTRY], 47 | 48 | output: { 49 | filename: PRODUCTION ? 'bundle.min.js' : 'bundle.js', 50 | library: 'js-bigchaindb-quickstart', 51 | libraryTarget: 'umd', 52 | path: PATHS.BUNDLE, 53 | }, 54 | 55 | devtool: PRODUCTION ? '#source-map' : '#inline-source-map', 56 | 57 | resolve: { 58 | extensions: ['.js'], 59 | modules: ['node_modules'], // Don't use absolute path here to allow recursive matching 60 | }, 61 | 62 | plugins: PLUGINS, 63 | 64 | module: { 65 | rules: [ 66 | { 67 | test: /\.js$/, 68 | exclude: [PATHS.NODE_MODULES], 69 | use: [{ 70 | loader: 'babel-loader', 71 | options: { 72 | cacheDirectory: true, 73 | }, 74 | }], 75 | }, 76 | ], 77 | }, 78 | }; 79 | 80 | module.exports = config; 81 | -------------------------------------------------------------------------------- /examples/docs/source/interledger.rst: -------------------------------------------------------------------------------- 1 | Interledger Lab 2 | =============== 3 | 4 | .. note:: **Work in progress**. 5 | 6 | 7 | Quickstart with Docker 8 | ---------------------- 9 | 10 | .. code-block:: bash 11 | 12 | $ make 13 | 14 | If you are using ``docker-machine``, then: 15 | 16 | 17 | .. code-block:: bash 18 | 19 | $ DOCKER_MACHINE_IP=$(docker-machine ip ) make 20 | 21 | Where ```` is the name of the machine you created, e.g.: 22 | 23 | .. code-block:: bash 24 | 25 | $ docker-machine create --driver virtualbox 26 | 27 | 28 | Step by step with Docker 29 | ------------------------ 30 | 31 | Build the services: 32 | 33 | .. code-block:: bash 34 | 35 | $ docker-compose -f ledgers.yml build 36 | 37 | Run RethinkDB in the background: 38 | 39 | .. code-block:: bash 40 | 41 | $ docker-compose -f ledgers.yml up -d rdb 42 | 43 | 44 | Configure each ledger: 45 | 46 | .. code-block:: bash 47 | 48 | $ docker-compose -f ledgers.yml run bdb-0 bigchaindb -y configure 49 | $ docker-compose -f ledgers.yml run bdb-1 bigchaindb -y configure 50 | 51 | Initialize each ledger: 52 | 53 | .. code-block:: bash 54 | 55 | $ docker-compose -f ledgers.yml run bdb-0 bigchaindb init 56 | $ docker-compose -f ledgers.yml run bdb-1 bigchaindb init 57 | 58 | Initialize the accounts and assets: 59 | 60 | .. code-block:: bash 61 | 62 | $ docker-compose -f ledgers.yml run bdb-0 python init_accounts.py 63 | $ docker-compose -f ledgers.yml run bdb-0 python init_assets.py 64 | 65 | .. note:: Since each ledger/service (``bdb-0``, ``bdb-1``) is connected to the 66 | same RethinkDB instance, the initialization commands can be run with either 67 | service (``bdb-0``, or ``bdb-1``). 68 | 69 | Start everything: 70 | 71 | .. code-block:: bash 72 | 73 | $ docker-compose -f ledgers.yml up 74 | 75 | 76 | To view each ledger in browser, visit: 77 | 78 | * ``bdb-0``: http://localhost:32800 79 | * ``bdb-1``: http://localhost:32810 80 | 81 | .. note:: Replace ``localhost`` with your docker-machine ip as necessary. 82 | -------------------------------------------------------------------------------- /drivers/python/CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | 0.2.0 (2017-02-06) 5 | ------------------ 6 | Added 7 | ^^^^^ 8 | * Support for BigchainDB server 0.9. 9 | * Methods for ``GET /`` and ``GET /api/v1`` 10 | 11 | Changed 12 | ^^^^^^^ 13 | * Node URLs, passed to ``BigchainDB()`` MUST not include the api prefix 14 | ``'/api/v1'``, e.g.: 15 | 16 | * BEFORE: ``http://localhost:9984/api/v1`` 17 | * NOW: ``http://localhost:9984`` 18 | 19 | 0.1.0 (2016-11-29) 20 | ------------------ 21 | Added 22 | ^^^^^ 23 | * Support for BigchainDB server 0.8.0. 24 | * Support for divisible assets. 25 | 26 | Removed 27 | ^^^^^^^ 28 | * ``create()`` and ``transfer()`` under ``TransactionEndpoint``, and available 29 | via ``BigchainDB.transactions``. Replaced by the three "canonical" 30 | transaction operations: ``prepare()``, ``fulfill()``, and ``send()``. 31 | * Support for client side timestamps. 32 | 33 | 34 | 0.0.3 (2016-11-25) 35 | ------------------ 36 | Added 37 | ^^^^^ 38 | * Support for "canonical" transaction operations: 39 | 40 | * ``prepare`` 41 | * ``fulfill`` 42 | * ``send`` 43 | 44 | Deprecated 45 | ^^^^^^^^^^ 46 | * ``create()`` and ``transfer()`` under ``TransactionEndpoint``, and available 47 | via ``BigchainDB.transactions``. Replaced by the above three "canonical" 48 | transaction operations: ``prepare()``, ``fulfill()``, and ``send()``. 49 | 50 | Fixed 51 | ^^^^^ 52 | * ``BigchainDB()`` default node setting on its transport class. See commit 53 | `0a80206 `_ 54 | 55 | 56 | 0.0.2 (2016-10-28) 57 | ------------------ 58 | 59 | Added 60 | ^^^^^ 61 | * Support for BigchainDB server 0.7.0 62 | 63 | 64 | 0.0.1dev1 (2016-08-25) 65 | ---------------------- 66 | 67 | * Development (pre-alpha) release on PyPI. 68 | 69 | Added 70 | ^^^^^ 71 | * Minimal support for ``POST`` (via ``create()`` and ``transfer()``), and 72 | ``GET`` operations on the ``/transactions`` endpoint. 73 | 74 | 75 | 0.0.1a1 (2016-08-12) 76 | -------------------- 77 | 78 | * Planning release on PyPI. 79 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/utils/ccJsonLoad.js: -------------------------------------------------------------------------------- 1 | import base58 from 'bs58'; 2 | import cc from 'five-bells-condition'; 3 | import { Buffer } from 'buffer'; 4 | 5 | /** 6 | * @public 7 | * Loads a crypto-condition class (Fulfillment or Condition) from a BigchainDB JSON object 8 | * @param {object} conditionJson 9 | * @returns {cc.Condition} Ed25519 Condition (that will need to wrapped in an Output) 10 | */ 11 | export default function ccJsonLoad(conditionJson) { 12 | 13 | if ('hash' in conditionJson) { 14 | let condition = new cc.Condition(); 15 | condition.type = conditionJson.type_id; 16 | condition.bitmask = conditionJson.bitmask; 17 | condition.hash = new Buffer(base58.decode(conditionJson.hash)); 18 | condition.maxFulfillmentLength = parseInt(conditionJson.max_fulfillment_length, 10); 19 | return condition 20 | } else { 21 | let fulfillment; 22 | 23 | if (conditionJson.type_id === 2) { 24 | fulfillment = new cc.ThresholdSha256(); 25 | fulfillment.threshold = conditionJson.threshold; 26 | conditionJson.subfulfillments.forEach((subfulfillment) => { 27 | subfulfillment = ccJsonLoad(subfulfillment); 28 | if ('getConditionUri' in subfulfillment) 29 | fulfillment.addSubfulfillment(subfulfillment); 30 | else if ('serializeUri' in subfulfillment) 31 | fulfillment.addSubcondition(subfulfillment) 32 | }) 33 | } 34 | 35 | if (conditionJson.type_id === 0) { 36 | fulfillment = new cc.PreimageSha256(); 37 | fulfillment.preimage = new Buffer(conditionJson.preimage); 38 | 39 | } 40 | 41 | if (conditionJson.type_id === 4) { 42 | fulfillment = new cc.Ed25519(); 43 | fulfillment.publicKey = new Buffer(base58.decode(conditionJson.public_key)); 44 | if (conditionJson.signature) 45 | fulfillment.signature = new Buffer(base58.decode(conditionJson.signature)); 46 | } 47 | return fulfillment; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /drivers/python/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from setuptools import setup 5 | 6 | with open('README.rst') as readme_file: 7 | readme = readme_file.read() 8 | 9 | with open('CHANGELOG.rst') as changelog_file: 10 | changelog = changelog_file.read() 11 | 12 | install_requires = [ 13 | 'requests>=2.11.0', 14 | 'bigchaindb~=0.9.1', 15 | ] 16 | 17 | tests_require = [ 18 | 'tox>=2.3.1', 19 | 'coverage>=4.1', 20 | 'flake8>=2.6.0', 21 | 'pytest>=3.0.1', 22 | 'pytest-cov', 23 | 'pytest-env', 24 | 'pytest-sugar', 25 | 'pytest-xdist', 26 | 'responses', 27 | ] 28 | 29 | dev_require = [ 30 | 'ipdb', 31 | 'ipython', 32 | ] 33 | 34 | docs_require = [ 35 | 'Sphinx>=1.3.5', 36 | 'sphinx-autobuild', 37 | 'sphinxcontrib-napoleon>=0.4.4', 38 | 'sphinx_rtd_theme', 39 | 'sphinxcontrib-httpdomain', 40 | 'matplotlib', 41 | ] 42 | 43 | setup( 44 | name='bigchaindb_driver', 45 | version='0.2.1', 46 | description="Python driver for BigchainDB", 47 | long_description=readme + '\n\n' + changelog, 48 | author="BigchainDB", 49 | author_email='dev@bigchaindb.com', 50 | url='https://github.com/bigchaindb/bigchaindb-driver', 51 | packages=[ 52 | 'bigchaindb_driver', 53 | ], 54 | package_dir={'bigchaindb_driver': 55 | 'bigchaindb_driver'}, 56 | include_package_data=True, 57 | install_requires=install_requires, 58 | license="Apache Software License 2.0", 59 | zip_safe=False, 60 | keywords='bigchaindb_driver', 61 | classifiers=[ 62 | 'Development Status :: 3 - Alpha', 63 | 'Intended Audience :: Developers', 64 | 'License :: OSI Approved :: Apache Software License', 65 | 'Natural Language :: English', 66 | 'Programming Language :: Python :: 3 :: Only', 67 | 'Programming Language :: Python :: 3.5', 68 | ], 69 | test_suite='tests', 70 | extras_require={ 71 | 'test': tests_require, 72 | 'dev': dev_require + tests_require + docs_require, 73 | 'docs': docs_require, 74 | }, 75 | ) 76 | -------------------------------------------------------------------------------- /examples/docs/source/run.rst: -------------------------------------------------------------------------------- 1 | .. _run: 2 | 3 | Running the Examples 4 | ==================== 5 | Details about each app is documented under: 6 | 7 | * :ref:`ontherecord` 8 | * :ref:`sharetrader` 9 | * :ref:`interledger` 10 | 11 | 12 | Docker 13 | ------ 14 | 15 | Use the provided `Makefile` to configure, initialize, and start running on Docker all in one go: 16 | 17 | .. code-block:: bash 18 | 19 | $ make 20 | 21 | Or, if you're using docker-machine instances (ie. on OSX / Windows), 22 | 23 | .. code-block:: bash 24 | 25 | $ DOCKER_MACHINE_IP=$(docker-machine ip) make 26 | 27 | You should be able to view the app at ``_ (replace ``localhost`` with your 28 | docker-machine ip as necessary). 29 | 30 | 31 | Locally 32 | ------- 33 | 34 | Using the CLI 35 | ^^^^^^^^^^^^^ 36 | 37 | .. code-block:: bash 38 | 39 | $ bigchaindb-examples start --init --all 40 | 41 | Starting Everything Manually 42 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | 44 | Not for the faint of heart; use the CLI instead! 45 | 46 | You'll need to run at least two instances of BigchainDB along with a Flask and a Tornado server for 47 | each instance (Flask should be run under ports 8000 and 8001; Tornado should be run under 8888 and 48 | 8889). 49 | 50 | Running the javascript client 51 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | In one terminal, run ``npm start`` in ``client/`` to serve the client apps 53 | 54 | .. code-block:: bash 55 | 56 | $ cd client 57 | $ npm start 58 | 59 | 60 | Running BigchainDB 61 | ^^^^^^^^^^^^^^^^^^ 62 | Launch ``BigchainDB`` with ``RethinkDB`` in a separate terminal 63 | 64 | .. code-block:: bash 65 | 66 | $ rethinkdb & # skip this if RethinkDB is already running 67 | $ bigchaindb -c .bigchaindb_examples start 68 | 69 | 70 | Running the App servers 71 | ^^^^^^^^^^^^^^^^^^^^^^^ 72 | In another terminal, launch the ``flask`` server 73 | 74 | .. code-block:: bash 75 | 76 | $ python3 -m server.app 77 | 78 | In (yet) another terminal, launch the ``tornado`` server 79 | 80 | .. code-block:: bash 81 | 82 | $ python3 -m server.tornado_app 83 | 84 | You should be able to view the app at ``_. 85 | -------------------------------------------------------------------------------- /tutorials/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bigchaindb-tutorials", 3 | "version": "0.0.1", 4 | "description": "BigchainDB Tutorials", 5 | "homepage": "https://www.bigchaindb.com/", 6 | "bugs": "https://github.com/bigchaindb/kyber/issues", 7 | "license": "Apache-2.0", 8 | "author": "Dimitri De Jonghe", 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:bigchaindb/kyber.git" 12 | }, 13 | "keywords": [ 14 | "bigchaindb", 15 | "blockchain", 16 | "tutorials" 17 | ], 18 | "scripts": { 19 | "lint": "eslint ./", 20 | "build": "cross-env NODE_ENV=extract webpack", 21 | "clean": "rimraf ./build ./dist", 22 | "test": "echo \"Error: no test specified\" && exit 1", 23 | "postinstall": "npm run clean && npm run build" 24 | }, 25 | "dependencies": { 26 | "es6-promise": "^4.0.5", 27 | "isomorphic-fetch": "^2.2.1", 28 | "js-utility-belt": "^1.5.0" 29 | }, 30 | "devDependencies": { 31 | "autoprefixer": "^6.3.7", 32 | "babel-cli": "^6.10.1", 33 | "babel-eslint": "^6.1.2", 34 | "babel-loader": "^6.2.4", 35 | "babel-plugin-react-transform": "^2.0.2", 36 | "babel-plugin-transform-object-assign": "^6.8.0", 37 | "babel-plugin-transform-react-display-name": "^6.8.0", 38 | "babel-plugin-transform-runtime": "^6.9.0", 39 | "babel-preset-es2015": "^6.9.0", 40 | "babel-preset-react": "^6.11.1", 41 | "babel-runtime": "^6.9.2", 42 | "cross-env": "^2.0.0", 43 | "dotenv": "^2.0.0", 44 | "eslint": "^2.10.2", 45 | "eslint-config-ascribe-react": "^1.0.1", 46 | "eslint-plugin-import": "^1.10.3", 47 | "eslint-plugin-jsx-a11y": "^2.0.1", 48 | "eslint-plugin-react": "^5.2.2", 49 | "extract-text-webpack-plugin": "=2.0.0-beta.1", 50 | "file-loader": "^0.9.0", 51 | "html-webpack-plugin": "^2.22.0", 52 | "node-sass": "^3.8.0", 53 | "postcss-loader": "^0.9.1", 54 | "react-transform-hmr": "^1.0.4", 55 | "rimraf": "^2.5.3", 56 | "sass-loader": "^4.0.0", 57 | "style-loader": "^0.13.1", 58 | "url-loader": "^0.5.7", 59 | "webpack": "=2.1.0-beta.17", 60 | "webpack-combine-loaders": "^2.0.0", 61 | "webpack-dev-server": "=2.1.0-beta.0" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/client/js/react/sources/transaction_source.js: -------------------------------------------------------------------------------- 1 | import * as driver from 'js-bigchaindb-quickstart'; 2 | 3 | import { API_PATH } from '../../constants/application_constants'; 4 | 5 | import TransactionActions from '../actions/transaction_actions'; 6 | 7 | 8 | const TransactionSource = { 9 | lookupTransactionList: { 10 | remote(state) { 11 | const {asset_id, operation} = state.transactionMeta; 12 | // fetch transactions for account 13 | return driver.Connection.listTransactions({asset_id, operation}, API_PATH); 14 | }, 15 | 16 | success: TransactionActions.successFetchTransactionList, 17 | error: TransactionActions.errorTransaction 18 | }, 19 | 20 | postTransaction: { 21 | remote(state) { 22 | const { transaction } = state.transactionMeta; 23 | return driver.Connection.postTransaction(transaction, API_PATH) 24 | }, 25 | 26 | success: TransactionActions.successPostTransaction, 27 | error: TransactionActions.errorTransaction 28 | }, 29 | 30 | lookupTransaction: { 31 | remote(state) { 32 | const { tx_id } = state.transactionMeta; 33 | return driver.Connection.getTransaction(tx_id, API_PATH) 34 | }, 35 | 36 | success: TransactionActions.successFetchTransaction, 37 | error: TransactionActions.errorTransaction 38 | }, 39 | 40 | 41 | lookupStatus: { 42 | remote(state) { 43 | const { tx_id } = state.transactionMeta; 44 | return driver.Connection.getStatus(tx_id, API_PATH) 45 | }, 46 | 47 | success: TransactionActions.successFetchStatus, 48 | error: TransactionActions.errorTransaction 49 | }, 50 | 51 | lookupOutputList: { 52 | remote(state) { 53 | const { public_key, unspent } = state.transactionMeta; 54 | return driver.Connection.listOutputs({public_key, unspent}, API_PATH, false) 55 | }, 56 | 57 | success: TransactionActions.successFetchOutputList, 58 | error: TransactionActions.errorTransaction 59 | } 60 | 61 | }; 62 | 63 | export default TransactionSource; 64 | -------------------------------------------------------------------------------- /examples/client/js/react/stores/block_store.js: -------------------------------------------------------------------------------- 1 | import alt from '../alt'; 2 | 3 | import BlockActions from '../actions/block_actions'; 4 | import BlockSource from '../sources/block_source'; 5 | 6 | class BlockStore { 7 | constructor() { 8 | this.block = null; 9 | this.blockMap = {}; 10 | this.blockMeta = { 11 | block_id: null, 12 | err: null, 13 | tx_id: null, 14 | status: null, 15 | }; 16 | this.bindActions(BlockActions); 17 | this.registerAsync(BlockSource); 18 | } 19 | 20 | onFetchBlockList({ txId, status }) { 21 | this.blockMeta.tx_id = txId; 22 | this.blockMeta.status = status; 23 | this.getInstance().lookupBlockList(); 24 | } 25 | 26 | onSuccessFetchBlockList(blockList) { 27 | if (blockList) { 28 | const { tx_id } = this.blockMeta; 29 | this.blockMap[tx_id] = blockList; 30 | this.blockMeta.err = null; 31 | this.blockMeta.tx_id = null; 32 | this.blockMeta.status = null; 33 | return new Promise((resolve, reject) => resolve(this)) 34 | } else { 35 | this.blockMeta.err = new Error('Problem fetching the block list'); 36 | } 37 | } 38 | 39 | onFlushBlockList() { 40 | this.blockMap = {}; 41 | this.blockMeta.tx_id = null; 42 | this.blockMeta.status = null; 43 | } 44 | 45 | onFetchBlock(block_id) { 46 | this.blockMeta.block_id = block_id; 47 | this.getInstance().lookupBlock(); 48 | } 49 | 50 | onSuccessFetchBlock(block) { 51 | if (block) { 52 | this.block = block; 53 | this.blockMeta.err = null; 54 | this.blockMeta.block = null; 55 | } else { 56 | this.blockMeta.err = new Error('Problem fetching the block'); 57 | } 58 | } 59 | 60 | onFlushBlock() { 61 | this.block = null; 62 | this.blockMeta.err = null; 63 | this.blockMeta.block = null; 64 | } 65 | 66 | onErrorBlock(err) { 67 | this.blockMeta.err = err; 68 | } 69 | } 70 | 71 | export default alt.createStore(BlockStore, 'BlockStore'); 72 | -------------------------------------------------------------------------------- /examples/setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | BigchainDB: A Scalable Blockchain Database 3 | 4 | For full docs visit https://bigchaindb.readthedocs.org 5 | 6 | """ 7 | from setuptools import setup, find_packages 8 | 9 | tests_require = [ 10 | 'pytest', 11 | 'coverage', 12 | 'pep8', 13 | 'pyflakes', 14 | 'pylint', 15 | 'pytest', 16 | 'pytest-cov', 17 | 'pytest-xdist', 18 | 'pytest-flask', 19 | ] 20 | 21 | dev_require = [ 22 | 'ipdb', 23 | 'ipython', 24 | ] 25 | 26 | docs_require = [ 27 | 'recommonmark>=0.4.0', 28 | 'Sphinx>=1.3.5', 29 | 'sphinxcontrib-napoleon>=0.4.4', 30 | 'sphinx-rtd-theme>=0.1.9', 31 | ] 32 | 33 | setup( 34 | name='BigchainDB-Examples', 35 | version='0.1.0', 36 | description='Example usages for BigchainDB', 37 | long_description=__doc__, 38 | url='https://github.com/BigchainDB/bigchaindb-examples/', 39 | author='BigchainDB Contributors', 40 | author_email='dev@bigchaindb.com', 41 | license='AGPLv3', 42 | zip_safe=False, 43 | 44 | classifiers=[ 45 | 'Development Status :: 3 - Alpha', 46 | 'Intended Audience :: Developers', 47 | 'Topic :: Database', 48 | 'Topic :: Database :: Database Engines/Servers', 49 | 'Topic :: Software Development', 50 | 'Natural Language :: English', 51 | 'License :: OSI Approved :: GNU Affero General Public License v3', 52 | 'Programming Language :: Python :: 3', 53 | 'Programming Language :: Python :: 3.4', 54 | 'Programming Language :: Python :: 3.5', 55 | 'Operating System :: MacOS :: MacOS X', 56 | 'Operating System :: POSIX :: Linux', 57 | ], 58 | 59 | packages=find_packages(exclude=['tests*']), 60 | 61 | entry_points={ 62 | 'console_scripts': [ 63 | 'bigchaindb-examples=commands.bigchaindb_examples:main' 64 | ] 65 | }, 66 | 67 | install_requires=[ 68 | "tornado" 69 | ], 70 | 71 | setup_requires=['pytest-runner'], 72 | tests_require=tests_require, 73 | extras_require={ 74 | 'test': tests_require, 75 | 'dev': dev_require + tests_require + docs_require, 76 | 'docs': docs_require, 77 | }, 78 | ) 79 | -------------------------------------------------------------------------------- /drivers/python/bigchaindb_driver/transport.py: -------------------------------------------------------------------------------- 1 | from .connection import Connection 2 | from .pool import Pool 3 | 4 | 5 | class Transport: 6 | """Transport class.""" 7 | 8 | def __init__(self, *nodes, headers=None): 9 | """Initializes an instance of 10 | :class:`~bigchaindb_driver.transport.Transport`. 11 | 12 | Args: 13 | nodes: nodes 14 | headers (dict): Optional headers to pass to the 15 | :class:`~.connection.Connection` instances, which will 16 | add it to the headers to be sent with each request. 17 | 18 | """ 19 | self.nodes = nodes 20 | self.init_pool(nodes, headers=headers) 21 | 22 | def init_pool(self, nodes, headers=None): 23 | """Initializes the pool of connections.""" 24 | connections = [ 25 | Connection(node_url=node, headers=headers) for node in nodes] 26 | self.pool = Pool(connections) 27 | 28 | def get_connection(self): 29 | """Gets a connection from the pool. 30 | 31 | Returns: 32 | A :class:`~bigchaindb_driver.connection.Connection` instance. 33 | """ 34 | return self.pool.get_connection() 35 | 36 | def forward_request(self, method, path=None, 37 | json=None, params=None, headers=None): 38 | """Forwards an http request to a connection. 39 | 40 | Args: 41 | method (str): HTTP method name (e.g.: ``'GET'``). 42 | path (str): Path to be appended to the base url of a node. E.g.: 43 | ``'/transactions'``). 44 | json (dict): Payload to be sent with the HTTP request. 45 | params (dict)): Dictionary of URL (query) parameters. 46 | headers (dict): Optional headers to pass to the request. 47 | 48 | Returns: 49 | dict: Result of :meth:`requests.models.Response.json` 50 | 51 | """ 52 | connection = self.get_connection() 53 | response = connection.request( 54 | method=method, 55 | path=path, 56 | params=params, 57 | json=json, 58 | headers=headers, 59 | ) 60 | return response.data 61 | -------------------------------------------------------------------------------- /drivers/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "js-bigchaindb-quickstart", 3 | "version": "0.0.1", 4 | "description": "Some quickstarting for BigchainDB with JavaScript (node + browser)", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/sohkai/js-bigchaindb-quickstart.git" 8 | }, 9 | "license": "¯\\_(ツ)_/¯", 10 | "author": "BigchainDB", 11 | "main": "./src/index.js", 12 | "scripts": { 13 | "lint": "eslint ./", 14 | "build": "npm run clean && npm run build:bundle && npm run build:cjs && npm run build:dist", 15 | "build:bundle": "webpack", 16 | "build:cjs": "cross-env BABEL_ENV=cjs babel ./src -d dist/node", 17 | "build:dist": "cross-env NODE_ENV=production webpack -p", 18 | "clean": "rimraf dist/bundle dist/node", 19 | "test": "echo \"Error: no test specified AWWWW YEAHHH\" && exit 1" 20 | }, 21 | "devDependencies": { 22 | "babel-cli": "^6.22.2", 23 | "babel-eslint": "^7.1.1", 24 | "babel-loader": "^6.2.10", 25 | "babel-plugin-add-module-exports": "^0.2.1", 26 | "babel-plugin-transform-es2015-modules-commonjs": "^6.23.0", 27 | "babel-plugin-transform-export-extensions": "^6.22.0", 28 | "babel-plugin-transform-object-assign": "^6.22.0", 29 | "babel-plugin-transform-object-rest-spread": "^6.23.0", 30 | "babel-plugin-transform-runtime": "^6.23.0", 31 | "babel-preset-es2015-no-commonjs": "0.0.2", 32 | "babel-preset-latest": "^6.22.0", 33 | "babel-runtime": "^6.22.0", 34 | "cross-env": "^3.1.4", 35 | "eslint": "^3.14.1", 36 | "eslint-config-ascribe": "^3.0.1", 37 | "eslint-plugin-import": "^2.2.0", 38 | "rimraf": "^2.5.4", 39 | "webpack": "^2.2.1" 40 | }, 41 | "dependencies": { 42 | "bs58": "^4.0.0", 43 | "buffer": "^5.0.2", 44 | "clone": "^2.1.0", 45 | "core-js": "^2.4.1", 46 | "decamelize": "^1.2.0", 47 | "es6-promise": "^4.0.5", 48 | "fetch-ponyfill": "^4.0.0", 49 | "five-bells-condition": "=3.3.1", 50 | "isomorphic-fetch": "^2.2.1", 51 | "js-sha3": "^0.5.7", 52 | "js-utility-belt": "^1.5.0", 53 | "json-stable-stringify": "^1.0.1", 54 | "sprintf-js": "^1.0.3", 55 | "tweetnacl": "^0.14.5" 56 | }, 57 | "keywords": [ 58 | "bigchaindb", 59 | "cryptoconditions" 60 | ] 61 | } 62 | -------------------------------------------------------------------------------- /drivers/python/bigchaindb_driver/connection.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | 3 | from requests import Session 4 | 5 | from .exceptions import HTTP_EXCEPTIONS, TransportError 6 | 7 | 8 | HttpResponse = namedtuple('HttpResponse', ('status_code', 'headers', 'data')) 9 | 10 | 11 | class Connection: 12 | """A Connection object to make HTTP requests.""" 13 | 14 | def __init__(self, *, node_url, headers=None): 15 | """Initializes a :class:`~bigchaindb_driver.connection.Connection` 16 | instance. 17 | 18 | Args: 19 | node_url (str): Url of the node to connect to. 20 | headers (dict): Optional headers to send with each request. 21 | 22 | """ 23 | self.node_url = node_url 24 | self.session = Session() 25 | if headers: 26 | self.session.headers.update(headers) 27 | 28 | def request(self, method, *, path=None, json=None, 29 | params=None, headers=None, **kwargs): 30 | """Performs an HTTP requests for the specified arguments. 31 | 32 | Args: 33 | method (str): HTTP method (e.g.: ``'GET'``). 34 | path (str): API endpoint path (e.g.: ``'/transactions'``). 35 | json (dict): JSON data to send along with the request. 36 | params (dict)): Dictionary of URL (query) parameters. 37 | headers (dict): Optional headers to pass to the request. 38 | kwargs: Optional keyword arguments. 39 | 40 | """ 41 | url = self.node_url + path if path else self.node_url 42 | response = self.session.request( 43 | method=method, 44 | url=url, 45 | json=json, 46 | params=params, 47 | headers=headers, 48 | **kwargs 49 | ) 50 | text = response.text 51 | try: 52 | json = response.json() 53 | except ValueError: 54 | json = None 55 | if not (200 <= response.status_code < 300): 56 | exc_cls = HTTP_EXCEPTIONS.get(response.status_code, TransportError) 57 | raise exc_cls(response.status_code, text, json) 58 | data = json if json is not None else text 59 | return HttpResponse(response.status_code, response.headers, data) 60 | -------------------------------------------------------------------------------- /drivers/python/docs/conf.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | 4 | import sphinx_rtd_theme 5 | 6 | # Get the project root dir, which is the parent dir of this 7 | cwd = os.getcwd() 8 | project_root = os.path.dirname(cwd) 9 | 10 | # Insert the project root dir as the first element in the PYTHONPATH. 11 | # This lets us ensure that the source package is imported, and that its 12 | # version is used. 13 | sys.path.insert(0, project_root) 14 | 15 | import bigchaindb_driver 16 | 17 | 18 | extensions = [ 19 | 'sphinx.ext.autodoc', 20 | 'sphinx.ext.intersphinx', 21 | 'sphinx.ext.todo', 22 | 'sphinx.ext.coverage', 23 | 'sphinx.ext.napoleon', 24 | 'sphinx.ext.viewcode', 25 | 'sphinxcontrib.httpdomain', 26 | 'IPython.sphinxext.ipython_console_highlighting', 27 | 'IPython.sphinxext.ipython_directive', 28 | ] 29 | 30 | autodoc_default_flags = ['show-inheritance'] 31 | templates_path = ['_templates'] 32 | source_suffix = '.rst' 33 | master_doc = 'index' 34 | project = 'BigchainDB Python Driver' 35 | copyright = '2016, BigchainDB Contributors' 36 | version = bigchaindb_driver.__version__ 37 | release = bigchaindb_driver.__version__ 38 | exclude_patterns = ['_build'] 39 | pygments_style = 'sphinx' 40 | todo_include_todos = True 41 | suppress_warnings = ['image.nonlocal_uri'] 42 | 43 | html_theme = 'sphinx_rtd_theme' 44 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 45 | html_static_path = ['_static'] 46 | htmlhelp_basename = 'bigchaindb_python_driverdoc' 47 | 48 | latex_elements = {} 49 | 50 | latex_documents = [ 51 | ('index', 'bigchaindb_python_driver.tex', 52 | 'BigchainDB Python Driver Documentation', 53 | 'BigchainDB', 'manual'), 54 | ] 55 | 56 | man_pages = [ 57 | ('index', 'bigchaindb_python_driver', 58 | 'BigchainDB Python Driver Documentation', 59 | ['BigchainDB'], 1) 60 | ] 61 | 62 | texinfo_documents = [ 63 | ('index', 'bigchaindb_python_driver', 64 | 'BigchainDB Python Driver Documentation', 65 | 'BigchainDB', 66 | 'bigchaindb_python_driver', 67 | '', 68 | 'Miscellaneous'), 69 | ] 70 | 71 | intersphinx_mapping = { 72 | 'python': ('https://docs.python.org/3', None), 73 | 'bigchaindb-server': ( 74 | 'https://docs.bigchaindb.com/projects/server/en/latest/', None), 75 | } 76 | -------------------------------------------------------------------------------- /drivers/python/docs/libref.rst: -------------------------------------------------------------------------------- 1 | Library Reference 2 | ================= 3 | 4 | .. automodule:: bigchaindb_driver 5 | 6 | ``driver`` 7 | ---------- 8 | 9 | .. autoclass:: BigchainDB 10 | :members: 11 | 12 | .. automethod:: __init__ 13 | 14 | .. automodule:: bigchaindb_driver.driver 15 | 16 | .. autoclass:: TransactionsEndpoint 17 | :members: 18 | 19 | .. autoclass:: OutputsEndpoint 20 | :members: 21 | 22 | .. autoclass:: NamespacedDriver 23 | :members: 24 | 25 | .. automethod:: __init__ 26 | 27 | 28 | ``offchain`` 29 | ------------ 30 | .. automodule:: bigchaindb_driver.offchain 31 | .. autofunction:: prepare_transaction 32 | .. autofunction:: prepare_create_transaction 33 | .. autofunction:: prepare_transfer_transaction 34 | .. autofunction:: fulfill_transaction 35 | 36 | 37 | ``transport`` 38 | ------------- 39 | .. automodule:: bigchaindb_driver.transport 40 | 41 | .. autoclass:: Transport 42 | :members: 43 | 44 | .. automethod:: __init__ 45 | 46 | ``pool`` 47 | -------- 48 | .. automodule:: bigchaindb_driver.pool 49 | 50 | .. autoclass:: Pool 51 | :members: 52 | 53 | .. automethod:: __init__ 54 | 55 | .. autoclass:: RoundRobinPicker 56 | :members: 57 | 58 | .. automethod:: __init__ 59 | 60 | .. autoclass:: AbstractPicker 61 | :members: 62 | 63 | 64 | ``connection`` 65 | -------------- 66 | .. automodule:: bigchaindb_driver.connection 67 | 68 | .. autoclass:: Connection 69 | :members: 70 | 71 | .. automethod:: __init__ 72 | 73 | 74 | ``crypto`` 75 | ---------- 76 | .. automodule:: bigchaindb_driver.crypto 77 | :members: 78 | 79 | 80 | ``exceptions`` 81 | -------------- 82 | 83 | .. automodule:: bigchaindb_driver.exceptions 84 | 85 | .. autoexception:: BigchaindbException 86 | 87 | .. autoexception:: TransportError 88 | 89 | .. autoexception:: ConnectionError 90 | 91 | .. autoexception:: NotFoundError 92 | 93 | .. autoexception:: KeypairNotFoundException 94 | 95 | .. autoexception:: InvalidPrivateKey 96 | 97 | .. autoexception:: InvalidPublicKey 98 | 99 | .. autoexception:: MissingPrivateKeyError 100 | 101 | 102 | ``utils`` 103 | --------- 104 | 105 | .. automodule:: bigchaindb_driver.utils 106 | :members: 107 | :private-members: 108 | -------------------------------------------------------------------------------- /examples/client/interledger/js/components/account_detail.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import classnames from 'classnames'; 4 | import { Col } from 'react-bootstrap/lib'; 5 | 6 | import Assets from './assets'; 7 | 8 | 9 | const AccountDetail = React.createClass({ 10 | propTypes: { 11 | account: React.PropTypes.object, 12 | accountList: React.PropTypes.array, 13 | activeAccount: React.PropTypes.object, 14 | activeAsset: React.PropTypes.object, 15 | assetList: React.PropTypes.object, 16 | handleAssetClick: React.PropTypes.func, 17 | handleClick: React.PropTypes.func 18 | }, 19 | 20 | render() { 21 | const { 22 | account, 23 | accountList, 24 | activeAccount, 25 | activeAsset, 26 | assetList, 27 | handleAssetClick, 28 | handleClick 29 | } = this.props; 30 | 31 | if (account && assetList && Array.isArray(assetList[account.vk])) { 32 | const assetListForAccount = assetList[account.vk]; 33 | return ( 34 | 37 |
38 |
39 | {account.name} 40 |
41 |
42 | {account.vk} 43 |
44 |
45 | {account.api} 46 |
47 | 54 |
55 | 56 | ); 57 | } 58 | return null; 59 | } 60 | }); 61 | 62 | export default AccountDetail; 63 | -------------------------------------------------------------------------------- /examples/client/share_trader/js/components/assets.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import AssetRow from './asset_row'; 4 | import Spinner from '../../../js/react/components/spinner'; 5 | 6 | 7 | const Assets = ({ 8 | accountList, 9 | activeAccount, 10 | activeAsset, 11 | assetClasses, 12 | assetList, 13 | handleAssetClick 14 | }) => { 15 | if (assetList && assetList.length) { 16 | // re-sorting assetList because assets of multiple accounts possible 17 | return ( 18 |
19 | {assetList.sort((a, b) => { 20 | if (a.transaction.timestamp === b.transaction.timestamp) { 21 | if (a.id < b.id) { 22 | return -1; 23 | } else { 24 | return a.id > b.id ? 1 : 0; 25 | } 26 | } 27 | return a.transaction.timestamp - b.transaction.timestamp; 28 | }) 29 | .map((asset) => { 30 | const isActive = !!activeAsset && activeAsset.id === asset.id; 31 | const assetClass = assetClasses[asset.transaction.conditions[0].new_owners[0]]; 32 | 33 | return ( 34 | 42 | ); 43 | })} 44 |
45 | ); 46 | } else { 47 | return ( 48 |
49 | 50 |
51 | ); 52 | } 53 | }; 54 | 55 | Assets.propTypes = { 56 | accountList: React.PropTypes.array, 57 | activeAccount: React.PropTypes.object, 58 | activeAsset: React.PropTypes.object, 59 | assetClasses: React.PropTypes.object, 60 | assetList: React.PropTypes.array, 61 | handleAssetClick: React.PropTypes.func 62 | }; 63 | 64 | export default Assets; 65 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/makeTransferTransaction.js: -------------------------------------------------------------------------------- 1 | import makeInputTemplate from './makeInputTemplate'; 2 | import makeTransaction from './makeTransaction'; 3 | 4 | 5 | /** 6 | * @public 7 | * Generate a `TRANSFER` transaction holding the `asset`, `metadata`, and `outputs`, that fulfills 8 | * the `fulfilledOutputs` of `unspentTransaction`. 9 | * @param {object} unspentTransaction Previous Transaction you have control over (i.e. can fulfill 10 | * its Output Condition) 11 | * @param {object} metadata Metadata for the Transaction 12 | * @param {object[]} outputs Array of Output objects to add to the Transaction. 13 | * Think of these as the recipients of the asset after the transaction. 14 | * For `TRANSFER` Transactions, this should usually just be a list of 15 | * Outputs wrapping Ed25519 Conditions generated from the public keys of 16 | * the recipients. 17 | * @param {...number} fulfilledOutputs Indices of the Outputs in `unspentTransaction` that this 18 | * Transaction fulfills. 19 | * Note that the public keys listed in the fulfilled Outputs 20 | * must be used (and in the same order) to sign the Transaction 21 | * (`signTransaction()`). 22 | * @returns {object} Unsigned transaction -- make sure to call signTransaction() on it before 23 | * sending it off! 24 | */ 25 | export default function makeTransferTransaction(unspentTransaction, metadata, outputs, ...fulfilledOutputs) { 26 | const inputs = fulfilledOutputs.map((outputIndex) => { 27 | const fulfilledOutput = unspentTransaction.outputs[outputIndex]; 28 | const transactionLink = { 29 | 'output': outputIndex, 30 | 'txid': unspentTransaction.id, 31 | }; 32 | 33 | return makeInputTemplate(fulfilledOutput.public_keys, transactionLink); 34 | }); 35 | 36 | const assetLink = { 37 | 'id': unspentTransaction.operation === 'CREATE' ? unspentTransaction.id 38 | : unspentTransaction.asset.id 39 | }; 40 | 41 | return makeTransaction('TRANSFER', assetLink, metadata, outputs, inputs); 42 | } 43 | -------------------------------------------------------------------------------- /examples/client/js/utils/cryptoconditions/parse_escrow_data.js: -------------------------------------------------------------------------------- 1 | import filterByType from './filter_by_type'; 2 | import TypeIds from './type_ids'; 3 | 4 | 5 | const filterChildrenByTypes = ({ condition, types }) => { 6 | if (condition.hasOwnProperty('subfulfillments')) { 7 | const children = Object.values(types) 8 | .map((type) => { 9 | return filterByType({ 10 | condition, 11 | typeId: type, 12 | maxDepth: 1 13 | }); 14 | }) 15 | .reduce((a, b) => a.concat(b)); 16 | if (children.length >= types.length) { 17 | return children; 18 | } 19 | } 20 | return null; 21 | }; 22 | 23 | 24 | export default function parseEscrowData(condition) { 25 | const expiryCondition = filterByType({ 26 | condition, 27 | typeId: TypeIds.timeout 28 | }); 29 | 30 | const thresholdConditions = filterByType({ 31 | condition, 32 | typeId: TypeIds.threshold 33 | }); 34 | 35 | let executeCondition = null; 36 | let abortCondition = null; 37 | 38 | Object.values(thresholdConditions).forEach((thresholdCondition) => { 39 | if (!executeCondition) { 40 | const filteredExecuteCondition = filterChildrenByTypes({ 41 | condition: thresholdCondition, 42 | types: [TypeIds.ed25519, TypeIds.timeout] 43 | }); 44 | executeCondition = filteredExecuteCondition ? 45 | filterByType({ 46 | condition: thresholdCondition, 47 | typeId: TypeIds.ed25519 48 | })[0] : null; 49 | } 50 | if (!abortCondition) { 51 | const filteredAbortCondition = filterChildrenByTypes({ 52 | condition: thresholdCondition, 53 | types: [TypeIds.ed25519, TypeIds.inverter] 54 | }); 55 | abortCondition = filteredAbortCondition ? 56 | filterByType({ 57 | condition: thresholdCondition, 58 | typeId: TypeIds.ed25519 59 | })[0] : null; 60 | } 61 | }); 62 | 63 | return { 64 | expiryTime: (expiryCondition.length > 0) ? expiryCondition[0].expire_time : null, 65 | executeCondition, 66 | abortCondition 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /drivers/python/README.rst: -------------------------------------------------------------------------------- 1 | BigchainDB Python Driver 2 | ======================== 3 | 4 | 5 | .. image:: https://img.shields.io/pypi/v/bigchaindb-driver.svg 6 | :target: https://pypi.python.org/pypi/bigchaindb-driver 7 | 8 | .. image:: https://img.shields.io/travis/bigchaindb/bigchaindb-driver.svg 9 | :target: https://travis-ci.org/bigchaindb/bigchaindb-driver 10 | 11 | .. image:: https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb-driver/master.svg 12 | :target: https://codecov.io/github/bigchaindb/bigchaindb-driver?branch=master 13 | 14 | .. image:: https://readthedocs.org/projects/bigchaindb-python-driver/badge/?version=latest 15 | :target: http://bigchaindb.readthedocs.io/projects/py-driver/en/latest/?badge=latest 16 | :alt: Documentation Status 17 | 18 | .. image:: https://pyup.io/repos/github/bigchaindb/bigchaindb-driver/shield.svg 19 | :target: https://pyup.io/repos/github/bigchaindb/bigchaindb-driver/ 20 | :alt: Updates 21 | 22 | 23 | * Free software: Apache Software License 2.0 24 | * Documentation: https://docs.bigchaindb.com/projects/py-driver/ 25 | 26 | 27 | Features 28 | -------- 29 | 30 | * Support for preparing, fulfilling, and sending transactions to a BigchainDB 31 | node. 32 | * Retrieval of transactions by id. 33 | * Getting status of a transaction by id. 34 | 35 | 36 | Compatibility Matrix 37 | -------------------- 38 | 39 | +-----------------------+---------------------------+ 40 | | **BigchainDB Server** | **BigchainDB Driver** | 41 | +=======================+===========================+ 42 | | ``>= 0.8.2`` | ``>= 0.1.3`` | 43 | +-----------------------+---------------------------+ 44 | | ``>= 0.9.1`` | ``0.2.x`` | 45 | +-----------------------+---------------------------+ 46 | 47 | `Although we do our best to keep the master branches in sync, there may be 48 | occasional delays.` 49 | 50 | 51 | Credits 52 | ------- 53 | 54 | This package was initially created using Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template. Many BigchainDB developers have contributed since then. 55 | 56 | .. _Cookiecutter: https://github.com/audreyr/cookiecutter 57 | .. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage 58 | .. _cryptoconditions: https://github.com/bigchaindb/cryptoconditions 59 | .. _pynacl: https://github.com/pyca/pynacl/ 60 | .. _Networking and Cryptography library: https://nacl.cr.yp.to/ 61 | -------------------------------------------------------------------------------- /drivers/javascript/src/transaction/utils/ccJsonify.js: -------------------------------------------------------------------------------- 1 | import base58 from 'bs58'; 2 | 3 | /** 4 | * @public 5 | * Serializes a crypto-condition class (Condition or Fulfillment) into a BigchainDB-compatible JSON 6 | * @param {cc.Fulfillment} fulfillment base58 encoded Ed25519 public key for the recipient of the Transaction 7 | * @returns {object} Ed25519 Condition (that will need to wrapped in an Output) 8 | */ 9 | export default function ccJsonify(fulfillment) { 10 | 11 | let conditionUri; 12 | 13 | if ('getConditionUri' in fulfillment) 14 | conditionUri = fulfillment.getConditionUri(); 15 | else if ('serializeUri' in fulfillment) 16 | conditionUri = fulfillment.serializeUri(); 17 | 18 | let jsonBody = { 19 | 'details': {}, 20 | 'uri': conditionUri, 21 | }; 22 | 23 | if (fulfillment.getTypeId() === 0) { 24 | jsonBody.details.type_id = 0; 25 | jsonBody.details.bitmask = 3; 26 | 27 | if ('preimage' in fulfillment) { 28 | jsonBody.details.preimage = fulfillment.preimage.toString(); 29 | jsonBody.details.type = 'fulfillment'; 30 | } 31 | } 32 | 33 | if (fulfillment.getTypeId() === 2) 34 | return { 35 | 'details': { 36 | 'type_id': 2, 37 | 'type': 'fulfillment', 38 | 'bitmask': fulfillment.getBitmask(), 39 | 'threshold': fulfillment.threshold, 40 | 'subfulfillments': fulfillment.subconditions.map((subcondition) => { 41 | const subconditionJson = ccJsonify(subcondition.body); 42 | subconditionJson.details.weight = 1; 43 | return subconditionJson.details; 44 | }) 45 | }, 46 | 'uri': conditionUri, 47 | }; 48 | 49 | if (fulfillment.getTypeId() === 4) { 50 | jsonBody.details.type_id = 4; 51 | jsonBody.details.bitmask = 32; 52 | 53 | if ('publicKey' in fulfillment) { 54 | jsonBody.details.signature = null; 55 | jsonBody.details.public_key = base58.encode(fulfillment.publicKey); 56 | jsonBody.details.type = 'fulfillment'; 57 | } 58 | } 59 | 60 | if ('hash' in fulfillment) { 61 | jsonBody.details.hash = base58.encode(fulfillment.hash); 62 | jsonBody.details.max_fulfillment_length = fulfillment.maxFulfillmentLength; 63 | jsonBody.details.type = 'condition'; 64 | } 65 | 66 | return jsonBody; 67 | } 68 | -------------------------------------------------------------------------------- /examples/iot_bdb_ethereum_bseh17/app/iot/connection.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | 3 | from bigchaindb_driver import BigchainDB 4 | from bigchaindb.common.utils import gen_timestamp 5 | from utils.bigchaindb_utils import ( 6 | poll_status_and_fetch_transaction, 7 | prepare_transfer_ed25519_simple, 8 | sign_ed25519 9 | ) 10 | 11 | 12 | class ShargeBDBConnection(object): 13 | def __init__(self, 14 | bdb_server_url, 15 | sharge=None, 16 | mobile=None): 17 | self.bdb = BigchainDB(bdb_server_url) 18 | self.sharge = sharge 19 | self.mobile = mobile 20 | self.data_stream = [] 21 | self.create_stream() 22 | 23 | def create_stream(self): 24 | tx_create = self.bdb.transactions.prepare( 25 | operation='CREATE', 26 | signers=self.sharge.public_key, 27 | asset={ 28 | 'data': 29 | { 30 | 'mobile': self.mobile.public_key, 31 | 'timestamp': gen_timestamp() 32 | } 33 | }, 34 | ) 35 | tx_create_signed = self.bdb.transactions.fulfill(tx_create, private_keys=self.sharge.private_key) 36 | self.bdb.transactions.send(tx_create_signed) 37 | poll_status_and_fetch_transaction(tx_create_signed['id'], driver=self.bdb) 38 | self.data_stream.append(tx_create_signed['id']) 39 | 40 | def stream(self, data, throttle=0): 41 | for sample in data: 42 | tx_last_id = self.data_stream[-1] 43 | tx_last = self.bdb.transactions.retrieve(tx_last_id) 44 | 45 | tx_sample = prepare_transfer_ed25519_simple( 46 | transaction=tx_last, 47 | receiver=self.sharge.public_key, 48 | metadata=sample 49 | ) 50 | tx_sample_signed = sign_ed25519(tx_sample, self.sharge.private_key) 51 | self.bdb.transactions.send(tx_sample_signed) 52 | poll_status_and_fetch_transaction(tx_sample_signed['id'], driver=self.bdb) 53 | self.data_stream.append(tx_sample_signed['id']) 54 | sleep(throttle) 55 | 56 | 57 | if __name__ == '__main__': 58 | import os 59 | from mock_data_sharge import generate_mock_data 60 | BDB_SERVER_URL = os.getenv('BDB_SERVER_URL', 'http://localhost:9984') 61 | mock_data, sharge, mobile = generate_mock_data() 62 | conn = ShargeBDBConnection(BDB_SERVER_URL, sharge, mobile) 63 | conn.stream(mock_data) 64 | -------------------------------------------------------------------------------- /examples/client/interledger/js/components/interledger.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { Navbar } from 'react-bootstrap/lib'; 4 | 5 | import AccountList from '../../../js/react/components/account_list'; 6 | import AccountDetail from './account_detail'; 7 | 8 | import AssetActions from '../../../js/react/actions/asset_actions'; 9 | 10 | import BigchainDBConnection from '../../../js/react/components/bigchaindb_connection'; 11 | 12 | 13 | const Interledger = React.createClass({ 14 | propTypes: { 15 | // Injected through BigchainDBConnection 16 | accountList: React.PropTypes.array, 17 | activeAccount: React.PropTypes.object, 18 | activeAsset: React.PropTypes.object, 19 | assetList: React.PropTypes.object, 20 | handleAccountChange: React.PropTypes.func, 21 | handleAssetChange: React.PropTypes.func 22 | }, 23 | 24 | fetchAssetList({ account }) { 25 | if (account) { 26 | AssetActions.fetchAssetList({ 27 | account 28 | }); 29 | } 30 | }, 31 | 32 | render() { 33 | const { 34 | accountList, 35 | activeAccount, 36 | activeAsset, 37 | assetList, 38 | handleAccountChange, 39 | handleAssetChange 40 | } = this.props; 41 | 42 | return ( 43 |
44 | 45 |

Interledger

46 |
47 |
48 |
49 |
50 | 55 | 60 | 61 |
62 |
63 |
64 |
65 | ); 66 | } 67 | }); 68 | 69 | export default BigchainDBConnection(Interledger); 70 | -------------------------------------------------------------------------------- /drivers/python/bigchaindb_driver/pool.py: -------------------------------------------------------------------------------- 1 | from abc import ABCMeta, abstractmethod 2 | 3 | 4 | class AbstractPicker(metaclass=ABCMeta): 5 | """Abstract class for picker classes that pick connections from a pool.""" 6 | 7 | @abstractmethod 8 | def pick(self, connections): 9 | """Picks a :class:`~bigchaindb_driver.connection.Connection` 10 | instance from the given list of 11 | :class:`~bigchaindb_driver.connection.Connection` instances. 12 | 13 | Args: 14 | connections (List): List of 15 | :class:`~bigchaindb_driver.connection.Connection` instances. 16 | 17 | """ 18 | pass # pragma: no cover 19 | 20 | 21 | class RoundRobinPicker(AbstractPicker): 22 | """Object to pick a :class:`~bigchaindb_driver.connection.Connection` 23 | instance from a list of connections. 24 | 25 | Attributes: 26 | picked (str): List index of 27 | :class:`~bigchaindb_driver.connection.Connection` 28 | instance that has been picked. 29 | 30 | """ 31 | def __init__(self): 32 | """Initializes a :class:`~bigchaindb_driver.pool.RoundRobinPicker` 33 | instance. Sets :attr:`picked` to ``-1``. 34 | 35 | """ 36 | self.picked = -1 37 | 38 | def pick(self, connections): 39 | """Picks a :class:`~bigchaindb_driver.connection.Connection` 40 | instance from the given list of 41 | :class:`~bigchaindb_driver.connection.Connection` instances. 42 | 43 | Args: 44 | connections (List): List of 45 | :class:`~bigchaindb_driver.connection.Connection` instances. 46 | 47 | """ 48 | self.picked += 1 49 | self.picked = self.picked % len(connections) 50 | return connections[self.picked] 51 | 52 | 53 | class Pool: 54 | """Pool of connections.""" 55 | 56 | def __init__(self, connections, picker_class=RoundRobinPicker): 57 | """Initializes a :class:`~bigchaindb_driver.pool.Pool` instance. 58 | 59 | Args: 60 | connections (list): List of 61 | :class:`~bigchaindb_driver.connection.Connection` instances. 62 | 63 | """ 64 | self.connections = connections 65 | self.picker = picker_class() 66 | 67 | def get_connection(self): 68 | """Gets a :class:`~bigchaindb_driver.connection.Connection` 69 | instance from the pool. 70 | 71 | Returns: 72 | A :class:`~bigchaindb_driver.connection.Connection` instance. 73 | 74 | """ 75 | if len(self.connections) > 1: 76 | return self.picker.pick(self.connections) 77 | 78 | return self.connections[0] 79 | -------------------------------------------------------------------------------- /drivers/python/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean clean-test clean-pyc clean-build docs help 2 | .DEFAULT_GOAL := help 3 | define BROWSER_PYSCRIPT 4 | import os, webbrowser, sys 5 | try: 6 | from urllib import pathname2url 7 | except: 8 | from urllib.request import pathname2url 9 | 10 | webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) 11 | endef 12 | export BROWSER_PYSCRIPT 13 | 14 | define PRINT_HELP_PYSCRIPT 15 | import re, sys 16 | 17 | for line in sys.stdin: 18 | match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) 19 | if match: 20 | target, help = match.groups() 21 | print("%-20s %s" % (target, help)) 22 | endef 23 | export PRINT_HELP_PYSCRIPT 24 | BROWSER := python -c "$$BROWSER_PYSCRIPT" 25 | 26 | help: 27 | @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) 28 | 29 | clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts 30 | 31 | 32 | clean-build: ## remove build artifacts 33 | rm -fr build/ 34 | rm -fr dist/ 35 | rm -fr .eggs/ 36 | find . -name '*.egg-info' -exec rm -fr {} + 37 | find . -name '*.egg' -exec rm -f {} + 38 | 39 | clean-pyc: ## remove Python file artifacts 40 | find . -name '*.pyc' -exec rm -f {} + 41 | find . -name '*.pyo' -exec rm -f {} + 42 | find . -name '*~' -exec rm -f {} + 43 | find . -name '__pycache__' -exec rm -fr {} + 44 | 45 | clean-test: ## remove test and coverage artifacts 46 | rm -fr .tox/ 47 | rm -f .coverage 48 | rm -fr htmlcov/ 49 | 50 | lint: ## check style with flake8 51 | flake8 bigchaindb_driver tests 52 | 53 | test: ## run tests quickly with the default Python 54 | py.test 55 | 56 | 57 | test-all: ## run tests on every Python version with tox 58 | tox 59 | 60 | coverage: ## check code coverage quickly with the default Python 61 | coverage run --source bigchaindb_driver py.test 62 | 63 | coverage report -m 64 | coverage html 65 | $(BROWSER) htmlcov/index.html 66 | 67 | docs: ## generate Sphinx HTML documentation, including API docs 68 | rm -f docs/bigchaindb_driver.rst 69 | rm -f docs/modules.rst 70 | sphinx-apidoc -o docs/ bigchaindb_driver 71 | $(MAKE) -C docs clean 72 | $(MAKE) -C docs html 73 | $(BROWSER) docs/_build/html/index.html 74 | 75 | servedocs: docs ## compile the docs watching for changes 76 | watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D . 77 | 78 | release: clean ## package and upload a release 79 | python setup.py sdist upload 80 | python setup.py bdist_wheel upload 81 | 82 | dist: clean ## builds source and wheel package 83 | python setup.py sdist 84 | python setup.py bdist_wheel 85 | ls -l dist 86 | 87 | install: clean ## install the package to the active Python's site-packages 88 | python setup.py install 89 | -------------------------------------------------------------------------------- /drivers/javascript/src/sanitize.js: -------------------------------------------------------------------------------- 1 | import coreIncludes from 'core-js/library/fn/array/includes'; 2 | import coreObjectEntries from 'core-js/library/fn/object/entries'; 3 | 4 | 5 | /** 6 | * Abstraction for selectFromObject and omitFromObject for DRYness. 7 | * Set isInclusion to true if the filter should be for including the filtered items (ie. selecting 8 | * only them vs omitting only them). 9 | */ 10 | function filterFromObject(obj, filter, { isInclusion = true } = {}) { 11 | if (filter && Array.isArray(filter)) { 12 | return applyFilterOnObject(obj, isInclusion ? ((_, key) => coreIncludes(filter, key)) 13 | : ((_, key) => !coreIncludes(filter, key))); 14 | } else if (filter && typeof filter === 'function') { 15 | // Flip the filter fn's return if it's for inclusion 16 | return applyFilterOnObject(obj, isInclusion ? filter 17 | : (...args) => !filter(...args)); 18 | } else { 19 | throw new Error('The given filter is not an array or function. Exclude aborted'); 20 | } 21 | } 22 | 23 | /** 24 | * Returns a filtered copy of the given object's own enumerable properties (no inherited 25 | * properties), keeping any keys that pass the given filter function. 26 | */ 27 | function applyFilterOnObject(obj, filterFn) { 28 | if (filterFn == null) { 29 | return Object.assign({}, obj); 30 | } 31 | 32 | const filteredObj = {}; 33 | coreObjectEntries(obj).forEach(([key, val]) => { 34 | if (filterFn(val, key)) { 35 | filteredObj[key] = val; 36 | } 37 | }); 38 | 39 | return filteredObj; 40 | } 41 | 42 | /** 43 | * Similar to lodash's _.pick(), this returns a copy of the given object's 44 | * own and inherited enumerable properties, selecting only the keys in 45 | * the given array or whose value pass the given filter function. 46 | * @param {object} obj Source object 47 | * @param {array|function} filter Array of key names to select or function to invoke per iteration 48 | * @return {object} The new object 49 | */ 50 | function selectFromObject(obj, filter) { 51 | return filterFromObject(obj, filter); 52 | } 53 | 54 | /** 55 | * Glorified selectFromObject. Takes an object and returns a filtered shallow copy that strips out 56 | * any properties that are falsy (including coercions, ie. undefined, null, '', 0, ...). 57 | * Does not modify the passed in object. 58 | * 59 | * @param {object} obj Javascript object 60 | * @return {object} Sanitized Javascript object 61 | */ 62 | export default function sanitize(obj) { 63 | return selectFromObject(obj, (val) => !!val); 64 | } 65 | -------------------------------------------------------------------------------- /examples/client/share_trader/scss/custom_style.scss: -------------------------------------------------------------------------------- 1 | .app--share_trader { 2 | $colorAvailable: #ECF0F1; 3 | $colorGrid: #BDC3C7; 4 | $colorState0: #3498DB; 5 | $colorState1: #39418b; 6 | $colorState2: #E74C3C; 7 | $colorState3: #34495E; 8 | $colorState4: #1ABC9C; 9 | $colorState5: #ff8600; 10 | $colorState6: #437c2b; 11 | $colorState7: #adaf35; 12 | $colorState8: #5bbc50; 13 | 14 | $colorList: ( 15 | ("available", $colorAvailable), 16 | ("state0", $colorState0), 17 | ("state1", $colorState1), 18 | ("state2", $colorState2), 19 | ("state3", $colorState3), 20 | ("state4", $colorState4), 21 | ("state5", $colorState5), 22 | ("state6", $colorState6), 23 | ("state7", $colorState7), 24 | ("state8", $colorState8) 25 | ); 26 | 27 | .Matrix { 28 | border: 1px solid black; 29 | 30 | .Grid { 31 | stroke: $colorGrid; 32 | } 33 | 34 | .Cell { 35 | @each $colorMap in $colorList { 36 | $state: nth($colorMap, 1); 37 | $color: nth($colorMap, 2); 38 | 39 | &.#{$state} { 40 | fill: $color; 41 | } 42 | } 43 | } 44 | .available { 45 | stroke: black; 46 | stroke-width: 0.1; 47 | } 48 | } 49 | 50 | @each $colorMap in $colorList { 51 | $state: nth($colorMap, 1); 52 | $color: nth($colorMap, 2); 53 | 54 | .asset-container.#{$state} { 55 | .asset-container-id, 56 | .asset-container-timestamp .glyphicon { 57 | color: $color 58 | } 59 | &.active { 60 | background: rgba($color, 0.1); 61 | border-left-color: $color; 62 | } 63 | &:hover { 64 | background: rgba($color, 0.05); 65 | border-left-color: rgba($color, 0.6); 66 | cursor: pointer; 67 | } 68 | &.inTransfer { 69 | background: rgba($color, 0.05); 70 | border-left-color: rgba($color, 0.4); 71 | cursor: wait; 72 | } 73 | } 74 | } 75 | 76 | .asset-container { 77 | width: 100% 78 | } 79 | 80 | .asset-history { 81 | height: calc(100vh - 70px); 82 | overflow-y: scroll; 83 | padding: 0; 84 | } 85 | 86 | .asset-matrix { 87 | border-right: 1px solid #888888; 88 | height: 100%; 89 | } 90 | 91 | .page-content { 92 | height: calc(100vh - 70px); 93 | padding-right: 0; 94 | 95 | .row { 96 | height: 100%; 97 | } 98 | } 99 | } --------------------------------------------------------------------------------