Merge pull request #312 from Bitcoin-com/wallet/task/500
Upgrade the bitcoin uri service and its integration
This commit is contained in:
commit
480cfe43ca
4 changed files with 66 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $log, $timeout, scannerService, incomingData, $state, $ionicHistory, $rootScope, $ionicNavBarDelegate) {
|
||||
angular.module('copayApp.controllers').controller('tabScanController', function(bitcoinUriService, gettextCatalog, popupService, $scope, $log, $timeout, scannerService, incomingData, $state, $ionicHistory, $rootScope, $ionicNavBarDelegate) {
|
||||
|
||||
var scannerStates = {
|
||||
unauthorized: 'unauthorized',
|
||||
|
|
@ -111,7 +111,27 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
|
|||
// Sometimes (testing in Chrome, when reading QR Code) data is an object
|
||||
// that has a string data.result.
|
||||
contents = contents.result || contents;
|
||||
incomingData.redir(contents);
|
||||
|
||||
var parsed = bitcoinUriService.parse(contents);
|
||||
var title = '';
|
||||
var msg = '';
|
||||
if (parsed.isValid) {
|
||||
if (parsed.testnet) {
|
||||
title = gettextCatalog.getString('Unsupported');
|
||||
msg = gettextCatalog.getString('Testnet is not supported.');
|
||||
popupService.showAlert(title, msg, function onAlertShown() {
|
||||
scannerService.resumePreview();
|
||||
});
|
||||
} else {
|
||||
incomingData.redir(contents);
|
||||
}
|
||||
} else {
|
||||
title = gettextCatalog.getString('Scan Failed');
|
||||
msg = gettextCatalog.getString('Data not recognised.');
|
||||
popupService.showAlert(title, msg, function onAlertShown() {
|
||||
scannerService.resumePreview();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$rootScope.$on('incomingDataMenu.menuHidden', function() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, $ionicLoading, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, sendFlowService, bwcError, gettextCatalog, scannerService, configService, bitcoinCashJsService, $ionicPopup, $ionicNavBarDelegate, clipboardService) {
|
||||
angular.module('copayApp.controllers').controller('tabSendController', function(bitcoinUriService, $scope, $rootScope, $log, $timeout, $ionicScrollDelegate, $ionicLoading, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, sendFlowService, bwcError, gettextCatalog, scannerService, configService, bitcoinCashJsService, $ionicPopup, $ionicNavBarDelegate, clipboardService) {
|
||||
var clipboardHasAddress = false;
|
||||
var clipboardHasContent = false;
|
||||
var originalList;
|
||||
|
|
@ -39,7 +39,9 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
|
||||
$scope.clipboardHasAddress = false;
|
||||
$scope.clipboardHasContent = false;
|
||||
if ((text.indexOf('bitcoincash:') === 0 || text[0] === 'C' || text[0] === 'H' || text[0] === 'p' || text[0] === 'q') && text.replace('bitcoincash:', '').length === 42) { // CashAddr
|
||||
var parsed = bitcoinUriService.parse(text);
|
||||
console.log('parsed', parsed);
|
||||
if (parsed.isValid && parsed.publicAddress && parsed.coin === 'bch' && !parsed.testnet) { // CashAddr
|
||||
$scope.clipboardHasAddress = true;
|
||||
} else if ((text[0] === "1" || text[0] === "3" || text.substring(0, 3) === "bc1") && text.length >= 26 && text.length <= 35) { // Legacy Addresses
|
||||
$scope.clipboardHasAddress = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue