2015-11-18 15:30:28 -08:00
|
|
|
var bwcModule = angular.module('bwcModule', []);
|
|
|
|
var Client = require('../node_modules/bitcore-wallet-client');
|
|
|
|
|
|
|
|
bwcModule.constant('MODULE_VERSION', '1.0.0');
|
|
|
|
|
|
|
|
bwcModule.provider("bwcService", function() {
|
|
|
|
var provider = {};
|
|
|
|
|
|
|
|
provider.$get = function() {
|
|
|
|
var service = {};
|
|
|
|
|
|
|
|
service.getBitcore = function() {
|
|
|
|
return Client.Bitcore;
|
|
|
|
};
|
|
|
|
|
2016-01-22 11:51:46 -08:00
|
|
|
service.getErrors = function() {
|
2016-01-22 12:42:49 -08:00
|
|
|
return Client.errors;
|
2016-01-22 11:51:46 -08:00
|
|
|
};
|
|
|
|
|
2015-11-18 15:30:28 -08:00
|
|
|
service.getSJCL = function() {
|
|
|
|
return Client.sjcl;
|
|
|
|
};
|
|
|
|
|
|
|
|
service.buildTx = Client.buildTx;
|
2015-11-20 05:22:10 -08:00
|
|
|
service.parseSecret = Client.parseSecret;
|
2016-05-20 07:50:55 -07:00
|
|
|
service.Client = Client;
|
2015-11-18 15:30:28 -08:00
|
|
|
|
|
|
|
service.getUtils = function() {
|
|
|
|
return Client.Utils;
|
|
|
|
};
|
|
|
|
|
2016-06-01 11:49:20 -07:00
|
|
|
service.getClient = function(walletData, opts) {
|
2016-06-06 15:09:57 -07:00
|
|
|
opts = opts || {};
|
2016-06-01 11:49:20 -07:00
|
|
|
|
2016-06-07 08:03:00 -07:00
|
|
|
//note opts use `bwsurl` all lowercase;
|
2015-11-18 15:30:28 -08:00
|
|
|
var bwc = new Client({
|
2016-06-07 08:03:00 -07:00
|
|
|
baseUrl: opts.bwsurl || 'https://bws.bitpay.com/bws/api',
|
2016-06-01 11:49:20 -07:00
|
|
|
verbose: opts.verbose,
|
|
|
|
transports: ['polling'],
|
2015-11-18 15:30:28 -08:00
|
|
|
});
|
|
|
|
if (walletData)
|
2016-06-01 11:49:20 -07:00
|
|
|
bwc.import(walletData, opts);
|
2015-11-18 15:30:28 -08:00
|
|
|
return bwc;
|
|
|
|
};
|
|
|
|
return service;
|
|
|
|
};
|
|
|
|
|
|
|
|
return provider;
|
|
|
|
});
|