Wallet/angular-bitcore-wallet-client/index.js

54 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

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;
};
2017-09-14 12:27:45 -03:00
service.getBitcoreCash = function() {
return Client.BitcoreCash;
};
2016-01-22 16:51:46 -03:00
service.getErrors = function() {
2016-01-22 17:42:49 -03:00
return Client.errors;
2016-01-22 16:51:46 -03:00
};
service.getSJCL = function() {
return Client.sjcl;
};
service.buildTx = Client.buildTx;
2015-11-20 10:22:10 -03:00
service.parseSecret = Client.parseSecret;
service.Client = Client;
service.getUtils = function() {
return Client.Utils;
};
2016-06-01 15:49:20 -03:00
service.getClient = function(walletData, opts) {
2016-06-06 19:09:57 -03:00
opts = opts || {};
2016-06-01 15:49:20 -03:00
2016-06-07 12:03:00 -03:00
//note opts use `bwsurl` all lowercase;
var bwc = new Client({
2017-06-12 15:10:14 +09:00
baseUrl: opts.bwsurl || 'https://bws.bitcoin.com/bws/api',
2016-06-01 15:49:20 -03:00
verbose: opts.verbose,
2016-12-01 16:26:44 -03:00
timeout: 100000,
2016-06-01 15:49:20 -03:00
transports: ['polling'],
});
if (walletData)
2016-06-01 15:49:20 -03:00
bwc.import(walletData, opts);
return bwc;
};
return service;
};
return provider;
});