1 | The following document is a step-by-step guide to run wallet-service.
|
2 |
|
3 | ### Prerequisites
|
4 | Ensure MongoDB (2.6+) is installed and running. This document assumes that mongod is running at the default port 27017.
|
5 | See the configuration section to configure a different host/port.
|
6 |
|
7 | ### Install Wallet Service from NPM
|
8 | Use the following steps to Install wallet-service from the npmjs repository and run it with defaults. To change configuration before running, see the Configuration section.
|
9 | ```bash
|
10 | npm install @owstack/wallet-service
|
11 | cd wallet-service
|
12 | ```
|
13 |
|
14 | ### Install wallet-service from github source
|
15 | Use the following steps to Install wallet-service from github source and run it with defaults. To change configuration before running, see the Configuration section.
|
16 | ```bash
|
17 | git clone https://github.com/owstack/wallet-service.git
|
18 | cd wallet-service
|
19 | npm install
|
20 | ```
|
21 |
|
22 | ### Start the wallet-service
|
23 | Start all services for all supported coin networks.
|
24 | ```bash
|
25 | npm start all
|
26 | ```
|
27 | Start services for a specific coin network.
|
28 | ```bash
|
29 | npm start [ btc | bch | ltc ]
|
30 | ```
|
31 |
|
32 | ### Run tests
|
33 | Use the following to run tests
|
34 | ```bash
|
35 | npm test
|
36 | ```
|
37 | Use the following to run coverage during testing
|
38 | ```bash
|
39 | npm run coverage
|
40 | ```
|
41 | or
|
42 | ```bash
|
43 | make
|
44 | ```
|
45 |
|
46 | ### Configuration
|
47 | Configuration for all required modules can be specified in https://github.com/owstack/wallet-service/blob/master/base-service/config.js
|
48 |
|
49 | The wallet-service is composed of the following separate node services:
|
50 |
|
51 | One global instance of each:
|
52 | * Fiat Rate Service - base-service/fiatrateservice/fiatrateservice.js
|
53 | * Locker - base-service/locker/locker.js
|
54 | * Message Broker - base-service/messagebroker/messagebroker.js
|
55 | * Wallet Service - base-service/ws.js
|
56 |
|
57 | One instance of each per coin network:
|
58 | * Blockchain Monitor - service-template/bcmonitor/bcmonitor.js (This service talks to the Blockchain Explorer service configured under blockchainExplorerOpts - see Configure blockchain service below.)
|
59 | * Email Service - service-template/emailservice/emailservice.js
|
60 | * Push Notifications Service - service-template/pushnotificationsservice/pushnotificationsservice.js
|
61 |
|
62 | #### Configure MongoDB
|
63 | Example configuration for connecting to the MongoDB instance:
|
64 | ```javascript
|
65 | storageOpts: {
|
66 | mongoDb: {
|
67 | uri: 'mongodb://localhost:27017/ws',
|
68 | },
|
69 | }
|
70 | ```
|
71 |
|
72 | #### Configure Locker service
|
73 | Example configuration for connecting to locker service:
|
74 | ```javascript
|
75 | lockOpts: {
|
76 | lockerServer: {
|
77 | host: 'localhost',
|
78 | port: 3231,
|
79 | },
|
80 | }
|
81 | ```
|
82 |
|
83 | #### Configure Message Broker service
|
84 | Example configuration for connecting to message broker service:
|
85 | ```javascript
|
86 | messageBrokerOpts: {
|
87 | messageBrokerServer: {
|
88 | url: 'http://localhost:3380',
|
89 | },
|
90 | }
|
91 | ```
|
92 |
|
93 | #### Configure blockchain service
|
94 | Note: this service will be used by blockchain monitor service as well as by wallet-service itself.
|
95 | An example of this configuration is:
|
96 | ```javascript
|
97 | blockchainExplorerOpts: {
|
98 | defaultProvider: 'explorer',
|
99 |
|
100 | // Providers
|
101 | 'explorer': {
|
102 | 'livenet': {
|
103 | url: 'https://explorer.openwalletstack.com:443',
|
104 | apiPrefix: '/explorer-api'
|
105 | },
|
106 | 'testnet': {
|
107 | url: 'https://test-explorer.openwalletstack.com:443',
|
108 | apiPrefix: '/explorer-api'
|
109 | }
|
110 | }
|
111 | }
|
112 | ```
|
113 |
|
114 | #### Configure Email service
|
115 | Example configuration for connecting to email service (using postfix):
|
116 | ```javascript
|
117 | emailOpts: {
|
118 | host: 'localhost',
|
119 | port: 25,
|
120 | ignoreTLS: true,
|
121 | subjectPrefix: '[Wallet Service]',
|
122 | from: 'wallet-service@openwalletstack.com',
|
123 | }
|
124 | ```
|
125 |
|
126 | #### Enable clustering
|
127 | Change `config.js` file to enable and configure clustering:
|
128 | ```javascript
|
129 | {
|
130 | cluster: true,
|
131 | clusterInstances: 4,
|
132 | }
|
133 | ```
|