fix for new addresses in send

This commit is contained in:
matiu 2017-09-14 12:27:45 -03:00
commit 8c3397e698
5 changed files with 29 additions and 6 deletions

View file

@ -13,6 +13,10 @@ bwcModule.provider("bwcService", function() {
return Client.Bitcore; return Client.Bitcore;
}; };
service.getBitcoreCash = function() {
return Client.BitcoreCash;
};
service.getErrors = function() { service.getErrors = function() {
return Client.errors; return Client.errors;
}; };

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, $stateParams, $window, $state, $log, profileService, bitcore, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, txConfirmNotification) { angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $interval, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, $stateParams, $window, $state, $log, profileService, bitcore, bitcoreCash, txFormatService, ongoingProcess, $ionicModal, popupService, $ionicHistory, $ionicConfig, payproService, feeService, bwcError, txConfirmNotification) {
var countDown = null; var countDown = null;
var CONFIRM_LIMIT_USD = 20; var CONFIRM_LIMIT_USD = 20;
@ -120,6 +120,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}; };
// Setup $scope // Setup $scope
//
var B = data.stateParams.coin == 'bch' ? bitcoreCash : bitcore;
// Grab stateParams // Grab stateParams
tx = { tx = {
@ -137,7 +139,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
toName: data.stateParams.toName, toName: data.stateParams.toName,
toEmail: data.stateParams.toEmail, toEmail: data.stateParams.toEmail,
toColor: data.stateParams.toColor, toColor: data.stateParams.toColor,
network: (new bitcore.Address(data.stateParams.toAddress)).network.name, network: (new B.Address(data.stateParams.toAddress)).network.name,
coin: data.stateParams.coin, coin: data.stateParams.coin,
txp: {}, txp: {},
}; };

View file

@ -30,7 +30,7 @@ angular.module('copayApp.controllers').controller('createController',
$scope.formData.derivationPath = derivationPathHelper.default; $scope.formData.derivationPath = derivationPathHelper.default;
$scope.formData.coin = 'btc'; $scope.formData.coin = 'btc';
if (config.cashSupport.enabled) $scope.enableCash = true; if (config.cashSupport) $scope.enableCash = true;
$scope.setTotalCopayers(tc); $scope.setTotalCopayers(tc);
updateRCSelect(tc); updateRCSelect(tc);

View file

@ -0,0 +1,6 @@
'use strict';
angular.module('copayApp.services')
.factory('bitcoreCash', function bitcoreFactory(bwcService) {
var bitcoreCash = bwcService.getBitcoreCash();
return bitcoreCash;
});

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, $rootScope, payproService, scannerService, appConfigService, popupService, gettextCatalog) { angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, appConfigService, popupService, gettextCatalog) {
var root = {}; var root = {};
@ -140,6 +140,16 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
} else { } else {
goToAmountPage(data); goToAmountPage(data);
} }
} else if (bitcoreCash.Address.isValid(data, 'livenet')) {
if ($state.includes('tabs.scan')) {
root.showMenu({
data: data,
type: 'bitcoinAddress',
coin: 'bch',
});
} else {
goToAmountPage(data, 'bch');
}
} else if (data && data.indexOf(appConfigService.name + '://glidera') === 0) { } else if (data && data.indexOf(appConfigService.name + '://glidera') === 0) {
var code = getParameterByName('code', data); var code = getParameterByName('code', data);
$ionicHistory.nextViewOptions({ $ionicHistory.nextViewOptions({
@ -254,14 +264,15 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
}; };
function goToAmountPage(toAddress) { function goToAmountPage(toAddress, coin) {
$state.go('tabs.send', {}, { $state.go('tabs.send', {}, {
'reload': true, 'reload': true,
'notify': $state.current.name == 'tabs.send' ? false : true 'notify': $state.current.name == 'tabs.send' ? false : true
}); });
$timeout(function() { $timeout(function() {
$state.transitionTo('tabs.send.amount', { $state.transitionTo('tabs.send.amount', {
toAddress: toAddress toAddress: toAddress,
coin: coin,
}); });
}, 100); }, 100);
} }