commit
3790442932
3 changed files with 12 additions and 6 deletions
4
angular-bitcore-wallet-client/index.js
vendored
4
angular-bitcore-wallet-client/index.js
vendored
|
|
@ -32,9 +32,9 @@ bwcModule.provider("bwcService", function() {
|
||||||
service.getClient = function(walletData, opts) {
|
service.getClient = function(walletData, opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
//note opts use `baseurl` all lowercase;
|
//note opts use `bwsurl` all lowercase;
|
||||||
var bwc = new Client({
|
var bwc = new Client({
|
||||||
baseUrl: opts.baseurl || 'https://bws.bitpay.com/bws/api',
|
baseUrl: opts.bwsurl || 'https://bws.bitpay.com/bws/api',
|
||||||
verbose: opts.verbose,
|
verbose: opts.verbose,
|
||||||
transports: ['polling'],
|
transports: ['polling'],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ angular.module('copayApp.services')
|
||||||
$log.debug('Bind wallet:' + credentials.walletId);
|
$log.debug('Bind wallet:' + credentials.walletId);
|
||||||
|
|
||||||
// Create the client
|
// Create the client
|
||||||
var getBaseURL = function(walletId) {
|
var getBWSURL = function(walletId) {
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
return ((config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url);
|
return ((config.bwsFor && config.bwsFor[walletId]) || defaults.bws.url);
|
||||||
|
|
@ -138,7 +138,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
var skipKeyValidation = root.profile.isChecked(platformInfo.ua, credentials.walletId);
|
var skipKeyValidation = root.profile.isChecked(platformInfo.ua, credentials.walletId);
|
||||||
var client = bwcService.getClient(JSON.stringify(credentials), {
|
var client = bwcService.getClient(JSON.stringify(credentials), {
|
||||||
baseurl: getBaseURL(credentials.walletId),
|
bwsurl: getBWSURL(credentials.walletId),
|
||||||
skipKeyValidation: skipKeyValidation,
|
skipKeyValidation: skipKeyValidation,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -324,7 +324,8 @@ angular.module('copayApp.services')
|
||||||
opts.network = 'livenet';
|
opts.network = 'livenet';
|
||||||
|
|
||||||
doCreateWallet(opts, function(err, walletClient) {
|
doCreateWallet(opts, function(err, walletClient) {
|
||||||
if (err) return bwsError.cb(err, gettext('Error creating wallet'), cb);
|
if (err) return cb(err);
|
||||||
|
|
||||||
p.addWallet(JSON.parse(walletClient.export()));
|
p.addWallet(JSON.parse(walletClient.export()));
|
||||||
return cb(null, p);
|
return cb(null, p);
|
||||||
});
|
});
|
||||||
|
|
@ -333,6 +334,8 @@ angular.module('copayApp.services')
|
||||||
// create and store a wallet
|
// create and store a wallet
|
||||||
root.createWallet = function(opts, cb) {
|
root.createWallet = function(opts, cb) {
|
||||||
doCreateWallet(opts, function(err, walletClient, secret) {
|
doCreateWallet(opts, function(err, walletClient, secret) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
root.addAndBindWalletClient(walletClient, {
|
root.addAndBindWalletClient(walletClient, {
|
||||||
bwsurl: opts.bwsurl
|
bwsurl: opts.bwsurl
|
||||||
}, cb);
|
}, cb);
|
||||||
|
|
@ -431,6 +434,9 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
// Adds and bind a new client to the profile
|
// Adds and bind a new client to the profile
|
||||||
root.addAndBindWalletClient = function(client, opts, cb) {
|
root.addAndBindWalletClient = function(client, opts, cb) {
|
||||||
|
if (!client || !client.credentials)
|
||||||
|
return cb(gettext('Could not access wallet'));
|
||||||
|
|
||||||
var walletId = client.credentials.walletId
|
var walletId = client.credentials.walletId
|
||||||
|
|
||||||
if (!root.profile.addWallet(JSON.parse(client.export())))
|
if (!root.profile.addWallet(JSON.parse(client.export())))
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ mocks.init = function(fixtures, controllerName, opts, done) {
|
||||||
var bwc = new $delegate.Client();
|
var bwc = new $delegate.Client();
|
||||||
if (walletData)
|
if (walletData)
|
||||||
bwc.import(walletData, {
|
bwc.import(walletData, {
|
||||||
baseUrl: opts.baseurl || 'https://bws.bitpay.com/bws/api',
|
baseUrl: opts.bwsurl || 'https://bws.bitpay.com/bws/api',
|
||||||
verbose: opts.verbose,
|
verbose: opts.verbose,
|
||||||
transports: ['polling'],
|
transports: ['polling'],
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue