-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbcoin_setClient.js
More file actions
27 lines (26 loc) · 875 Bytes
/
bcoin_setClient.js
File metadata and controls
27 lines (26 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* @name: setClient()
* @description: Sets bcoin client object based on parameters in the process.env
* @usage: require('./setClient')(); client = setClient()
* @author: Mike Rightmire
* @email: Michael.Rightmire@groenewold-newmedia.de
* @copyright: Groenewold New Media
* @version: 0.9.0.0
* @Licensing: ALl rights reserved
*/
module.exports = function() {
this.setClient = function () { // defaults
/* Set the parameters for the node client to be transacted against */
const {Network} = require('bcoin');
const network = Network.get(process.env.net);
const {NodeClient} = require('bclient');
const clientOptions = {
network: network.type, // I.e. testnet
host: process.env.nodeHost,
port: network.rpcPort,
apiKey: process.env.nodeApiKey
}
const client = new NodeClient(clientOptions);
return client;
}
}