Hold on backup page until all copayers made a full backup
This commit is contained in:
parent
f9fad5d62f
commit
49ac6dfcf4
4 changed files with 48 additions and 11 deletions
13
index.html
13
index.html
|
|
@ -140,10 +140,11 @@
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<div class="line-dashed"></div>
|
<div class="line-dashed"></div>
|
||||||
<button class="button primary radius right"
|
<button class="button primary radius right"
|
||||||
ng-click="backupAndOpen()"
|
ng-click="backup()"
|
||||||
|
ng-show="!$root.wallet.publicKeyRing.isBackupReady()"
|
||||||
ng-disabled="!$root.wallet.publicKeyRing.isComplete()">
|
ng-disabled="!$root.wallet.publicKeyRing.isComplete()">
|
||||||
<span ng-show="$root.wallet.publicKeyRing.isComplete()" >
|
<span ng-show="$root.wallet.publicKeyRing.isComplete()" >
|
||||||
Backup keys and continue
|
Backup keys
|
||||||
</span>
|
</span>
|
||||||
<span ng-show="!$root.wallet.publicKeyRing.isComplete()" >
|
<span ng-show="!$root.wallet.publicKeyRing.isComplete()" >
|
||||||
<span ng-show="$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers()>1">
|
<span ng-show="$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers()>1">
|
||||||
|
|
@ -154,10 +155,12 @@
|
||||||
</span>
|
</span>
|
||||||
yet to join.
|
yet to join.
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
|
||||||
</button>
|
</button>
|
||||||
<!-- <a href="" class="db p10t left" ng-disabled="!$root.wallet.publicKeyRing.isComplete()">Skip Backup</a> -->
|
<button class="button primary radius right"
|
||||||
|
disabled="disabled"
|
||||||
|
ng-show="$root.wallet.publicKeyRing.isBackupReady()">
|
||||||
|
Waiting for copayers to backup
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,10 @@ angular.module('copayApp.controllers').controller('HeaderController',
|
||||||
window.onbeforeunload = undefined;
|
window.onbeforeunload = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.backupAndOpen = function() {
|
$scope.backup = function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
w.offerBackup();
|
|
||||||
backupService.download(w);
|
backupService.download(w);
|
||||||
|
w.setBackupReady();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getVideoURL = function(copayer) {
|
$scope.getVideoURL = function(copayer) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ function PublicKeyRing(opts) {
|
||||||
this.publicKeysCache = opts.publicKeysCache || {};
|
this.publicKeysCache = opts.publicKeysCache || {};
|
||||||
this.nicknameFor = opts.nicknameFor || {};
|
this.nicknameFor = opts.nicknameFor || {};
|
||||||
this.copayerIds = [];
|
this.copayerIds = [];
|
||||||
|
this.copayersBackup = opts.copayersBackup || [];
|
||||||
this.addressToPath = {};
|
this.addressToPath = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,6 +60,7 @@ PublicKeyRing.prototype.toObj = function() {
|
||||||
requiredCopayers: this.requiredCopayers,
|
requiredCopayers: this.requiredCopayers,
|
||||||
totalCopayers: this.totalCopayers,
|
totalCopayers: this.totalCopayers,
|
||||||
indexes: AddressIndex.serialize(this.indexes),
|
indexes: AddressIndex.serialize(this.indexes),
|
||||||
|
copayersBackup: this.copayersBackup,
|
||||||
|
|
||||||
copayersExtPubKeys: this.copayersHK.map(function(b) {
|
copayersExtPubKeys: this.copayersHK.map(function(b) {
|
||||||
return b.extendedPublicKeyString();
|
return b.extendedPublicKeyString();
|
||||||
|
|
@ -350,12 +352,30 @@ PublicKeyRing.prototype._mergePubkeys = function(inPKR) {
|
||||||
return hasChanged;
|
return hasChanged;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.setBackupReady = function(copayerId) {
|
||||||
|
if (this.isBackupReady()) return false;
|
||||||
|
|
||||||
|
var cid = this.myCopayerId();
|
||||||
|
this.copayersBackup.push(cid);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.isBackupReady = function(copayerId) {
|
||||||
|
var cid = this.myCopayerId();
|
||||||
|
return this.copayersBackup.indexOf(cid) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.isFullyBackup = function(copayerId) {
|
||||||
|
return this.copayersBackup.length == this.totalCopayers;
|
||||||
|
}
|
||||||
|
|
||||||
PublicKeyRing.prototype.merge = function(inPKR, ignoreId) {
|
PublicKeyRing.prototype.merge = function(inPKR, ignoreId) {
|
||||||
this._checkInPKR(inPKR, ignoreId);
|
this._checkInPKR(inPKR, ignoreId);
|
||||||
|
|
||||||
var hasChanged = false;
|
var hasChanged = false;
|
||||||
hasChanged |= this.mergeIndexes(inPKR.indexes);
|
hasChanged |= this.mergeIndexes(inPKR.indexes);
|
||||||
hasChanged |= this._mergePubkeys(inPKR);
|
hasChanged |= this._mergePubkeys(inPKR);
|
||||||
|
hasChanged |= this.mergeBackups(inPKR.copayersBackup);
|
||||||
|
|
||||||
return !!hasChanged;
|
return !!hasChanged;
|
||||||
};
|
};
|
||||||
|
|
@ -372,4 +392,18 @@ PublicKeyRing.prototype.mergeIndexes = function(indexes) {
|
||||||
return !!hasChanged
|
return !!hasChanged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PublicKeyRing.prototype.mergeBackups = function(backups) {
|
||||||
|
var self = this;
|
||||||
|
var hasChanged = false;
|
||||||
|
|
||||||
|
backups.forEach(function(cid) {
|
||||||
|
var isNew = self.copayersBackup.indexOf(cid) == -1;
|
||||||
|
if (isNew) self.copayersBackup.push(cid);
|
||||||
|
hasChanged |= isNew;
|
||||||
|
});
|
||||||
|
|
||||||
|
return !!hasChanged
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = require('soop')(PublicKeyRing);
|
module.exports = require('soop')(PublicKeyRing);
|
||||||
|
|
|
||||||
|
|
@ -879,13 +879,13 @@ Wallet.prototype.toggleAddressBookEntry = function(key) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.isReady = function() {
|
Wallet.prototype.isReady = function() {
|
||||||
var ret = this.publicKeyRing.isComplete() && this.backupOffered;
|
var ret = this.publicKeyRing.isComplete() && this.publicKeyRing.isFullyBackup();
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.offerBackup = function() {
|
Wallet.prototype.setBackupReady = function() {
|
||||||
this.backupOffered = true;
|
this.publicKeyRing.setBackupReady();
|
||||||
this.store();
|
this.emit('publicKeyRingUpdated', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.signJson = function(payload) {
|
Wallet.prototype.signJson = function(payload) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue