<commit_before>(function() {
    "use strict";

    angular.module("blocktrail.wallet")
        .controller("SendScanQRCtrl", SendScanQRCtrl);

    function SendScanQRCtrl($scope, $rootScope, $state, QR, $log, $btBackButtonDelegate, $timeout, $translate, modalService,
                            $ionicHistory, $cordovaToast, $ionicLoading, bitcoinLinkService, walletsManagerService, $stateParams) {
        //remove animation for next state - looks kinda buggy
        $ionicHistory.nextViewOptions({
            disableAnimate: true
        });

        $ionicLoading.show({template: "<div>{{ 'LOADING' | translate }}...</div>", hideOnStateChange: true});

        //wait for transition, then open the scanner and begin scanning
        $timeout(function() {
            QR.scan(
                function(result) {
                    $log.debug('scan done', result);
                    // bitcoin cash ppl care so little for standards or consensus that we actually need to do this ...
                    result = result.replace(/^bitcoin cash:/, 'bitcoincash:');

                    $log.debug('scan done', result);
                    $ionicLoading.hide();

                    // Handle cancelled stage
                    if (result.toLowerCase() !== "cancelled") {
                        //parse result for address and value
                        var elm = angular.element('<a>').attr('href', result )[0];

                        $log.debug(elm.protocol, elm.pathname, elm.search, elm.hostname);

                        // Handle promocodes
                        if (elm.protocol === 'btccomwallet:') {
                            var reg = new RegExp(/btccomwallet:\/\/promocode\?code=(.+)/);
                            var res = result.match(reg);

                            $state.go('app.wallet.promo', {code: res[1]});

                        } else if (elm.protocol === 'bitcoincash:' && $rootScope.NETWORK === "BTC") {
                            throw new Error("Can't send to Bitcoin Cash address with BTC wallet");
                        } else if (elm.protocol === 'bitcoin:' || elm.protocol === 'bitcoincash:') {
                            $scope.clearRecipient();
                            bitcoinLinkService.parse(result).then(function (sendInput) {
                                if(sendInput && (sendInput.network === 'bitcoin' || sendInput.network === 'bitcoincash')) {
                                    $state.go('app.wallet.send', {
                                        sendInput: sendInput
                                    });
                                } else {
                                    $cordovaToast.showLongTop($translate.instant("MSG_INVALID_RECIPIENT").sentenceCase());
                                    $timeout(function() {$btBackButtonDelegate.goBack();}, 180);
                                }
                            });
                        } else {
                            walletsManagerService.getActiveWallet().validateAddress(result)
                                .then(function () {
                                    $state.go('app.wallet.send', {
                                        sendInput: {
                                            recipientDisplay: result,
                                            recipientAddress: result
                                        }
                                    });
                                })
                                .catch(function () {
                                    $timeout(function() {
                                        $btBackButtonDelegate.goBack();
                                        modalService.alert({
                                            title: "ERROR_TITLE_3",
                                            body: "MSG_INVALID_RECIPIENT"
                                        });
                                    }, 180);
                                });
                        }
                    } else {
                        if ($stateParams.promoCodeRedeem) {
                            $timeout(function () {
                                $state.go("app.wallet.summary")
                            }, 300);
                        } else {
                            $timeout(function () {
                                $btBackButtonDelegate.goBack();
                            }, 180);
                        }
                    }
                },
                function(error) {
                    $log.error("Scanning failed: " + error);

                    $ionicLoading.hide();
                    $cordovaToast.showLongTop("Scanning failed: " + error);
                    $scope.appControl.isScanning = false;
                    $timeout(function() {$btBackButtonDelegate.goBack();}, 180);
                }
            );
        }, 150);
    }
})();<commit_msg>remove backbutton call on QR scanner close<commit_after>(function() {
    "use strict";

    angular.module("blocktrail.wallet")
        .controller("SendScanQRCtrl", SendScanQRCtrl);

    function SendScanQRCtrl($scope, $rootScope, $state, QR, $log, $timeout, $translate, modalService, $ionicHistory,
                            $cordovaToast, $ionicLoading, bitcoinLinkService, walletsManagerService, $stateParams) {
        //remove animation for next state - looks kinda buggy
        $ionicHistory.nextViewOptions({
            disableAnimate: true
        });

        $ionicLoading.show({template: "<div>{{ 'LOADING' | translate }}...</div>", hideOnStateChange: true});

        //wait for transition, then open the scanner and begin scanning
        $timeout(function() {
            QR.scan(
                function(result) {
                    $log.debug('scan done', result);
                    // bitcoin cash ppl care so little for standards or consensus that we actually need to do this ...
                    result = result.replace(/^bitcoin cash:/, 'bitcoincash:');

                    $log.debug('scan done', result);
                    $ionicLoading.hide();

                    // Handle cancelled stage
                    if (result.toLowerCase() !== "cancelled") {
                        //parse result for address and value
                        var elm = angular.element('<a>').attr('href', result )[0];

                        $log.debug(elm.protocol, elm.pathname, elm.search, elm.hostname);

                        // Handle promocodes
                        if (elm.protocol === 'btccomwallet:') {
                            var reg = new RegExp(/btccomwallet:\/\/promocode\?code=(.+)/);
                            var res = result.match(reg);

                            $state.go('app.wallet.promo', {code: res[1]});

                        } else if (elm.protocol === 'bitcoincash:' && $rootScope.NETWORK === "BTC") {
                            throw new Error("Can't send to Bitcoin Cash address with BTC wallet");
                        } else if (elm.protocol === 'bitcoin:' || elm.protocol === 'bitcoincash:') {
                            $scope.clearRecipient();
                            bitcoinLinkService.parse(result).then(function (sendInput) {
                                if(sendInput && (sendInput.network === 'bitcoin' || sendInput.network === 'bitcoincash')) {
                                    $state.go('app.wallet.send', {
                                        sendInput: sendInput
                                    });
                                } else {
                                    $cordovaToast.showLongTop($translate.instant("MSG_INVALID_RECIPIENT").sentenceCase());
                                }
                            });
                        } else {
                            walletsManagerService.getActiveWallet().validateAddress(result)
                                .then(function () {
                                    $state.go('app.wallet.send', {
                                        sendInput: {
                                            recipientDisplay: result,
                                            recipientAddress: result
                                        }
                                    });
                                })
                                .catch(function () {
                                    $timeout(function() {
                                        modalService.alert({
                                            title: "ERROR_TITLE_3",
                                            body: "MSG_INVALID_RECIPIENT"
                                        });
                                    }, 180);
                                });
                        }
                    } else {
                        if ($stateParams.promoCodeRedeem) {
                            $timeout(function () {
                                $state.go("app.wallet.summary")
                            }, 300);
                        }
                    }
                },
                function(error) {
                    $log.error("Scanning failed: " + error);

                    $ionicLoading.hide();
                    $cordovaToast.showLongTop("Scanning failed: " + error);
                    $scope.appControl.isScanning = false;
                }
            );
        }, 150);
    }
})();
{'fraction_non_alphanumeric': 0.1078983735516105, 'fraction_numerical': 0.0035080259381311788, 'mean_word_length': 0.9831365935919055, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 48, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7060001', 'n_tokens_mistral': 2120, 'n_tokens_neox': 1956, 'n_words': 390}