Files
2017-06-14 02:38:08 -07:00

58 lines
2.0 KiB
JavaScript

'use strict';
var viewWalletCtrl = function($scope, walletService) {
$scope.usdBalance = "loading";
$scope.gbpBalance = "loading";
$scope.eurBalance = "loading";
$scope.btcBalance = "loading";
$scope.etherBalance = "loading";
$scope.tokenVisibility = "hidden";
$scope.pkeyVisible = false;
walletService.wallet = null;
walletService.password = '';
$scope.ajaxReq = ajaxReq;
$scope.$watch(function() {
if (walletService.wallet == null) return null;
return walletService.wallet.getAddressString();
}, function() {
if (walletService.wallet == null) return;
$scope.wallet = walletService.wallet;
$scope.wd = true;
$scope.showEnc = walletService.password != '';
if (walletService.wallet.type == "default") $scope.blob = globalFuncs.getBlob("text/json;charset=UTF-8", $scope.wallet.toJSON());
if (walletService.password != '') {
$scope.blobEnc = globalFuncs.getBlob("text/json;charset=UTF-8", $scope.wallet.toV3(walletService.password, {
kdf: globalFuncs.kdf,
n: globalFuncs.scrypt.n
}));
$scope.encFileName = $scope.wallet.getV3Filename();
}
$scope.wallet.setBalance();
$scope.wallet.setTokens();
});
$scope.$watch('ajaxReq.key', function() {
if ($scope.wallet) {
$scope.wallet.setBalance();
$scope.wallet.setTokens();
}
});
$scope.printQRCode = function() {
globalFuncs.printPaperWallets(JSON.stringify([{
address: $scope.wallet.getChecksumAddressString(),
private: $scope.wallet.getPrivateKeyString()
}]));
}
$scope.showHidePkey = function() {
$scope.pkeyVisible = !$scope.pkeyVisible;
}
$scope.resetWallet = function() {
$scope.wallet = null;
walletService.wallet = null;
walletService.password = '';
$scope.blob = $scope.blobEnc = $scope.password = "";
}
};
module.exports = viewWalletCtrl;