fix conflics
This commit is contained in:
commit
cd71ce4421
25 changed files with 268 additions and 122 deletions
|
|
@ -26,13 +26,13 @@ var copayApp = window.copayApp = angular.module('copayApp',[
|
|||
'monospaced.qrcode',
|
||||
'notifications',
|
||||
'copayApp.filters',
|
||||
'copayApp.services',
|
||||
'copayApp.controllers',
|
||||
'copayApp.directives',
|
||||
'copayApp.services',
|
||||
]);
|
||||
|
||||
angular.module('copayApp.filters', []);
|
||||
angular.module('copayApp.services', []);
|
||||
angular.module('copayApp.controllers', []);
|
||||
angular.module('copayApp.directives', []);
|
||||
angular.module('copayApp.services', []);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,32 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('BackupController',
|
||||
function($scope, $rootScope, $location, $window, $timeout, $modal, controllerUtils, walletFactory) {
|
||||
function($scope, $rootScope, $location, $window, $timeout, $modal, backupService, walletFactory, controllerUtils) {
|
||||
$scope.title = 'Backup';
|
||||
|
||||
var _getEncryptedWallet = function() {
|
||||
var wallet = $rootScope.wallet.toEncryptedObj();
|
||||
return wallet;
|
||||
};
|
||||
|
||||
$scope.download = function() {
|
||||
var timestamp = +(new Date);
|
||||
var walletName = ($rootScope.wallet.name ? $rootScope.wallet.name : '') + '-' + $rootScope.wallet.id;
|
||||
var filename = walletName + '-' + timestamp + '.json.aes';
|
||||
var wallet = _getEncryptedWallet();
|
||||
var blob = new Blob([wallet], {
|
||||
type: 'text/plain;charset=utf-8'
|
||||
});
|
||||
// show a native save dialog if we are in the shell
|
||||
// and pass the wallet to the shell to convert to node Buffer
|
||||
if (window.cshell) {
|
||||
return window.cshell.send('backup:download', {
|
||||
name: walletName,
|
||||
wallet: wallet
|
||||
});
|
||||
}
|
||||
// otherwise lean on the browser implementation
|
||||
saveAs(blob, filename);
|
||||
backupService.download($rootScope.wallet);
|
||||
};
|
||||
|
||||
$scope.openModal = function() {
|
||||
|
|
@ -35,7 +14,9 @@ angular.module('copayApp.controllers').controller('BackupController',
|
|||
controller: ModalInstanceCtrl,
|
||||
});
|
||||
|
||||
modalInstance.result.then(sendEmail);
|
||||
modalInstance.result.then(function(email) {
|
||||
backupService.sendEmail(email, $rootScope.wallet);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteWallet = function() {
|
||||
|
|
@ -46,23 +27,6 @@ angular.module('copayApp.controllers').controller('BackupController',
|
|||
});
|
||||
};
|
||||
|
||||
var sendEmail = function(email) {
|
||||
var body = _getEncryptedWallet();
|
||||
var subject = ($rootScope.wallet.name ? $rootScope.wallet.name + ' - ' : '') + $rootScope.wallet.id;
|
||||
var href = 'mailto:' + email + '?' + 'subject=[Copay Backup] ' + subject + '&' + 'body=' + body;
|
||||
|
||||
if (window.cshell) {
|
||||
return window.cshell.send('backup:email', href);
|
||||
}
|
||||
|
||||
var newWin = $window.open(href, '_blank', 'scrollbars=yes,resizable=yes,width=10,height=10');
|
||||
|
||||
if (newWin) {
|
||||
$timeout(function() {
|
||||
newWin.close();
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HeaderController',
|
||||
function($scope, $rootScope, $location, $notification, $http, walletFactory, controllerUtils) {
|
||||
function($scope, $rootScope, $location, $notification, $http, controllerUtils) {
|
||||
$scope.menu = [
|
||||
{
|
||||
'title': 'Addresses',
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ var valid_pairs = {
|
|||
};
|
||||
|
||||
angular.module('copayApp.controllers').controller('SetupController',
|
||||
function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase) {
|
||||
function($scope, $rootScope, $location, $timeout, walletFactory, controllerUtils, Passphrase, backupService) {
|
||||
|
||||
$rootScope.videoInfo = {};
|
||||
$scope.loading = false;
|
||||
|
|
@ -84,6 +84,7 @@ angular.module('copayApp.controllers').controller('SetupController',
|
|||
passphrase: passphrase,
|
||||
};
|
||||
var w = walletFactory.create(opts);
|
||||
backupService.download(w);
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('SigninController',
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase) {
|
||||
var cmp = function(o1, o2){
|
||||
var v1 = o1.show.toLowerCase(), v2 = o2.show.toLowerCase();
|
||||
return v1 > v2 ? 1 : ( v1 < v2 ) ? -1 : 0;
|
||||
function($scope, $rootScope, $location, walletFactory, controllerUtils, Passphrase, backupService) {
|
||||
var cmp = function(o1, o2) {
|
||||
var v1 = o1.show.toLowerCase(),
|
||||
v2 = o2.show.toLowerCase();
|
||||
return v1 > v2 ? 1 : (v1 < v2) ? -1 : 0;
|
||||
};
|
||||
$rootScope.videoInfo = {};
|
||||
$scope.loading = false;
|
||||
|
|
@ -14,23 +15,31 @@ angular.module('copayApp.controllers').controller('SigninController',
|
|||
|
||||
$scope.open = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
$rootScope.$flashMessage = { message: 'Please, enter required fields', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Please, enter required fields',
|
||||
type: 'error'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$scope.loading = true;
|
||||
var password = form.openPassword.$modelValue;
|
||||
|
||||
Passphrase.getBase64Async(password, function(passphrase){
|
||||
Passphrase.getBase64Async(password, function(passphrase) {
|
||||
var w, errMsg;
|
||||
try{
|
||||
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
|
||||
} catch (e){
|
||||
try {
|
||||
var w = walletFactory.open($scope.selectedWalletId, {
|
||||
passphrase: passphrase
|
||||
});
|
||||
} catch (e) {
|
||||
errMsg = e.message;
|
||||
};
|
||||
if (!w) {
|
||||
$scope.loading = false;
|
||||
$rootScope.$flashMessage = { message: errMsg || 'Wrong password', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: errMsg || 'Wrong password',
|
||||
type: 'error'
|
||||
};
|
||||
$rootScope.$digest();
|
||||
return;
|
||||
}
|
||||
|
|
@ -40,31 +49,48 @@ angular.module('copayApp.controllers').controller('SigninController',
|
|||
|
||||
$scope.join = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
$rootScope.$flashMessage = { message: 'Please, enter required fields', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Please, enter required fields',
|
||||
type: 'error'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
walletFactory.network.on('badSecret', function() {
|
||||
});
|
||||
walletFactory.network.on('badSecret', function() {});
|
||||
|
||||
Passphrase.getBase64Async($scope.joinPassword, function(passphrase){
|
||||
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, function(err,w) {
|
||||
Passphrase.getBase64Async($scope.joinPassword, function(passphrase) {
|
||||
walletFactory.joinCreateSession($scope.connectionId, $scope.nickname, passphrase, function(err, w) {
|
||||
$scope.loading = false;
|
||||
if (err || !w) {
|
||||
if (err === 'joinError')
|
||||
$rootScope.$flashMessage = { message: 'Can not find peer'};
|
||||
if (err === 'joinError')
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Can\'t find peer'
|
||||
};
|
||||
else if (err === 'walletFull')
|
||||
$rootScope.$flashMessage = { message: 'The wallet is full', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'The wallet is full',
|
||||
type: 'error'
|
||||
};
|
||||
else if (err === 'badNetwork')
|
||||
$rootScope.$flashMessage = { message: 'The wallet your are trying to join uses a different Bitcoin Network. Check your settings.', type: 'error'};
|
||||
else if (err === 'badSecret')
|
||||
$rootScope.$flashMessage = { message: 'Bad secret secret string', type: 'error'};
|
||||
else
|
||||
$rootScope.$flashMessage = { message: 'Unknown error', type: 'error'};
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'The wallet your are trying to join uses a different Bitcoin Network. Check your settings.',
|
||||
type: 'error'
|
||||
};
|
||||
else if (err === 'badSecret')
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Bad secret secret string',
|
||||
type: 'error'
|
||||
};
|
||||
else
|
||||
$rootScope.$flashMessage = {
|
||||
message: 'Unknown error',
|
||||
type: 'error'
|
||||
};
|
||||
controllerUtils.onErrorDigest();
|
||||
} else {
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
backupService.download(w);
|
||||
controllerUtils.startNetwork(w, $scope);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
var imports = require('soop').imports();
|
||||
var Storage = imports.Storage;
|
||||
var Network = imports.Network;
|
||||
var Blockchain = imports.Blockchain;
|
||||
|
||||
var TxProposals = require('./TxProposals');
|
||||
var PublicKeyRing = require('./PublicKeyRing');
|
||||
var PrivateKey = require('./PrivateKey');
|
||||
var Wallet = require('./Wallet');
|
||||
|
||||
var WebRTC = module.exports.WebRTC = require('../network/WebRTC');
|
||||
var Insight = module.exports.Insight = require('../blockchain/Insight');
|
||||
//var StorageLocalPlain = module.exports.StorageLocalPlain = require('../storage/LocalPlain');
|
||||
var StorageLocalEncrypted = module.exports.StorageLocalEncrypted = require('../storage/LocalEncrypted');
|
||||
|
||||
/*
|
||||
* WalletFactory
|
||||
*
|
||||
|
|
@ -19,9 +21,13 @@ function WalletFactory(config, version) {
|
|||
var self = this;
|
||||
config = config || {};
|
||||
|
||||
this.storage = config.storageObj || new Storage(config.storage);
|
||||
this.network = config.networkObj || new Network(config.network);
|
||||
this.blockchain = config.blockchainObj || new Blockchain(config.blockchain);
|
||||
this.Storage = config.Storage || StorageLocalEncrypted;
|
||||
this.Network = config.Network || WebRTC;
|
||||
this.Blockchain = config.Blockchain || Insight;
|
||||
|
||||
this.storage = new this.Storage(config.storage);
|
||||
this.network = new this.Network(config.network);
|
||||
this.blockchain = new this.Blockchain(config.blockchain);
|
||||
|
||||
this.networkName = config.networkName;
|
||||
this.verbose = config.verbose;
|
||||
|
|
|
|||
47
js/services/backupService.js
Normal file
47
js/services/backupService.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
|
||||
var BackupService = function() {};
|
||||
|
||||
BackupService.prototype.getName = function(wallet) {
|
||||
return (wallet.name ? (wallet.name+'-') : '') + wallet.id;
|
||||
};
|
||||
|
||||
BackupService.prototype.download = function(wallet) {
|
||||
var ew = wallet.toEncryptedObj();
|
||||
var timestamp = +(new Date());
|
||||
var walletName = this.getName(wallet);
|
||||
var filename = walletName + '-' + timestamp + '-keybackup.json.aes';
|
||||
var blob = new Blob([ew], {
|
||||
type: 'text/plain;charset=utf-8'
|
||||
});
|
||||
// show a native save dialog if we are in the shell
|
||||
// and pass the wallet to the shell to convert to node Buffer
|
||||
if (window.cshell) {
|
||||
return window.cshell.send('backup:download', {
|
||||
name: walletName,
|
||||
wallet: ew
|
||||
});
|
||||
}
|
||||
// otherwise lean on the browser implementation
|
||||
saveAs(blob, filename);
|
||||
};
|
||||
|
||||
BackupService.prototype.sendEmail = function(email, wallet) {
|
||||
var ew = wallet.toEncryptedObj();
|
||||
var body = ew;
|
||||
var subject = this.getName(wallet);
|
||||
var href = 'mailto:' + email + '?' + 'subject=[Copay Backup] ' + subject + '&' + 'body=' + body;
|
||||
|
||||
if (window.cshell) {
|
||||
return window.cshell.send('backup:email', href);
|
||||
}
|
||||
|
||||
var newWin = window.open(href, '_blank', 'scrollbars=yes,resizable=yes,width=10,height=10');
|
||||
if (newWin) {
|
||||
setTimeout(function() {
|
||||
newWin.close();
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
angular.module('copayApp.services').value('backupService', new BackupService());
|
||||
Loading…
Add table
Add a link
Reference in a new issue