Get protocol handler from walletService

This commit is contained in:
Gustavo Maximiliano Cortez 2017-09-09 19:42:48 -03:00
commit 779d21e9e9
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 18 additions and 2 deletions

View file

@ -8,6 +8,10 @@ angular.module('copayApp.controllers').controller('customAmountController', func
});
};
var setProtocolHandler = function() {
$scope.protocolHandler = walletService.getProtocolHandler($scope.wallet);
}
$scope.$on("$ionicView.beforeEnter", function(event, data) {
var walletId = data.stateParams.id;
@ -20,6 +24,8 @@ angular.module('copayApp.controllers').controller('customAmountController', func
$scope.wallet = profileService.getWallet(walletId);
setProtocolHandler();
walletService.getAddress($scope.wallet, false, function(err, addr) {
if (!addr) {
showErrorAndBack('Error', 'Could not get the address');

View file

@ -124,8 +124,13 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
return wallet;
}
var setProtocolHandler = function() {
$scope.protocolHandler = walletService.getProtocolHandler($scope.wallet);
}
$scope.onWalletSelect = function(wallet) {
$scope.wallet = wallet;
setProtocolHandler();
$scope.setAddress();
};

View file

@ -1232,5 +1232,10 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
});
};
root.getProtocolHandler = function(wallet) {
if (wallet.coin== 'bch') return 'bitcoincash';
else return 'bitcoin';
}
return root;
});

View file

@ -21,7 +21,7 @@
<ion-content scroll="false">
<div class="address" ng-if="address && amountBtc">
<div class="qr-code" copy-to-clipboard="copyToClipboard()">
<qrcode size="220" data="bitcoin{{ wallet.coin == 'bch' ? 'cash' : '' }}:{{address + '?amount=' + amountBtc}}" color="#334"></qrcode>
<qrcode size="220" data="{{ protocolHandler }}:{{address + '?amount=' + amountBtc}}" color="#334"></qrcode>
</div>
<div class="info">
<div class="item single-line" copy-to-clipboard="address">

View file

@ -34,7 +34,7 @@
<span translate>Show address</span>
</button>
</span>
<qrcode ng-if="addr" size="220" data="bitcoin{{ wallet.coin == 'bch' ? 'cash' : ''}}:{{addr}}" color="#334"></qrcode>
<qrcode ng-if="addr" size="220" data="{{ protocolHandler }}:{{addr}}" color="#334"></qrcode>
<div class="address-label">
<span class="ellipsis">{{addr}}</span>
<ion-spinner ng-show="!addr" class="spinner-dark" icon="crescent"></ion-spinner>