resolved
This commit is contained in:
parent
94221a312f
commit
81a73e6f2a
5 changed files with 51 additions and 12 deletions
|
|
@ -632,6 +632,14 @@ Wallet.prototype.getMyCopayerIdPriv = function() {
|
||||||
return this.privateKey.getIdPriv(); //copayer idpriv is hex of a private key
|
return this.privateKey.getIdPriv(); //copayer idpriv is hex of a private key
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc Get my own nickname
|
||||||
|
* @return {string} copayer nickname
|
||||||
|
*/
|
||||||
|
Wallet.prototype.getMyCopayerNickname = function() {
|
||||||
|
return this.publicKeyRing.nicknameForCopayer(this.getMyCopayerId());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc Returns the secret value for other users to join this wallet
|
* @desc Returns the secret value for other users to join this wallet
|
||||||
* @return {string} my own pubkey, base58 encoded
|
* @return {string} my own pubkey, base58 encoded
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,17 @@ BackupService.prototype.getName = function(wallet) {
|
||||||
return (wallet.name ? (wallet.name + '-') : '') + wallet.id;
|
return (wallet.name ? (wallet.name + '-') : '') + wallet.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BackupService.prototype.getCopayer = function(wallet) {
|
||||||
|
return wallet.getMyCopayerNickname();
|
||||||
|
};
|
||||||
|
|
||||||
BackupService.prototype.download = function(wallet) {
|
BackupService.prototype.download = function(wallet) {
|
||||||
var ew = wallet.toEncryptedObj();
|
var ew = wallet.toEncryptedObj();
|
||||||
var partial = !wallet.publicKeyRing.isComplete();
|
var walletName = this.getName(wallet);
|
||||||
var walletName = this.getName(wallet) + (partial ? '-Partial' : '');
|
var copayerName = this.getCopayer(wallet);
|
||||||
var filename = walletName + '-keybackup.json.aes';
|
var filename = copayerName + '-' + walletName + '-keybackup.json.aes';
|
||||||
|
|
||||||
var notify = partial ? 'Partial backup created' : 'Backup created';
|
this.notifications.success('Backup created', 'Encrypted backup file saved.');
|
||||||
this.notifications.success(notify, 'Encrypted backup file saved.');
|
|
||||||
var blob = new Blob([ew], {
|
var blob = new Blob([ew], {
|
||||||
type: 'text/plain;charset=utf-8'
|
type: 'text/plain;charset=utf-8'
|
||||||
});
|
});
|
||||||
|
|
@ -32,9 +35,8 @@ BackupService.prototype.download = function(wallet) {
|
||||||
// throw an email intent if we are in the mobile version
|
// throw an email intent if we are in the mobile version
|
||||||
if (window.cordova) {
|
if (window.cordova) {
|
||||||
var name = wallet.name ? wallet.name + ' ' : '';
|
var name = wallet.name ? wallet.name + ' ' : '';
|
||||||
var partial = partial ? 'Partial ' : '';
|
|
||||||
return window.plugin.email.open({
|
return window.plugin.email.open({
|
||||||
subject: 'Copay - ' + name + 'Wallet ' + partial + 'Backup',
|
subject: 'Copay - ' + name + 'Wallet ' + 'Backup',
|
||||||
body: 'Here is the encrypted backup of the wallet ' + wallet.id,
|
body: 'Here is the encrypted backup of the wallet ' + wallet.id,
|
||||||
attachments: ['base64:' + filename + '//' + btoa(ew)]
|
attachments: ['base64:' + filename + '//' + btoa(ew)]
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ var FakeWallet = function() {
|
||||||
'1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC': 1000
|
'1CjPR7Z5ZSyWk6WtXvSFgkptmpoi4UM9BC': 1000
|
||||||
};
|
};
|
||||||
this.name = 'myTESTwullet';
|
this.name = 'myTESTwullet';
|
||||||
|
this.nickname = 'myNickname';
|
||||||
this.addressBook = {
|
this.addressBook = {
|
||||||
'2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ': {
|
'2NFR2kzH9NUdp8vsXTB4wWQtTtzhpKxsyoJ': {
|
||||||
label: 'John',
|
label: 'John',
|
||||||
|
|
@ -86,6 +87,10 @@ FakeWallet.prototype.getAddressesInfo = function() {
|
||||||
|
|
||||||
FakeWallet.prototype.subscribeToAddresses = function() {};
|
FakeWallet.prototype.subscribeToAddresses = function() {};
|
||||||
|
|
||||||
|
FakeWallet.prototype.getMyCopayerNickname = function() {
|
||||||
|
return this.nickname;
|
||||||
|
};
|
||||||
|
|
||||||
FakeWallet.prototype.isShared = function() {
|
FakeWallet.prototype.isShared = function() {
|
||||||
return this.totalCopayers > 1;
|
return this.totalCopayers > 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1221,6 +1221,15 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getMyCopayerNickname', function() {
|
||||||
|
it('should call publicKeyRing.nicknameForCopayer', function() {
|
||||||
|
var w = cachedCreateW2();
|
||||||
|
w.publicKeyRing.nicknameForCopayer = sinon.spy();
|
||||||
|
w.getMyCopayerNickname();
|
||||||
|
w.publicKeyRing.nicknameForCopayer.calledOnce.should.equal(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#netStart', function() {
|
describe('#netStart', function() {
|
||||||
it('should call Network.start', function() {
|
it('should call Network.start', function() {
|
||||||
var w = cachedCreateW2();
|
var w = cachedCreateW2();
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
|
|
||||||
// Replace saveAs plugin
|
// Replace saveAs plugin
|
||||||
saveAsLastCall = null;
|
saveAs = function(blob, filename) {
|
||||||
saveAs = function(o) {
|
saveAsLastCall = {
|
||||||
saveAsLastCall = o;
|
blob: blob,
|
||||||
|
filename: filename
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var startServer = require('../../mocks/FakePayProServer');
|
var startServer = require('../../mocks/FakePayProServer');
|
||||||
|
|
@ -35,6 +37,11 @@ describe("Unit: Controllers", function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('More Controller', function() {
|
describe('More Controller', function() {
|
||||||
|
it('Copay config should be binded', function() {
|
||||||
|
should.exist(config);
|
||||||
|
should.exist(config.unitToSatoshi);
|
||||||
|
});
|
||||||
|
|
||||||
var ctrl;
|
var ctrl;
|
||||||
beforeEach(inject(function($controller, $rootScope) {
|
beforeEach(inject(function($controller, $rootScope) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
|
@ -44,14 +51,22 @@ describe("Unit: Controllers", function() {
|
||||||
$scope: scope,
|
$scope: scope,
|
||||||
$modal: {},
|
$modal: {},
|
||||||
});
|
});
|
||||||
|
saveAsLastCall = null;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('Backup controller #download', function() {
|
it('Backup controller #download', function() {
|
||||||
scope.wallet.setEnc('1234567');
|
scope.wallet.setEnc('1234567');
|
||||||
expect(saveAsLastCall).equal(null);
|
expect(saveAsLastCall).equal(null);
|
||||||
scope.downloadBackup();
|
scope.downloadBackup();
|
||||||
expect(saveAsLastCall.size).equal(7);
|
expect(saveAsLastCall.blob.size).equal(7);
|
||||||
expect(saveAsLastCall.type).equal('text/plain;charset=utf-8');
|
expect(saveAsLastCall.blob.type).equal('text/plain;charset=utf-8');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Backup controller should name backup correctly', function() {
|
||||||
|
scope.wallet.setEnc('1234567');
|
||||||
|
expect(saveAsLastCall).equal(null);
|
||||||
|
scope.downloadBackup();
|
||||||
|
expect(saveAsLastCall.filename).equal('myNickname-myTESTwullet-testID-keybackup.json.aes');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Backup controller #delete', function() {
|
it('Backup controller #delete', function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue