Middleware service for handling incoming transactions
This module is a part of middleware services. You can install it in 2 ways:
- through core middleware installer middleware installer
- by hands: just clone the repo, do 'npm install', set your .env - and you are ready to go
This module is used for performing 2fa authentication. It's also depends from block-processor and chrono-sc-processor.
It works like so:
- user create wallet through the smart contract
- he activate 2fa through 2fa REST API: the activation happens in 2 steps: At first, user obtain his token through REST API (be careful, in case it hasn't been validated earlier, each time you will obtain new token)
- user send some money on his created wallet
- then he validate his operation through 2fa service (via REST API)
- the 2fa service validates the operation and sends the money to destination user
The available routes are listed below:
| route | methods | params | description |
|---|---|---|---|
| /wallets/:addr | GET | return available wallets for the certain address | |
| /wallet/secret | POST | {pupkey: <string>} |
obtain the secret (TOTP token) for the specified pubkey |
| /wallet/secret/confirm | POST | ``` {address: , token: <string | integer>} ``` |
| /wallet/confirm | POST | ``` {wallet: , token: <string | integer>, operation: } ``` |
To apply your configuration, create a .env file in root folder of repo (in case it's not present already). Below is the expamle configuration:
MONGO_ACCOUNTS_URI=mongodb://localhost:27017/data
MONGO_ACCOUNTS_COLLECTION_PREFIX=eth
MONGO_DATA_URI=mongodb://localhost:27017/data
MONGO_DATA_COLLECTION_PREFIX=eth
RABBIT_URI=amqp://localhost:5672
RABBIT_SERVICE_NAME=app_eth
DOMAIN=localhost
REST_PORT=8081
SMART_CONTRACTS_PATH=../node_modules/chronobank-smart-contracts/build/contracts
WEB3_URI=tmp/development/geth.ipc
ORACLE_PRIVATE_KEY=1111111111111
The options are presented below:
| name | description |
|---|---|
| MONGO_URI | the URI string for mongo connection |
| MONGO_COLLECTION_PREFIX | the default prefix for all mongo collections. The default value is 'eth' |
| MONGO_ACCOUNTS_URI | the URI string for mongo connection, which holds users accounts (if not specified, then default MONGO_URI connection will be used) |
| MONGO_ACCOUNTS_COLLECTION_PREFIX | the collection prefix for accounts collection in mongo (If not specified, then the default MONGO_COLLECTION_PREFIX will be used) |
| MONGO_DATA_URI | the URI string for mongo connection, which holds data collections (for instance, processed block's height). In case, it's not specified, then default MONGO_URI connection will be used) |
| MONGO_DATA_COLLECTION_PREFIX | the collection prefix for data collections in mongo (If not specified, then the default MONGO_COLLECTION_PREFIX will be used) |
| RABBIT_URI | rabbitmq URI connection string |
| RABBIT_SERVICE_NAME | namespace for all rabbitmq queues, like 'app_eth_transaction' |
| WEB3_URI | the path to ipc interface |
| ORACLE_PRIVATE_KEY | the oracle private key |
| SMART_CONTRACTS_PATH | the smart contract's path |
LaborX PTY