forked from bitpay/angular-bitcore-wallet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (49 loc) · 1.29 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
58
59
60
61
62
63
var bwcModule = angular.module('bwcModule', []);
var Client = require('bitcore-wallet-client');
bwcModule.constant('MODULE_VERSION', '1.1.7');
bwcModule.provider("bwcService", function() {
var provider = {};
var config = {
baseUrl: 'http://localhost:3001/bws/api',
verbose: null,
transports: null
};
provider.setBaseUrl = function(url) {
config.baseUrl = url;
};
provider.setVerbose = function(v) {
config.verbose = v ? true : false;
};
provider.$get = function() {
var service = {};
service.setBaseUrl = function(url) {
config.baseUrl = url;
};
service.setTransports = function(transports) {
config.transports = transports;
};
service.getBitcore = function() {
return Client.Bitcore;
};
service.getSJCL = function() {
return Client.sjcl;
};
service.buildTx = Client.buildTx;
service.parseSecret = Client.parseSecret;
service.getUtils = function() {
return Client.Utils;
};
service.getClient = function(walletData) {
var bwc = new Client({
baseUrl: config.baseUrl,
verbose: config.verbose,
transports: config.transports
});
if (walletData)
bwc.import(walletData);
return bwc;
};
return service;
};
return provider;
});