-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathindex.js
57 lines (45 loc) · 1.25 KB
/
index.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var bwcModule = angular.module('bwcModule', []);
var Client = require('bitcore-wallet-client');
bwcModule.constant('MODULE_VERSION', '5.1.2');
bwcModule.provider("bwcService", function() {
var provider = {};
var config = {
baseUrl: 'https://bws.bitpay.com/bws/api',
verbose: null,
timeout: 100000,
transports: ['polling']
};
provider.$get = function() {
var service = {};
service.getBitcore = function() {
return Client.Bitcore;
};
service.getErrors = function() {
return Client.errors;
};
service.getSJCL = function() {
return Client.sjcl;
};
service.buildTx = Client.buildTx;
service.parseSecret = Client.parseSecret;
service.Client = Client;
service.getUtils = function() {
return Client.Utils;
};
service.getClient = function(walletData, opts) {
opts = opts || {};
//note opts use `bwsurl` all lowercase;
var bwc = new Client({
baseUrl: opts.bwsurl || config.baseUrl,
verbose: opts.verbose || config.verbose,
timeout: config.timeout,
transports: config.transport
});
if (walletData)
bwc.import(walletData, opts);
return bwc;
};
return service;
};
return provider;
});