run js-beautify on everything
...with two spaces. Command: js-beautify -s 2 -r [filename]
This commit is contained in:
parent
da445e7c69
commit
ea2e2d4e19
49 changed files with 859 additions and 682 deletions
|
|
@ -34,4 +34,3 @@ angular.module('copayApp.filters', []);
|
|||
angular.module('copayApp.services', []);
|
||||
angular.module('copayApp.controllers', []);
|
||||
angular.module('copayApp.directives', []);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ angular.module('copayApp.controllers').controller('FooterController', function($
|
|||
|
||||
if (config.themes && Array.isArray(config.themes) && config.themes[0]) {
|
||||
$scope.themes = config.themes;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$scope.themes = ['default'];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('HeaderController',
|
||||
function($scope, $rootScope, $location, notification, $http, controllerUtils) {
|
||||
$scope.menu = [
|
||||
{
|
||||
$scope.menu = [{
|
||||
'title': 'Addresses',
|
||||
'icon': 'fi-address-book',
|
||||
'link': '#/addresses'
|
||||
|
|
@ -26,13 +25,21 @@ angular.module('copayApp.controllers').controller('HeaderController',
|
|||
}
|
||||
|
||||
$http.get('https://api.github.com/repos/bitpay/copay/tags').success(function(data) {
|
||||
var toInt = function (s) { return parseInt(s); };
|
||||
var toInt = function(s) {
|
||||
return parseInt(s);
|
||||
};
|
||||
var latestVersion = data[0].name.replace('v', '').split('.').map(toInt);
|
||||
var currentVersion = copay.version.split('.').map(toInt);
|
||||
if (currentVersion[0] < latestVersion[0]) {
|
||||
$scope.updateVersion = {class: 'error', version:data[0].name};
|
||||
$scope.updateVersion = {
|
||||
class: 'error',
|
||||
version: data[0].name
|
||||
};
|
||||
} else if (currentVersion[0] == latestVersion[0] && currentVersion[1] < latestVersion[1]) {
|
||||
$scope.updateVersion = {class: 'info', version:data[0].name};
|
||||
$scope.updateVersion = {
|
||||
class: 'info',
|
||||
version: data[0].name
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
walletFactory.import(encryptedObj, passphrase, function(err, w) {
|
||||
if (err) {
|
||||
$scope.loading = false;
|
||||
$rootScope.$flashMessage = { message: err.errMsg || 'Wrong password', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: err.errMsg || 'Wrong password',
|
||||
type: 'error'
|
||||
};
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
|
|
@ -43,7 +46,10 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
$scope.import = function(form) {
|
||||
if (form.$invalid) {
|
||||
$scope.loading = false;
|
||||
$rootScope.$flashMessage = { message: 'There is an error in the form. Please, try again', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'There is an error in the form. Please, try again',
|
||||
type: 'error'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +59,10 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
|
||||
if (!backupFile && !backupText) {
|
||||
$scope.loading = false;
|
||||
$rootScope.$flashMessage = { message: 'Please, select your backup file or paste the text', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Please, select your backup file or paste the text',
|
||||
type: 'error'
|
||||
};
|
||||
$scope.loading = false;
|
||||
return;
|
||||
}
|
||||
|
|
@ -62,8 +71,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
|
||||
if (backupFile) {
|
||||
reader.readAsBinaryString(backupFile);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_importBackup(backupText);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -255,8 +255,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
};
|
||||
|
||||
$scope.topAmount = function() {
|
||||
var maxSat = ($rootScope.availableBalance * config.unitToSatoshi).toFixed(0)
|
||||
- bitcore.TransactionBuilder.FEE_PER_1000B_SAT;
|
||||
var maxSat = ($rootScope.availableBalance * config.unitToSatoshi).toFixed(0) - bitcore.TransactionBuilder.FEE_PER_1000B_SAT;
|
||||
$scope.amount = maxSat / config.unitToSatoshi;
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.filters', [])
|
||||
.filter('amTimeAgo', ['amMoment', function(amMoment) {
|
||||
.filter('amTimeAgo', ['amMoment',
|
||||
function(amMoment) {
|
||||
return function(input) {
|
||||
return amMoment.preprocessDate(input).fromNow();
|
||||
};
|
||||
}])
|
||||
}
|
||||
])
|
||||
.filter('paged', function() {
|
||||
return function(elements) {
|
||||
if (elements) {
|
||||
|
|
@ -28,5 +30,4 @@ angular.module('copayApp.filters', [])
|
|||
|
||||
return addrs;
|
||||
};
|
||||
})
|
||||
;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -168,14 +168,28 @@ Insight.prototype.checkActivity = function(addresses, cb) {
|
|||
if (!addresses) throw new Error('address must be set');
|
||||
|
||||
this.getTransactions(addresses, function onResult(txs) {
|
||||
var flatArray = function (xss) { return xss.reduce(function(r, xs) { return r.concat(xs); }, []); };
|
||||
var getInputs = function (t) { return t.vin.map(function (vin) { return vin.addr }); };
|
||||
var getOutputs = function (t) { return flatArray(
|
||||
t.vout.map(function (vout) { return vout.scriptPubKey.addresses; })
|
||||
);};
|
||||
var flatArray = function(xss) {
|
||||
return xss.reduce(function(r, xs) {
|
||||
return r.concat(xs);
|
||||
}, []);
|
||||
};
|
||||
var getInputs = function(t) {
|
||||
return t.vin.map(function(vin) {
|
||||
return vin.addr
|
||||
});
|
||||
};
|
||||
var getOutputs = function(t) {
|
||||
return flatArray(
|
||||
t.vout.map(function(vout) {
|
||||
return vout.scriptPubKey.addresses;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
var activityMap = new Array(addresses.length);
|
||||
var activeAddress = flatArray(txs.map(function(t) { return getInputs(t).concat(getOutputs(t)); }));
|
||||
var activeAddress = flatArray(txs.map(function(t) {
|
||||
return getInputs(t).concat(getOutputs(t));
|
||||
}));
|
||||
activeAddress.forEach(function(addr) {
|
||||
var index = addresses.indexOf(addr);
|
||||
if (index != -1) activityMap[index] = true;
|
||||
|
|
|
|||
|
|
@ -84,8 +84,12 @@ PrivateKey.prototype.getForPath = function(path) {
|
|||
var derivedHK = this._getHK(path);
|
||||
pk = this.privateKeyCache[path] = derivedHK.eckey.private.toString('hex');
|
||||
}
|
||||
var wk = new WalletKey({network: this.network});
|
||||
wk.fromObj({priv: pk});
|
||||
var wk = new WalletKey({
|
||||
network: this.network
|
||||
});
|
||||
wk.fromObj({
|
||||
priv: pk
|
||||
});
|
||||
return wk;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
|
||||
|
|
@ -90,7 +89,9 @@ PublicKeyRing.prototype._checkKeys = function() {
|
|||
};
|
||||
|
||||
PublicKeyRing.prototype._newExtendedPublicKey = function() {
|
||||
return new PrivateKey({networkName: this.network.name})
|
||||
return new PrivateKey({
|
||||
networkName: this.network.name
|
||||
})
|
||||
.deriveBIP45Branch()
|
||||
.extendedPublicKeyString();
|
||||
};
|
||||
|
|
@ -147,10 +148,13 @@ PublicKeyRing.prototype.getPubKeys = function(index, isChange) {
|
|||
var hk = this.copayersHK[i].derive(path);
|
||||
pubKeys[i] = hk.eckey.public;
|
||||
}
|
||||
this.publicKeysCache[path] = pubKeys.map(function(pk){return pk.toString('hex');});
|
||||
}
|
||||
else {
|
||||
pubKeys = pubKeys.map(function(s){return new Buffer(s,'hex');});
|
||||
this.publicKeysCache[path] = pubKeys.map(function(pk) {
|
||||
return pk.toString('hex');
|
||||
});
|
||||
} else {
|
||||
pubKeys = pubKeys.map(function(s) {
|
||||
return new Buffer(s, 'hex');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -146,8 +146,7 @@ Wallet.prototype._handleAddressBook = function(senderId, data, isInbound) {
|
|||
if (!this.addressBook[key]) {
|
||||
this.addressBook[key] = rcv[key];
|
||||
hasChange = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (rcv[key].createdTs > this.addressBook[key].createdTs) {
|
||||
this.addressBook[key] = rcv[key];
|
||||
hasChange = true;
|
||||
|
|
@ -804,7 +803,9 @@ Wallet.prototype.indexDiscovery = function(start, change, gap, cb) {
|
|||
next();
|
||||
});
|
||||
},
|
||||
function _while() { return hasActivity; },
|
||||
function _while() {
|
||||
return hasActivity;
|
||||
},
|
||||
function _finnaly(err) {
|
||||
if (err) return cb(err);
|
||||
cb(null, lastActive);
|
||||
|
|
|
|||
|
|
@ -272,9 +272,7 @@ Network.prototype._addCopayerMap = function(peerId, copayerId) {
|
|||
if (!this.copayerForPeer[peerId]) {
|
||||
if (Object.keys(this.copayerForPeer).length < this.maxPeers) {
|
||||
this.copayerForPeer[peerId] = copayerId;
|
||||
}
|
||||
else {
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -426,7 +424,9 @@ Network.prototype.lockIncommingConnections = function(allowedCopayerIdsArray) {
|
|||
Network.prototype.disconnect = function(cb, forced) {
|
||||
var self = this;
|
||||
self.closing = 1;
|
||||
self.send(null, { type: 'disconnect' }, function(){
|
||||
self.send(null, {
|
||||
type: 'disconnect'
|
||||
}, function() {
|
||||
self.cleanUp();
|
||||
if (typeof cb === 'function') cb();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
var imports = require('soop').imports();
|
||||
|
||||
function Storage() {
|
||||
}
|
||||
function Storage() {}
|
||||
|
||||
Storage.prototype._read = function(k) {
|
||||
var ret;
|
||||
|
|
|
|||
|
|
@ -67,8 +67,7 @@ angular
|
|||
|
||||
if (!util.supports.data) {
|
||||
$location.path('unsupported');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ((!$rootScope.wallet || !$rootScope.wallet.id) && next.validate) {
|
||||
$location.path('signin');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,41 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').
|
||||
factory('notification', ['$timeout',function($timeout){
|
||||
factory('notification', ['$timeout',
|
||||
function($timeout) {
|
||||
|
||||
var notifications = JSON.parse(localStorage.getItem('notifications')) || [],
|
||||
queue = [];
|
||||
|
||||
var settings = {
|
||||
info: { duration: 5000, enabled: true },
|
||||
funds: { duration: 5000, enabled: true },
|
||||
warning: { duration: 5000, enabled: true },
|
||||
error: { duration: 1e10, enabled: true },
|
||||
success: { duration: 5000, enabled: true },
|
||||
progress: { duration: 0, enabled: true },
|
||||
custom: { duration: 35000, enabled: true },
|
||||
info: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
funds: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
warning: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
error: {
|
||||
duration: 1e10,
|
||||
enabled: true
|
||||
},
|
||||
success: {
|
||||
duration: 5000,
|
||||
enabled: true
|
||||
},
|
||||
progress: {
|
||||
duration: 0,
|
||||
enabled: true
|
||||
},
|
||||
custom: {
|
||||
duration: 35000,
|
||||
enabled: true
|
||||
},
|
||||
details: true,
|
||||
localStorage: false,
|
||||
html5Mode: false,
|
||||
|
|
@ -33,8 +55,7 @@ angular.module('copayApp.services').
|
|||
noti.onclose = onclose;
|
||||
}
|
||||
noti.show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
settings.html5Mode = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -77,20 +98,17 @@ angular.module('copayApp.services').
|
|||
if (window.webkitNotifications) {
|
||||
if (window.webkitNotifications.checkPermission() === 0) {
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
window.webkitNotifications.requestPermission(function() {
|
||||
if (window.webkitNotifications.checkPermission() === 0) {
|
||||
settings.html5Mode = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
settings.html5Mode = false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
|
@ -167,8 +185,7 @@ angular.module('copayApp.services').
|
|||
}, function() {
|
||||
// inner on close function
|
||||
});
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
queue.push(notification);
|
||||
$timeout(function removeFromQueueTimeout() {
|
||||
queue.splice(queue.indexOf(notification), 1);
|
||||
|
|
@ -200,7 +217,8 @@ angular.module('copayApp.services').
|
|||
}
|
||||
|
||||
};
|
||||
}]).
|
||||
}
|
||||
]).
|
||||
directive('notifications', function(notification, $compile) {
|
||||
/**
|
||||
*
|
||||
|
|
@ -244,7 +262,8 @@ angular.module('copayApp.services').
|
|||
scope: {},
|
||||
template: html,
|
||||
link: link,
|
||||
controller: ['$scope', function NotificationsCtrl( $scope ){
|
||||
controller: ['$scope',
|
||||
function NotificationsCtrl($scope) {
|
||||
$scope.queue = notification.getQueue();
|
||||
|
||||
$scope.removeNotification = function(noti) {
|
||||
|
|
@ -255,8 +274,3 @@ angular.module('copayApp.services').
|
|||
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,12 @@ angular.module('copayApp.services').factory('Socket',
|
|||
var ret = {};
|
||||
|
||||
var addrList = listeners
|
||||
.filter(function(i) { return i.event != 'block'; })
|
||||
.map(function(i) {return i.event;});
|
||||
.filter(function(i) {
|
||||
return i.event != 'block';
|
||||
})
|
||||
.map(function(i) {
|
||||
return i.event;
|
||||
});
|
||||
|
||||
for (var i in addrList) {
|
||||
ret[addrList[i]] = 1;
|
||||
|
|
@ -47,7 +51,9 @@ angular.module('copayApp.services').factory('Socket',
|
|||
return ret;
|
||||
},
|
||||
isListeningBlocks: function() {
|
||||
return listeners.filter(function(i) { return i.event == 'block'; }).length > 0;
|
||||
return listeners.filter(function(i) {
|
||||
return i.event == 'block';
|
||||
}).length > 0;
|
||||
},
|
||||
emit: function(event, data, callback) {
|
||||
socket.emit(event, data, function() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').value('walletFactory', new copay.WalletFactory(config, copay.version));
|
||||
|
||||
|
|
|
|||
11
js/shell.js
11
js/shell.js
|
|
@ -11,13 +11,14 @@
|
|||
** there to be no references in the window to these libs, so let's trick
|
||||
** the renderer into thinking that we are _not_ in a CommonJS environment.
|
||||
*/
|
||||
if (typeof module !== 'undefined') module = { exports: null };
|
||||
if (typeof module !== 'undefined') module = {
|
||||
exports: null
|
||||
};
|
||||
|
||||
// are we running in copay shell?
|
||||
if (window.process && process.type === 'renderer') {
|
||||
window.cshell = initCopayShellBindings();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +41,9 @@
|
|||
|
||||
// atom shell forces to implement the clipboard on our own - thanks obama.
|
||||
|
||||
Mousetrap.stopCallback = function() { return false };
|
||||
Mousetrap.stopCallback = function() {
|
||||
return false
|
||||
};
|
||||
|
||||
Mousetrap.bind('ctrl+c', function(e) {
|
||||
clipb.writeText(window.getSelection().toString());
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@
|
|||
|
||||
var sys = require('sys')
|
||||
var exec = require('child_process').exec;
|
||||
function puts(error, stdout, stderr) { sys.puts(stdout) }
|
||||
|
||||
function puts(error, stdout, stderr) {
|
||||
sys.puts(stdout)
|
||||
}
|
||||
|
||||
function isNumber(n) {
|
||||
return !isNaN(parseInt(n)) && isFinite(n);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
if (typeof window != 'undefined') {
|
||||
window.mocha.setup({ timeout: 5000 });
|
||||
window.mocha.setup({
|
||||
timeout: 5000
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
|
||||
var imports = require('soop').imports();
|
||||
var EventEmitter = imports.EventEmitter || require('events').EventEmitter;
|
||||
|
||||
function Network(opts) {
|
||||
}
|
||||
function Network(opts) {}
|
||||
|
||||
Network.parent = EventEmitter;
|
||||
|
||||
|
|
@ -34,10 +32,8 @@ Network.prototype.lockIncommingConnections = function() {
|
|||
|
||||
};
|
||||
|
||||
Network.prototype.getPeer = function() {
|
||||
};
|
||||
Network.prototype.connectToCopayers = function(cps) {
|
||||
};
|
||||
Network.prototype.getPeer = function() {};
|
||||
Network.prototype.connectToCopayers = function(cps) {};
|
||||
Network.prototype.isOnline = function() {
|
||||
return true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ describe('API', function() {
|
|||
|
||||
it('should have a command called "echo"', function() {
|
||||
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
should.exist(api.echo);
|
||||
});
|
||||
|
||||
|
|
@ -32,7 +34,9 @@ describe('API', function() {
|
|||
})
|
||||
|
||||
it('should throw an error for all commands when called with wrong number of arguments', function() {
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
for (var i in API.prototype) {
|
||||
var f = API.prototype[i];
|
||||
if (i[0] != '_' && typeof f == 'function') {
|
||||
|
|
@ -59,7 +63,9 @@ describe('API', function() {
|
|||
|
||||
describe('#echo', function() {
|
||||
it('should echo a string', function(done) {
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
var str = 'mystr';
|
||||
api.echo(str, function(err, result) {
|
||||
result.should.equal(str);
|
||||
|
|
@ -70,7 +76,9 @@ describe('API', function() {
|
|||
|
||||
describe('#echoNumber', function() {
|
||||
it('should echo a number', function(done) {
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
var num = 500;
|
||||
api.echoNumber(num, function(err, result) {
|
||||
result.should.equal(num);
|
||||
|
|
@ -82,8 +90,12 @@ describe('API', function() {
|
|||
|
||||
describe('#echoObject', function() {
|
||||
it('should echo an object', function(done) {
|
||||
var api = new API({Storage: Storage});
|
||||
var obj = {test:'test'};
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
var obj = {
|
||||
test: 'test'
|
||||
};
|
||||
api.echoObject(obj, function(err, result) {
|
||||
result.test.should.equal(obj.test);
|
||||
(typeof result).should.equal('object');
|
||||
|
|
@ -94,7 +106,9 @@ describe('API', function() {
|
|||
|
||||
describe('#getArgTypes', function() {
|
||||
it('should get the argTypes of echo', function(done) {
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
api.getArgTypes('echo', function(err, result) {
|
||||
result[0][1].should.equal('string');
|
||||
done();
|
||||
|
|
@ -104,7 +118,9 @@ describe('API', function() {
|
|||
|
||||
describe('#getCommands', function() {
|
||||
it('should get all the commands', function(done) {
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
var n = 0;
|
||||
|
||||
for (var i in api)
|
||||
|
|
@ -120,7 +136,9 @@ describe('API', function() {
|
|||
|
||||
describe('#getWallets', function() {
|
||||
it('should get the wallet ids', function(done) {
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
api.getWallets(function(err, result) {
|
||||
result.length.should.be.greaterThan(-1);
|
||||
done();
|
||||
|
|
@ -130,7 +148,9 @@ describe('API', function() {
|
|||
|
||||
describe('#help', function() {
|
||||
it('should call _cmd_getCommands', function(done) {
|
||||
var api = new API({Storage: Storage});
|
||||
var api = new API({
|
||||
Storage: Storage
|
||||
});
|
||||
api._cmd_getCommands = function(callback) {
|
||||
(typeof arguments[0]).should.equal('function');
|
||||
callback(null, ['item']);
|
||||
|
|
|
|||
|
|
@ -84,5 +84,3 @@ describe('AddressIndex model', function() {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,5 +21,3 @@ describe('Passphrase model', function() {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@ var createW = function (networkName) {
|
|||
}
|
||||
w.walletId = '1234567';
|
||||
|
||||
return {w:w, copayers: copayers};
|
||||
return {
|
||||
w: w,
|
||||
copayers: copayers
|
||||
};
|
||||
};
|
||||
|
||||
describe('PublicKeyRing model', function() {
|
||||
|
|
@ -63,7 +66,9 @@ describe('PublicKeyRing model', function() {
|
|||
w2.registeredCopayers().should.equal(0);
|
||||
w2.isComplete().should.equal(false);
|
||||
|
||||
(function() {w2.getAddress(0, false);}).should.throw();
|
||||
(function() {
|
||||
w2.getAddress(0, false);
|
||||
}).should.throw();
|
||||
});
|
||||
|
||||
it('should add and check when adding shared pub keys', function() {
|
||||
|
|
@ -74,7 +79,9 @@ describe('PublicKeyRing model', function() {
|
|||
w.isComplete().should.equal(true);
|
||||
w.addCopayer.should.throw();
|
||||
for (var i = 0; i < 5; i++) {
|
||||
(function() {w.addCopayer(copayers[i])}).should.throw();
|
||||
(function() {
|
||||
w.addCopayer(copayers[i])
|
||||
}).should.throw();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -100,7 +107,9 @@ describe('PublicKeyRing model', function() {
|
|||
w2.isComplete().should.equal(true);
|
||||
w2.addCopayer.should.throw();
|
||||
for (var i = 0; i < 5; i++) {
|
||||
(function() {w.addCopayer(copayers[i])}).should.throw();
|
||||
(function() {
|
||||
w.addCopayer(copayers[i])
|
||||
}).should.throw();
|
||||
}
|
||||
|
||||
w2.indexes.getChangeIndex().should.equal(changeN);
|
||||
|
|
@ -194,29 +203,39 @@ describe('PublicKeyRing model', function() {
|
|||
networkName: 'testnet', //wrong
|
||||
walletId: w.walletId,
|
||||
});
|
||||
(function() { w2.merge(w);}).should.throw();
|
||||
(function() {
|
||||
w2.merge(w);
|
||||
}).should.throw();
|
||||
|
||||
var w3 = new PublicKeyRing({
|
||||
networkName: 'livenet',
|
||||
walletId: w.walletId,
|
||||
requiredCopayers: 2, // wrong
|
||||
});
|
||||
(function() { w3.merge(w);}).should.throw();
|
||||
(function() {
|
||||
w3.merge(w);
|
||||
}).should.throw();
|
||||
|
||||
var w4 = new PublicKeyRing({
|
||||
networkName: 'livenet',
|
||||
walletId: w.walletId,
|
||||
totalCopayers: 3, // wrong
|
||||
});
|
||||
(function() { w4.merge(w);}).should.throw();
|
||||
(function() {
|
||||
w4.merge(w);
|
||||
}).should.throw();
|
||||
|
||||
|
||||
var w6 = new PublicKeyRing({
|
||||
networkName: 'livenet',
|
||||
});
|
||||
(function() { w6.merge(w);}).should.throw();
|
||||
(function() {
|
||||
w6.merge(w);
|
||||
}).should.throw();
|
||||
w.networkName = 'livenet';
|
||||
(function() { w6.merge(w);}).should.throw();
|
||||
(function() {
|
||||
w6.merge(w);
|
||||
}).should.throw();
|
||||
|
||||
|
||||
var w0 = new PublicKeyRing({
|
||||
|
|
@ -227,7 +246,9 @@ describe('PublicKeyRing model', function() {
|
|||
w0.addCopayer();
|
||||
w0.addCopayer();
|
||||
w0.addCopayer();
|
||||
(function() { w0.merge(w);}).should.throw();
|
||||
(function() {
|
||||
w0.merge(w);
|
||||
}).should.throw();
|
||||
w.merge(w0, true).should.equal(true);
|
||||
w.isComplete().should.equal(true);
|
||||
|
||||
|
|
@ -235,7 +256,9 @@ describe('PublicKeyRing model', function() {
|
|||
networkName: 'livenet',
|
||||
});
|
||||
wx.addCopayer();
|
||||
(function() { w.merge(wx);}).should.throw();
|
||||
(function() {
|
||||
w.merge(wx);
|
||||
}).should.throw();
|
||||
|
||||
|
||||
});
|
||||
|
|
@ -370,5 +393,3 @@ describe('PublicKeyRing model', function() {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -135,24 +135,45 @@ describe('Insight model', function() {
|
|||
w.checkActivity(addresses, function(err, actives) {
|
||||
console.log(err);
|
||||
actives.length.should.equal(addresses.length);
|
||||
actives.filter(function(i) { return i }).length.should.equal(0);
|
||||
actives.filter(function(i) {
|
||||
return i
|
||||
}).length.should.equal(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('#checkActivity for active addreses', function(done) {
|
||||
var w = new Insight();
|
||||
w.getTransactions = function(addresses, cb) {
|
||||
cb([
|
||||
{vin: [{ addr: '2NATQJnaQe2CUKLyhL1zdNkttJM1dUH9HaM'}], vout: []},
|
||||
{vin: [{ addr: '2NATQJnaQe2CUKLyhL1zdNkttJM1dUH9HaM'}], vout: []},
|
||||
{vin: [{ addr: '2N9D5bcCQ2bPWUDByQ6Qb5bMgMtgsk1rw3x'}], vout: []},
|
||||
{vin: [], vout: [{scriptPubKey: {addresses: ['2NFjCBFZSsxiwWAD7CKQ3hzWFtf9DcqTucY']}}]}
|
||||
]);
|
||||
cb([{
|
||||
vin: [{
|
||||
addr: '2NATQJnaQe2CUKLyhL1zdNkttJM1dUH9HaM'
|
||||
}],
|
||||
vout: []
|
||||
}, {
|
||||
vin: [{
|
||||
addr: '2NATQJnaQe2CUKLyhL1zdNkttJM1dUH9HaM'
|
||||
}],
|
||||
vout: []
|
||||
}, {
|
||||
vin: [{
|
||||
addr: '2N9D5bcCQ2bPWUDByQ6Qb5bMgMtgsk1rw3x'
|
||||
}],
|
||||
vout: []
|
||||
}, {
|
||||
vin: [],
|
||||
vout: [{
|
||||
scriptPubKey: {
|
||||
addresses: ['2NFjCBFZSsxiwWAD7CKQ3hzWFtf9DcqTucY']
|
||||
}
|
||||
}]
|
||||
}]);
|
||||
};
|
||||
|
||||
w.checkActivity(addresses, function(err, actives) {
|
||||
actives.length.should.equal(addresses.length);
|
||||
actives.filter(function(i) { return i }).length.should.equal(3);
|
||||
actives.filter(function(i) {
|
||||
return i
|
||||
}).length.should.equal(3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -95,7 +95,9 @@ describe('Network / WebRTC', function() {
|
|||
key.regenerateSync();
|
||||
|
||||
var copayerId = key.public.toString('hex');
|
||||
n._sendToOne = function(a1, a2, a3, cb) {cb();};
|
||||
n._sendToOne = function(a1, a2, a3, cb) {
|
||||
cb();
|
||||
};
|
||||
var sig = undefined;
|
||||
n.send(copayerId, data, function() {
|
||||
done();
|
||||
|
|
@ -138,7 +140,9 @@ describe('Network / WebRTC', function() {
|
|||
key.regenerateSync();
|
||||
|
||||
var copayerIds = [key.public.toString('hex')];
|
||||
n._sendToOne = function(a1, a2, a3, cb) {cb();};
|
||||
n._sendToOne = function(a1, a2, a3, cb) {
|
||||
cb();
|
||||
};
|
||||
var sig = undefined;
|
||||
n.send(copayerIds, data, function() {
|
||||
done();
|
||||
|
|
|
|||
|
|
@ -17,12 +17,18 @@ describe('Storage/File', function() {
|
|||
var fs = {}
|
||||
fs.readFile = function(filename, callback) {
|
||||
filename.should.equal('myfilename');
|
||||
var obj = {"test":"test"};
|
||||
var obj = {
|
||||
"test": "test"
|
||||
};
|
||||
var encryptedStr = CryptoJS.AES.encrypt(JSON.stringify(obj), "password").toString();
|
||||
callback(null, encryptedStr);
|
||||
};
|
||||
var Storage = require('soop').load('../js/models/storage/File.js', {fs: fs});
|
||||
var storage = new Storage({password: 'password'});
|
||||
var Storage = require('soop').load('../js/models/storage/File.js', {
|
||||
fs: fs
|
||||
});
|
||||
var storage = new Storage({
|
||||
password: 'password'
|
||||
});
|
||||
storage.load('myfilename', function(err) {
|
||||
done();
|
||||
});
|
||||
|
|
@ -36,8 +42,12 @@ describe('Storage/File', function() {
|
|||
filename.should.equal('myfilename');
|
||||
callback();
|
||||
};
|
||||
var Storage = require('soop').load('../js/models/storage/File.js', {fs: fs});
|
||||
var storage = new Storage({password: 'password'});
|
||||
var Storage = require('soop').load('../js/models/storage/File.js', {
|
||||
fs: fs
|
||||
});
|
||||
var storage = new Storage({
|
||||
password: 'password'
|
||||
});
|
||||
storage.save('myfilename', function(err) {
|
||||
done();
|
||||
});
|
||||
|
|
@ -47,7 +57,11 @@ describe('Storage/File', function() {
|
|||
describe('#_read', function() {
|
||||
it('should return the value of a key', function() {
|
||||
var storage = new Storage();
|
||||
storage.data = {'walletId':{'test':'data'}};
|
||||
storage.data = {
|
||||
'walletId': {
|
||||
'test': 'data'
|
||||
}
|
||||
};
|
||||
storage._read('walletId::test').should.equal('data');
|
||||
});
|
||||
});
|
||||
|
|
@ -68,7 +82,11 @@ describe('Storage/File', function() {
|
|||
describe('#getGlobal', function() {
|
||||
it('should call storage._read', function() {
|
||||
var storage = new Storage();
|
||||
storage.data = {'walletId':{'test':'test'}};
|
||||
storage.data = {
|
||||
'walletId': {
|
||||
'test': 'test'
|
||||
}
|
||||
};
|
||||
storage._read = sinon.spy();
|
||||
storage.getGlobal('walletId::test');
|
||||
storage._read.calledOnce.should.equal(true);
|
||||
|
|
@ -91,7 +109,11 @@ describe('Storage/File', function() {
|
|||
describe('#removeGlobal', function() {
|
||||
it('should remove a global key', function(done) {
|
||||
var storage = new Storage();
|
||||
storage.data = {'walletId':{'key':'value'}};
|
||||
storage.data = {
|
||||
'walletId': {
|
||||
'key': 'value'
|
||||
}
|
||||
};
|
||||
storage.save = function(walletId, callback) {
|
||||
should.not.exist(storage.data[walletId]['key']);
|
||||
callback();
|
||||
|
|
@ -141,7 +163,9 @@ describe('Storage/File', function() {
|
|||
|
||||
describe('#setFromObj', function() {
|
||||
it('should set this object for a wallet', function(done) {
|
||||
var obj = {test:'testval'};
|
||||
var obj = {
|
||||
test: 'testval'
|
||||
};
|
||||
var storage = new Storage();
|
||||
storage.save = function(walletId, callback) {
|
||||
callback();
|
||||
|
|
@ -155,12 +179,16 @@ describe('Storage/File', function() {
|
|||
|
||||
describe('#getEncryptedObj', function() {
|
||||
it('should give an encrypted object', function() {
|
||||
var obj = {test:'testval'};
|
||||
var obj = {
|
||||
test: 'testval'
|
||||
};
|
||||
var data = JSON.stringify(obj);
|
||||
var encrypted = CryptoJS.AES.encrypt(data, 'password');
|
||||
var base64 = encrypted.toString();
|
||||
|
||||
var storage = new Storage({password: 'password'});
|
||||
var storage = new Storage({
|
||||
password: 'password'
|
||||
});
|
||||
storage.data['walletId'] = obj;
|
||||
|
||||
var enc = storage.getEncryptedObj('walletId');
|
||||
|
|
|
|||
|
|
@ -38,11 +38,17 @@ if (typeof process === 'undefined' || !process.version) {
|
|||
1, 1000, -15, -1000,
|
||||
0.1, -0.5, -0.5e-10, Math.PI,
|
||||
'hi', 'auydoaiusyodaisudyoa', '0b5b8556a0c2ce828c9ccfa58b3dd0a1ae879b9b',
|
||||
'1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC', 'OP_DUP OP_HASH160 80ad90d4035',
|
||||
[1,2,3,4,5,6],
|
||||
{ x: 1, y: 2},
|
||||
{ x: 'hi', y: null},
|
||||
{ a: {}, b: [], c: [1,2,'hi']},
|
||||
'1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC', 'OP_DUP OP_HASH160 80ad90d4035', [1, 2, 3, 4, 5, 6], {
|
||||
x: 1,
|
||||
y: 2
|
||||
}, {
|
||||
x: 'hi',
|
||||
y: null
|
||||
}, {
|
||||
a: {},
|
||||
b: [],
|
||||
c: [1, 2, 'hi']
|
||||
},
|
||||
null
|
||||
];
|
||||
getSetData.forEach(function(obj) {
|
||||
|
|
@ -56,9 +62,13 @@ if (typeof process === 'undefined' || !process.version) {
|
|||
|
||||
describe('#export', function() {
|
||||
it('should export the encrypted wallet', function() {
|
||||
var storage = new LocalEncrypted({password: 'password'});
|
||||
var storage = new LocalEncrypted({
|
||||
password: 'password'
|
||||
});
|
||||
storage.set(fakeWallet, timeStamp, 'testval');
|
||||
var obj = {test:'testval'};
|
||||
var obj = {
|
||||
test: 'testval'
|
||||
};
|
||||
var encrypted = storage.export(obj);
|
||||
encrypted.length.should.be.greaterThan(10);
|
||||
localStorage.removeItem(fakeWallet + '::' + timeStamp);
|
||||
|
|
|
|||
|
|
@ -131,7 +131,8 @@ describe("Unit: Controllers", function() {
|
|||
newlabel: null,
|
||||
};
|
||||
$compile(element)(scope);
|
||||
$controller('SendController', {$scope: scope,
|
||||
$controller('SendController', {
|
||||
$scope: scope,
|
||||
$modal: {},
|
||||
});
|
||||
scope.$digest();
|
||||
|
|
|
|||
|
|
@ -85,7 +85,11 @@ describe("Unit: Testing Directives", function() {
|
|||
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
$rootScope.wallet = {
|
||||
addressBook: {'2MtBXKLtZuXGDshUcyH6yq7aZ33Snbb49pT': {label: ':)'}}
|
||||
addressBook: {
|
||||
'2MtBXKLtZuXGDshUcyH6yq7aZ33Snbb49pT': {
|
||||
label: ':)'
|
||||
}
|
||||
}
|
||||
}
|
||||
element1 = angular.element(
|
||||
'<contact address="2MtBXKLtZuXGDshUcyH6yq7aZ33Snbb49pT" />'
|
||||
|
|
|
|||
|
|
@ -22,16 +22,31 @@ describe('Unit: Testing Filters', function() {
|
|||
|
||||
it('should filter correctly', inject(function($filter) {
|
||||
var limitAddress = $filter('limitAddress');
|
||||
var addresses = [
|
||||
{isChange: true, balance: 0},
|
||||
{isChange: false, balance: 0},
|
||||
{isChange: true, balance: 0},
|
||||
{isChange: false, balance: 0},
|
||||
{isChange: true, balance: 0},
|
||||
{isChange: false, balance: 0},
|
||||
{isChange: true, balance: 0},
|
||||
{isChange: false, balance: 0}
|
||||
];
|
||||
var addresses = [{
|
||||
isChange: true,
|
||||
balance: 0
|
||||
}, {
|
||||
isChange: false,
|
||||
balance: 0
|
||||
}, {
|
||||
isChange: true,
|
||||
balance: 0
|
||||
}, {
|
||||
isChange: false,
|
||||
balance: 0
|
||||
}, {
|
||||
isChange: true,
|
||||
balance: 0
|
||||
}, {
|
||||
isChange: false,
|
||||
balance: 0
|
||||
}, {
|
||||
isChange: true,
|
||||
balance: 0
|
||||
}, {
|
||||
isChange: false,
|
||||
balance: 0
|
||||
}];
|
||||
expect(limitAddress(addresses, false).length).to.equal(1);
|
||||
|
||||
addresses[0].isChange = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue