Next address after receive funds
This commit is contained in:
parent
959707f3b7
commit
fe8dcd2f94
4 changed files with 48 additions and 20 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('headController',
|
angular.module('copayApp.controllers').controller('headController',
|
||||||
function($scope, $window, $log, glideraService) {
|
function($scope, $window, $log) {
|
||||||
$scope.appConfig = $window.appConfig;
|
$scope.appConfig = $window.appConfig;
|
||||||
$log.info('Running head controller:' + $window.appConfig.nameCase)
|
$log.info('Running head controller:' + $window.appConfig.nameCase)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -102,12 +102,6 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on("$ionicView.leave", function(event, data) {
|
|
||||||
lodash.each(listeners, function(x) {
|
|
||||||
x();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
|
$scope.openExternalLink = function(url, optIn, title, message, okText, cancelText) {
|
||||||
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
externalLinkService.open(url, optIn, title, message, okText, cancelText);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $timeout, $log, $ionicModal, $state, $ionicHistory, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
|
angular.module('copayApp.controllers').controller('tabReceiveController', function($rootScope, $scope, $timeout, $log, $ionicModal, $state, $ionicHistory, storageService, platformInfo, walletService, profileService, configService, lodash, gettextCatalog, popupService) {
|
||||||
|
|
||||||
|
var listeners = [];
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
$scope.isNW = platformInfo.isNW;
|
$scope.isNW = platformInfo.isNW;
|
||||||
$scope.walletAddrs = {};
|
$scope.walletAddrs = {};
|
||||||
|
|
@ -113,10 +114,41 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
||||||
$log.debug('Wallet changed: ' + wallet.name);
|
$log.debug('Wallet changed: ' + wallet.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.updateCurrentWallet = function() {
|
||||||
|
walletService.getStatus($scope.wallet, {}, function(err, status) {
|
||||||
|
if (err) {
|
||||||
|
$log.error(err);
|
||||||
|
}
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.wallet = profileService.getWallet($scope.wallet.id);
|
||||||
|
$scope.wallet.status = status;
|
||||||
|
$scope.setAddress();
|
||||||
|
$scope.$apply();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.wallets = profileService.getWallets();
|
$scope.wallets = profileService.getWallets();
|
||||||
|
|
||||||
lodash.each($scope.wallets, function(wallet, index) {
|
lodash.each($scope.wallets, function(wallet, index) {
|
||||||
$scope.loadAddresses(wallet);
|
$scope.loadAddresses(wallet);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
listeners = [
|
||||||
|
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||||
|
// Update current address
|
||||||
|
if ($scope.wallet && walletId == $scope.wallet.id) $scope.updateCurrentWallet();
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
// Update current wallet
|
||||||
|
if ($scope.wallet) $scope.updateCurrentWallet();
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$on("$ionicView.leave", function(event, data) {
|
||||||
|
lodash.each(listeners, function(x) {
|
||||||
|
x();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -29,16 +29,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// // RECEIVE
|
|
||||||
// // Check address
|
|
||||||
// root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
|
|
||||||
// if (used) {
|
|
||||||
// $log.debug('Address used. Creating new');
|
|
||||||
// $rootScope.$emit('Local/AddressIsUsed');
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
|
|
||||||
var _signWithLedger = function(wallet, txp, cb) {
|
var _signWithLedger = function(wallet, txp, cb) {
|
||||||
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
||||||
|
|
||||||
|
|
@ -231,6 +221,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
cache.alternativeName = config.settings.alternativeName;
|
cache.alternativeName = config.settings.alternativeName;
|
||||||
cache.alternativeIsoCode = config.settings.alternativeIsoCode;
|
cache.alternativeIsoCode = config.settings.alternativeIsoCode;
|
||||||
|
|
||||||
|
// Check address
|
||||||
|
root.isAddressUsed(wallet, balance.byAddress, function(err, used) {
|
||||||
|
if (used) {
|
||||||
|
$log.debug('Address used. Creating new');
|
||||||
|
// Force new address
|
||||||
|
root.getAddress(wallet, true, function(err, addr) {
|
||||||
|
$log.debug('New address: ', addr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
|
|
||||||
var totalBalanceAlternative = rateService.toFiat(cache.totalBalanceSat, cache.alternativeIsoCode);
|
var totalBalanceAlternative = rateService.toFiat(cache.totalBalanceSat, cache.alternativeIsoCode);
|
||||||
|
|
@ -760,12 +761,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.isUsed = function(wallet, byAddress, cb) {
|
// Check address
|
||||||
|
root.isAddressUsed = function(wallet, byAddress, cb) {
|
||||||
storageService.getLastAddress(wallet.id, function(err, addr) {
|
storageService.getLastAddress(wallet.id, function(err, addr) {
|
||||||
var used = lodash.find(byAddress, {
|
var used = lodash.find(byAddress, {
|
||||||
address: addr
|
address: addr
|
||||||
});
|
});
|
||||||
return cb(null, used);
|
return cb(err, used);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue