Merge pull request #3881 from JDonadio/bug/send-without-backup

fix send payments to destination address without backup
This commit is contained in:
Gustavo Maximiliano Cortez 2016-02-23 11:05:33 -03:00
commit 8cc46f9b7e
4 changed files with 30 additions and 26 deletions

View file

@ -395,7 +395,11 @@
<i class="icon-close-circle size-14"></i> <i class="icon-close-circle size-14"></i>
<span class="vm" translate>Not valid</span> <span class="vm" translate>Not valid</span>
</span> </span>
<small class="right text-primary" ng-show="!sendForm.address.$invalid"> <span class="has-error right size-12" ng-show="home.destinationWalletNeedsBackup">
<i class="icon-close-circle size-14"></i>
<span class="vm" translate>Destination wallet needs backup</span>
</span>
<small class="right text-primary" ng-show="!sendForm.address.$invalid && !home.destinationWalletNeedsBackup">
<i class="icon-checkmark-circle size-14"></i> <i class="icon-checkmark-circle size-14"></i>
</small> </small>
</span> </span>
@ -479,8 +483,8 @@
<a fast-click callback-fn="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a> <a fast-click callback-fn="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
</div> </div>
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}"> <div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}">
<button class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline || (home.paymentExpired && home._paypro)" <button class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline || home.destinationWalletNeedsBackup"
ng-style="{'background-color':index.backgroundColor}" fast-click callback-fn="home.submitForm()" translate> ng-style="{'background-color':index.backgroundColor}" fast-click callback-fn="home.submitForm()" translate>
Send Send
</button> </button>
</div> </div>

View file

@ -137,20 +137,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.initGlidera(); self.initGlidera();
self.setCustomBWSFlag(); self.setCustomBWSFlag();
profileService.isBackupNeeded(self.walletId, function(needsBackup) {
$rootScope.$apply(); self.needsBackup = needsBackup;
if (fc.isPrivKeyExternal()) {
self.needsBackup = false;
self.openWallet(); self.openWallet();
} else { });
storageService.getBackupFlag(self.walletId, function(err, val) {
if (!fc.credentials.mnemonic)
self.needsBackup = false;
else
self.needsBackup = self.network == 'testnet' ? false : !val;
self.openWallet();
});
}
}); });
}; };
@ -1275,7 +1265,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.needsBackup = false; self.needsBackup = false;
$log.debug('Backup done'); $log.debug('Backup done');
storageService.setBackupFlag(walletId || self.walletId, function(err) { storageService.setBackupFlag(walletId || self.walletId, function(err) {
$log.debug('Backup done stored'); $log.debug('Backup stored');
}); });
}); });

View file

@ -25,8 +25,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
ret.isWindowsPhoneApp = isMobile.Windows() && isCordova; ret.isWindowsPhoneApp = isMobile.Windows() && isCordova;
var vanillaScope = ret; var vanillaScope = ret;
var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) { var disableScannerListener = $rootScope.$on('dataScanned', function(event, data) {
self.setForm(data); self.setForm(data);
$rootScope.$emit('Local/SetTab', 'send'); $rootScope.$emit('Local/SetTab', 'send');
@ -94,8 +92,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$rootScope.shouldHideMenuBar = false; $rootScope.shouldHideMenuBar = false;
}); });
this.onQrCodeScanned = function(data) { this.onQrCodeScanned = function(data) {
if (data) go.send(); if (data) go.send();
$rootScope.$emit('dataScanned', data); $rootScope.$emit('dataScanned', data);
@ -124,6 +120,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var confirm_msg = gettextCatalog.getString('Confirm'); var confirm_msg = gettextCatalog.getString('Confirm');
this.openDestinationAddressModal = function(wallets, address) { this.openDestinationAddressModal = function(wallets, address) {
self.destinationWalletNeedsBackup = null;
$rootScope.modalOpened = true; $rootScope.modalOpened = true;
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
self.lockAddress = false; self.lockAddress = false;
@ -252,7 +249,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return; return;
} }
$modalInstance.close(addr); profileService.isBackupNeeded(walletId, function(needsBackup) {
self.destinationWalletNeedsBackup = needsBackup;
$modalInstance.close(addr);
});
}); });
}; };
}; };
@ -984,11 +984,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
} }
}; };
this.resetForm = function() { this.resetForm = function() {
this.resetError(); this.resetError();
this.paymentExpired = false; this.destinationWalletNeedsBackup = null;
this._paypro = null; this._paypro = null;
this.lockedCurrentFeePerKb = null; this.lockedCurrentFeePerKb = null;
@ -1130,7 +1128,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self._paypro = null; self._paypro = null;
self.error = gettext('Cannot sign: The payment request has expired'); self.error = gettext('Cannot sign: The payment request has expired');
}; };
}; };
this.setFromUri = function(uri) { this.setFromUri = function(uri) {
var self = this; var self = this;

View file

@ -174,6 +174,18 @@ angular.module('copayApp.services')
}); });
}; };
root.isBackupNeeded = function(walletId, cb) {
var c = root.getClient(walletId);
if (c.isPrivKeyExternal()) return cb(false);
if (!c.credentials.mnemonic) return cb(false);
if (c.credentials.network == 'testnet') return cb(false);
storageService.getBackupFlag(walletId, function(err, val) {
if (err || val) return cb(false);
return cb(true);
});
};
root._seedWallet = function(opts, cb) { root._seedWallet = function(opts, cb) {
opts = opts || {}; opts = opts || {};
if (opts.bwsurl) if (opts.bwsurl)