commit
e4e388f7bd
14 changed files with 119 additions and 116 deletions
|
|
@ -5,6 +5,17 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var cachedTxp = {};
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, wallet) {
|
||||
if (lodash.isEmpty(wallet)) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
$log.debug('Wallet changed: ' + wallet.name);
|
||||
setWallet(wallet, true);
|
||||
});
|
||||
|
||||
|
||||
$scope.showDescriptionPopup = function() {
|
||||
var commentPopup = $ionicPopup.show({
|
||||
templateUrl: "views/includes/note.html",
|
||||
|
|
@ -17,13 +28,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.commentPopupSave = function(description) {
|
||||
$log.debug('Saving description: ' + description);
|
||||
$scope.description = description;
|
||||
$scope.txp = null;
|
||||
|
||||
createTx($scope.wallet, function(err, txp) {
|
||||
if (err) return;
|
||||
cachedTxp[$scope.wallet.id] = txp;
|
||||
apply(txp);
|
||||
});
|
||||
commentPopup.close();
|
||||
};
|
||||
};
|
||||
|
|
@ -137,15 +141,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
};
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, wallet) {
|
||||
if (lodash.isEmpty(wallet)) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
}
|
||||
$log.debug('Wallet changed: ' + wallet.name);
|
||||
setWallet(wallet, true);
|
||||
});
|
||||
|
||||
function setWallet(wallet, delayed) {
|
||||
var stop;
|
||||
$scope.wallet = wallet;
|
||||
|
|
@ -165,7 +160,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
apply(cachedTxp[wallet.id]);
|
||||
} else {
|
||||
stop = $timeout(function() {
|
||||
createTx(wallet, function(err, txp) {
|
||||
createTx(wallet, true, function(err, txp) {
|
||||
if (err) return;
|
||||
cachedTxp[wallet.id] = txp;
|
||||
apply(txp);
|
||||
|
|
@ -184,7 +179,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.$apply();
|
||||
};
|
||||
|
||||
var createTx = function(wallet, cb) {
|
||||
var createTx = function(wallet, dryRun, cb) {
|
||||
var config = configService.getSync().wallet;
|
||||
var currentSpendUnconfirmed = config.spendUnconfirmed;
|
||||
var outputs = [];
|
||||
|
|
@ -227,6 +222,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
txp.payProUrl = paypro;
|
||||
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
|
||||
txp.feeLevel = config.settings.feeLevel || 'normal';
|
||||
txp.dryRun = dryRun;
|
||||
|
||||
walletService.createTx(wallet, txp, function(err, ctxp) {
|
||||
if (err) {
|
||||
|
|
@ -247,14 +243,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
$scope.approve = function() {
|
||||
var wallet = $scope.wallet;
|
||||
var txp = $scope.txp;
|
||||
if (!wallet) {
|
||||
return setSendError(gettextCatalog.getString('No wallet selected'));
|
||||
};
|
||||
|
||||
if (!txp) {
|
||||
return setSendError(gettextCatalog.getString('No transaction'));
|
||||
};
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
|
|
@ -265,9 +257,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
}
|
||||
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
$state.transitionTo('tabs.home');
|
||||
ongoingProcess.set('creatingTx', true);
|
||||
createTx(wallet, false, function(err, txp) {
|
||||
ongoingProcess.set('creatingTx', false);
|
||||
if (err) return;
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
$state.transitionTo('tabs.home');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,9 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
$scope.sign = function() {
|
||||
$scope.loading = true;
|
||||
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
|
||||
|
||||
console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
||||
|
||||
$scope.$emit('UpdateTx');
|
||||
if (err) return setSendError(err);
|
||||
$scope.close(txp);
|
||||
$scope.close();
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -53,7 +50,7 @@ console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
|||
if (err)
|
||||
return setError(err, gettextCatalog.getString('Could not reject payment'));
|
||||
|
||||
$scope.close(txpr);
|
||||
$scope.close();
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -90,7 +87,7 @@ console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
|||
return setError(err, gettextCatalog.getString('Could not broadcast payment'));
|
||||
}
|
||||
|
||||
$scope.close(txpb);
|
||||
$scope.close();
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
|
@ -175,7 +172,7 @@ console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
|||
});
|
||||
};
|
||||
|
||||
$scope.close = function(txp) {
|
||||
$scope.close = function() {
|
||||
$scope.loading = null;
|
||||
$scope.txpDetailsModal.hide();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesAbout',
|
||||
function($ionicNavBarDelegate, gettextCatalog) {
|
||||
function($scope, $window, $ionicNavBarDelegate, gettextCatalog) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('About Copay'));
|
||||
|
||||
$scope.version = $window.version;
|
||||
$scope.commitHash = $window.commitHash;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,23 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, $ionicScrollDelegate, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService, txpModalService) {
|
||||
function($rootScope, $timeout, $scope, $state, $ionicScrollDelegate, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService, txpModalService, $window) {
|
||||
|
||||
$scope.externalServices = {};
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
|
||||
|
||||
function updateTxps() {
|
||||
profileService.getTxps({
|
||||
limit: 3
|
||||
}, function(err, txps, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
}
|
||||
$scope.txps = txps;
|
||||
$scope.txpsN = n;
|
||||
$ionicScrollDelegate.resize();
|
||||
|
||||
var setPendingTxps = function(txps) {
|
||||
if (!txps) {
|
||||
$scope.txps = [];
|
||||
return;
|
||||
}
|
||||
$scope.txps = lodash.sortBy(txps, 'createdOn').reverse();
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
|
||||
$scope.updateAllWallets = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
if (lodash.isEmpty($scope.wallets)) return;
|
||||
|
|
@ -35,20 +42,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
wallet.status = status;
|
||||
}
|
||||
if (++j==i) {
|
||||
profileService.getTxps({
|
||||
limit: 3
|
||||
}, function(err, txps, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
}
|
||||
$scope.txps = txps;
|
||||
$scope.txpsN = n;
|
||||
$ionicScrollDelegate.resize();
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
});
|
||||
updateTxps();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -81,29 +75,18 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
}
|
||||
wallet.status = status;
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
profileService.getNotifications({
|
||||
limit: 3
|
||||
}, function(err, notifications) {
|
||||
$scope.fetchingNotifications = false;
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
}
|
||||
$scope.notifications = notifications;
|
||||
|
||||
profileService.getTxps({
|
||||
limit: 3
|
||||
}, function(err, txps, n) {
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
}
|
||||
$scope.txps = txps;
|
||||
$scope.txpsN = n;
|
||||
$ionicScrollDelegate.resize();
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 1);
|
||||
})
|
||||
updateTxps();
|
||||
})
|
||||
});
|
||||
};
|
||||
|
|
@ -123,6 +106,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
$scope.updateWallet(wallet);
|
||||
}),
|
||||
$rootScope.$on('Local/TxAction', function(e, walletId) {
|
||||
$log.debug('Got action for wallet '+ walletId);
|
||||
var wallet = profileService.getWallet(walletId);
|
||||
$scope.updateWallet(wallet);
|
||||
}),
|
||||
|
|
@ -143,5 +127,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
|
||||
$scope.version = $window.version;
|
||||
$scope.name = $window.appConfig.nameCase;
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ angular.module('copayApp.services')
|
|||
if (wallet.cachedActivity)
|
||||
wallet.cachedActivity.isValid = false;
|
||||
|
||||
|
||||
if (wallet.cachedTxps)
|
||||
wallet.cachedTxps.isValid = false;
|
||||
|
||||
|
|
@ -908,22 +907,14 @@ angular.module('copayApp.services')
|
|||
|
||||
var txps = [];
|
||||
|
||||
function process(notifications) {
|
||||
if (!notifications) return [];
|
||||
|
||||
var shown = lodash.sortBy(notifications, 'createdOn').reverse();
|
||||
shown = shown.splice(0, opts.limit || MAX);
|
||||
return shown;
|
||||
};
|
||||
|
||||
lodash.each(w, function(x) {
|
||||
if (x.pendingTxps)
|
||||
txps = txps.concat(x.pendingTxps);
|
||||
});
|
||||
txps = lodash.sortBy(txps, 'createdOn');
|
||||
txps = lodash.sortBy(txps, 'pendingForUs', 'createdOn');
|
||||
txps = lodash.compact(lodash.flatten(txps)).slice(0,MAX);
|
||||
var n = txps.length;
|
||||
return cb(null, process(txps), n);
|
||||
return cb(null, txps, n);
|
||||
};
|
||||
|
||||
return root;
|
||||
|
|
|
|||
|
|
@ -92,13 +92,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
|
||||
root.invalidateCache = function(wallet) {
|
||||
if (wallet.cachedStatus) {
|
||||
if (wallet.cachedStatus)
|
||||
wallet.cachedStatus.isValid = false;
|
||||
}
|
||||
|
||||
if (wallet.completeHistory) {
|
||||
if (wallet.completeHistory)
|
||||
wallet.completeHistory.isValid = false;
|
||||
}
|
||||
|
||||
if (wallet.cachedActivity)
|
||||
wallet.cachedActivity.isValid = false;
|
||||
|
||||
if (wallet.cachedTxps)
|
||||
wallet.cachedTxps.isValid = false;
|
||||
};
|
||||
|
||||
root.getStatus = function(wallet, opts, cb) {
|
||||
|
|
@ -623,6 +627,10 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
wallet.removeTxProposal(txp, function(err) {
|
||||
$log.debug('Transaction removed');
|
||||
|
||||
root.invalidateCache(wallet);
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
|
||||
return cb(err);
|
||||
});
|
||||
};
|
||||
|
|
@ -852,6 +860,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
askPassword(wallet.name, gettext('Enter Spending Password'), function(password) {
|
||||
if (!password) return cb('no password');
|
||||
if (!wallet.checkPassword(password)) return cb('wrong password');
|
||||
|
||||
|
||||
return cb(null, password);
|
||||
});
|
||||
|
|
@ -862,8 +872,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
ongoingProcess.set('rejectTx', true);
|
||||
root.rejectTx(wallet, txp, function(err, txpr) {
|
||||
root.invalidateCache(wallet);
|
||||
|
||||
ongoingProcess.set('rejectTx', false);
|
||||
|
||||
if (err) return cb(err);
|
||||
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
|
|
@ -933,6 +943,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
var msg = err.message ?
|
||||
err.message :
|
||||
gettext('The payment was created but could not be completed. Please try again from home screen');
|
||||
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return cb(msg);
|
||||
}
|
||||
|
|
@ -943,18 +954,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
ongoingProcess.set('broadcastingTx', false);
|
||||
if (err) return cb('sign error' + err);
|
||||
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
var type = root.getViewStatus(wallet, broadcastedTxp);
|
||||
root.openStatusModal(type, broadcastedTxp, function() {
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
});
|
||||
|
||||
return cb(null, broadcastedTxp)
|
||||
});
|
||||
} else {
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
|
||||
var type = root.getViewStatus(wallet, signedTxp);
|
||||
root.openStatusModal(type, signedTxp, function() {
|
||||
root.invalidateCache(wallet);
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
});
|
||||
return cb(null, signedTxp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue