commit
16c0c58d32
25 changed files with 511 additions and 129 deletions
|
|
@ -15,6 +15,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.toEmail = data.stateParams.toEmail;
|
||||
$scope.description = data.stateParams.description;
|
||||
$scope.paypro = data.stateParams.paypro;
|
||||
$scope._paypro = $scope.paypro;
|
||||
$scope.paymentExpired = {
|
||||
value: false
|
||||
};
|
||||
|
|
@ -25,13 +26,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
|
||||
var initConfirm = function() {
|
||||
if ($scope.paypro) {
|
||||
return setFromPayPro($scope.paypro, function(err) {
|
||||
if (err && !isChromeApp) {
|
||||
popupService.showAlert(gettext('Could not fetch payment'));
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO (URL , etc)
|
||||
if (!$scope.toAddress || !$scope.toAmount) {
|
||||
$log.error('Bad params at amount');
|
||||
|
|
@ -100,6 +94,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.alternativeAmountStr = v;
|
||||
});
|
||||
|
||||
if($scope.paypro) {
|
||||
_paymentTimeControl($scope.paypro.expires);
|
||||
}
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
|
|
@ -149,56 +147,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
return amountStr.split(' ')[1];
|
||||
}
|
||||
|
||||
var setFromPayPro = function(uri, cb) {
|
||||
if (!cb) cb = function() {};
|
||||
|
||||
var wallet = profileService.getWallets({
|
||||
onlyComplete: true
|
||||
})[0];
|
||||
|
||||
if (!wallet) return cb();
|
||||
|
||||
if (isChromeApp) {
|
||||
popupService.showAlert(gettextCatalog.getString('Payment Protocol not supported on Chrome App'));
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
$log.debug('Fetch PayPro Request...', uri);
|
||||
|
||||
ongoingProcess.set('fetchingPayPro', true);
|
||||
wallet.fetchPayPro({
|
||||
payProUrl: uri,
|
||||
}, function(err, paypro) {
|
||||
|
||||
ongoingProcess.set('fetchingPayPro', false);
|
||||
|
||||
if (err) {
|
||||
$log.warn('Could not fetch payment request:', err);
|
||||
var msg = err.toString();
|
||||
if (msg.match('HTTP')) {
|
||||
msg = gettextCatalog.getString('Could not fetch payment information');
|
||||
}
|
||||
popupService.showAlert(msg);
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
if (!paypro.verified) {
|
||||
$log.warn('Failed to verify payment protocol signatures');
|
||||
popupService.showAlert(gettextCatalog.getString('Payment Protocol Invalid'));
|
||||
return cb(true);
|
||||
}
|
||||
|
||||
$scope.toAmount = paypro.amount;
|
||||
$scope.toAddress = paypro.toAddress;
|
||||
$scope.description = paypro.memo;
|
||||
$scope.paypro = null;
|
||||
|
||||
$scope._paypro = paypro;
|
||||
_paymentTimeControl(paypro.expires);
|
||||
return initConfirm();
|
||||
});
|
||||
};
|
||||
|
||||
function _paymentTimeControl(expirationTime) {
|
||||
$scope.paymentExpired.value = false;
|
||||
setExpirationTime();
|
||||
|
|
@ -219,7 +167,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var m = Math.floor(totalSecs / 60);
|
||||
var s = totalSecs % 60;
|
||||
$scope.remainingTimeStr.value = ('0' + m).slice(-2) + ":" + ('0' + s).slice(-2);
|
||||
};
|
||||
}
|
||||
|
||||
function setExpiredValues() {
|
||||
$scope.paymentExpired.value = true;
|
||||
|
|
@ -228,8 +176,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function setWallet(wallet, delayed) {
|
||||
var stop;
|
||||
|
|
@ -257,7 +205,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
}, delayed ? 2000 : 1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var setSendError = function(msg) {
|
||||
$scope.sendStatus = '';
|
||||
|
|
@ -294,7 +242,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var msg = 'Amount too big';
|
||||
$log.warn(msg);
|
||||
return setSendError(msg);
|
||||
};
|
||||
}
|
||||
|
||||
outputs.push({
|
||||
'toAddress': toAddress,
|
||||
|
|
@ -313,7 +261,9 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
txp.outputs = outputs;
|
||||
txp.message = description;
|
||||
txp.payProUrl = paypro;
|
||||
if(paypro) {
|
||||
txp.payProUrl = paypro.url;
|
||||
}
|
||||
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
|
||||
txp.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
|
||||
txp.dryRun = dryRun;
|
||||
|
|
@ -349,7 +299,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var wallet = $scope.wallet;
|
||||
if (!wallet) {
|
||||
return setSendError(gettextCatalog.getString('No wallet selected'));
|
||||
};
|
||||
}
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
$scope.$on("$ionicView.afterEnter", function() {
|
||||
// try initializing and refreshing status any time the view is entered
|
||||
scannerService.gentleInitialize();
|
||||
scannerService.resumePreview();
|
||||
});
|
||||
|
||||
function activate(){
|
||||
|
|
@ -95,9 +96,15 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
|
||||
function handleSuccessfulScan(contents){
|
||||
$log.debug('Scan returned: "' + contents + '"');
|
||||
scannerService.pausePreview();
|
||||
incomingData.redir(contents);
|
||||
}
|
||||
|
||||
$rootScope.$on('incomingDataMenu.menuHidden', function() {
|
||||
scannerService.resumePreview();
|
||||
activate();
|
||||
});
|
||||
|
||||
$scope.openSettings = function(){
|
||||
scannerService.openSettings();
|
||||
};
|
||||
|
|
@ -126,7 +133,7 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
|
||||
$scope.canGoBack = function(){
|
||||
return $state.params.passthroughMode;
|
||||
}
|
||||
};
|
||||
function goBack(){
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
|
||||
$scope.openScanner = function() {
|
||||
$state.go('tabs.scan');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.showMore = function() {
|
||||
currentContactsPage++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue