diff --git a/src/js/controllers/walletHome.js b/old/walletHome.js
similarity index 100%
rename from src/js/controllers/walletHome.js
rename to old/walletHome.js
diff --git a/public/views/confirm.html b/public/views/confirm.html
index 3ca817958..745f5746b 100644
--- a/public/views/confirm.html
+++ b/public/views/confirm.html
@@ -41,6 +41,7 @@
+
[Only showing testnet wallets]
diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js
index 2606878a2..d70b6bf23 100644
--- a/src/js/controllers/amount.js
+++ b/src/js/controllers/amount.js
@@ -1,6 +1,6 @@
'use strict';
-angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log) {
+angular.module('copayApp.controllers').controller('amountController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log, txFormatService) {
var unitToSatoshi;
@@ -144,7 +144,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
if (lodash.isNumber(result)) {
$scope.globalResult = isExpression(val) ? '= ' + processResult(result) : '';
$scope.amountResult = $filter('formatFiatAmount')(toFiat(result));
- $scope.alternativeResult = walletService.formatAmount(fromFiat(result) * unitToSatoshi, true);
+ $scope.alternativeResult = txFormatService.formatAmount(fromFiat(result) * unitToSatoshi, true);
}
};
@@ -152,7 +152,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
if ($scope.showAlternativeAmount)
return $filter('formatFiatAmount')(val);
else
- return walletService.formatAmount(val.toFixed(unitDecimals) * unitToSatoshi, true);
+ return txFormatService.formatAmount(val.toFixed(unitDecimals) * unitToSatoshi, true);
};
function fromFiat(val) {
diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js
index b66b66901..25d8c8e75 100644
--- a/src/js/controllers/confirm.js
+++ b/src/js/controllers/confirm.js
@@ -52,6 +52,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.toName = $stateParams.toName;
var network = (new bitcore.Address($scope.toAddress)).network.name;
+ $scope.network = network;
+
$scope.setWallets(network);
toFiat($scope.amount, function(v) {
@@ -62,6 +64,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
$scope.wallet = $scope.wallets[data.slider.activeIndex];
+
});
createTx($scope.toAddress, $scope.toAmount);
@@ -87,6 +90,7 @@ console.log('[confirm.js.78:toAddress:]',toAddress); //TODO
$log.error('No wallet selected')
return;
};
+console.log('[confirm.js.85:wallet:]',wallet); //TODO
var outputs = [];
var comment = $scope.comment;
diff --git a/src/js/controllers/modals/txDetails.js b/src/js/controllers/modals/txDetails.js
index 205ba17fd..48e5c277e 100644
--- a/src/js/controllers/modals/txDetails.js
+++ b/src/js/controllers/modals/txDetails.js
@@ -1,6 +1,6 @@
'use strict';
-angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService, lodash) {
+angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService, lodash, txFormatService) {
var self = $scope.self;
var fc = profileService.focusedClient;
@@ -13,8 +13,8 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.copayerId = fc.credentials.copayerId;
$scope.isShared = fc.credentials.n > 1;
- $scope.btx.amountStr = profileService.formatAmount($scope.btx.amount, true) + ' ' + walletSettings.unitName;
- $scope.btx.feeStr = profileService.formatAmount($scope.btx.fees, true) + ' ' + walletSettings.unitName;
+ $scope.btx.amountStr = txFormatService.formatAmount($scope.btx.amount, true) + ' ' + walletSettings.unitName;
+ $scope.btx.feeStr = txFormatService.formatAmount($scope.btx.fees, true) + ' ' + walletSettings.unitName;
$scope.showCommentPopup = function() {
$scope.data = {
diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js
index 8560a7a5f..e731e07f3 100644
--- a/src/js/controllers/modals/txpDetails.js
+++ b/src/js/controllers/modals/txpDetails.js
@@ -108,12 +108,12 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
};
$scope.getShortNetworkName = function() {
- return fc.credentials.networkName.substring(0, 4);
+ return $scope.wallet.credentials.networkName.substring(0, 4);
};
function checkPaypro() {
if (tx.payProUrl && !platformInfo.isChromeApp) {
- fc.fetchPayPro({
+ $scope.wallet.fetchPayPro({
payProUrl: tx.payProUrl,
}, function(err, paypro) {
if (err) return;
@@ -150,7 +150,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
lodash.each(['TxProposalRejectedBy', 'TxProposalAcceptedBy', 'transactionProposalRemoved', 'TxProposalRemoved', 'NewOutgoingTx', 'UpdateTx'], function(eventName) {
$rootScope.$on(eventName, function() {
- fc.getTx($scope.tx.id, function(err, tx) {
+ $scope.wallet.getTx($scope.tx.id, function(err, tx) {
if (err) {
if (err.message && err.message == 'TX_NOT_FOUND' &&
(eventName == 'transactionProposalRemoved' || eventName == 'TxProposalRemoved')) {
@@ -163,7 +163,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
}
var action = lodash.find(tx.actions, {
- copayerId: fc.credentials.copayerId
+ copayerId: $scope.wallet.credentials.copayerId
});
$scope.tx = txFormatService.processTx(tx);
@@ -187,14 +187,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
});
};
- function handleEncryptedWallet(cb) {
- if (!walletService.isEncrypted(fc)) return cb();
- $rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
- if (err) return cb(err);
- return cb(walletService.unlock(fc, password));
- });
- };
-
$scope.copyToClipboard = function(addr, $event) {
if (!addr) return;
self.copyToClipboard(addr, $event);
diff --git a/src/js/controllers/paperWallet.js b/src/js/controllers/paperWallet.js
index 581a71b1c..69554c2dd 100644
--- a/src/js/controllers/paperWallet.js
+++ b/src/js/controllers/paperWallet.js
@@ -1,5 +1,5 @@
angular.module('copayApp.controllers').controller('paperWalletController',
- function($scope, $timeout, $log, $ionicModal, configService, profileService, go, addressService, txStatus, bitcore, ongoingProcess) {
+ function($scope, $timeout, $log, $ionicModal, configService, profileService, go, addressService, txStatus, bitcore, ongoingProcess, txFormatService) {
var fc = profileService.focusedClient;
var rawTx;
@@ -61,7 +61,7 @@ angular.module('copayApp.controllers').controller('paperWalletController',
$scope.privateKey = privateKey;
$scope.balanceSat = balance;
var config = configService.getSync().wallet.settings;
- $scope.balance = profileService.formatAmount(balance) + ' ' + config.unitName;
+ $scope.balance = txFormatService.formatAmount(balance) + ' ' + config.unitName;
}
$scope.$apply();
diff --git a/src/js/services/feeService.js b/src/js/services/feeService.js
index cf7288feb..30362efb8 100644
--- a/src/js/services/feeService.js
+++ b/src/js/services/feeService.js
@@ -1,6 +1,6 @@
'use strict';
-angular.module('copayApp.services').factory('feeService', function($log, bwcService, walletService, configService, gettext, lodash) {
+angular.module('copayApp.services').factory('feeService', function($log, bwcService, walletService, configService, gettext, lodash, txFormatService) {
var root = {};
// Constant fee options to translate
@@ -16,6 +16,8 @@ angular.module('copayApp.services').factory('feeService', function($log, bwcServ
};
root.getCurrentFeeValue = function(cb) {
+console.log('[feeService.js.18:getCurrentFeeValue:] TODO TODO TODO'); //TODO
+ // TODO TODO TODO
var fc = walletService.focusedClient;
var feeLevel = root.getCurrentFeeLevel();
@@ -49,8 +51,8 @@ angular.module('copayApp.services').factory('feeService', function($log, bwcServ
if (errLivenet || errTestnet) $log.debug('Could not get dynamic fee');
else {
for (var i = 0; i < 4; i++) {
- levelsLivenet[i]['feePerKBUnit'] = walletService.formatAmount(levelsLivenet[i].feePerKB) + ' ' + unitName;
- levelsTestnet[i]['feePerKBUnit'] = walletService.formatAmount(levelsTestnet[i].feePerKB) + ' ' + unitName;
+ levelsLivenet[i]['feePerKBUnit'] = txFormatService.formatAmount(levelsLivenet[i].feePerKB) + ' ' + unitName;
+ levelsTestnet[i]['feePerKBUnit'] = txFormatService.formatAmount(levelsTestnet[i].feePerKB) + ' ' + unitName;
}
}
diff --git a/src/js/services/txFormatService.js b/src/js/services/txFormatService.js
index ea1aba2a0..478467d26 100644
--- a/src/js/services/txFormatService.js
+++ b/src/js/services/txFormatService.js
@@ -1,12 +1,37 @@
'use strict';
-angular.module('copayApp.services').factory('txFormatService', function(walletService, rateService, configService, lodash) {
+angular.module('copayApp.services').factory('txFormatService', function(bwcService, rateService, configService, lodash) {
var root = {};
+
+ // // RECEIVE
+ // // Check address
+ // root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
+ // if (used) {
+ // $log.debug('Address used. Creating new');
+ // $rootScope.$emit('Local/AddressIsUsed');
+ // }
+ // });
+ //
+
+ root.Utils = bwcService.getUtils();
+ root.formatAmount = function(amount, fullPrecision) {
+ var config = configService.getSync().wallet.settings;
+ if (config.unitCode == 'sat') return amount;
+
+ //TODO : now only works for english, specify opts to change thousand separator and decimal separator
+ var opts = {
+ fullPrecision: !!fullPrecision
+ };
+ return this.Utils.formatAmount(amount, config.unitCode, opts);
+ };
+
+
+
var formatAmountStr = function(amount) {
if (!amount) return;
var config = configService.getSync().wallet.settings;
- return walletService.formatAmount(amount) + ' ' + config.unitName;
+ return root.formatAmount(amount) + ' ' + config.unitName;
};
var formatAlternativeStr = function(amount) {
@@ -18,7 +43,7 @@ angular.module('copayApp.services').factory('txFormatService', function(walletSe
var formatFeeStr = function(fee) {
if (!fee) return;
var config = configService.getSync().wallet.settings;
- return walletService.formatAmount(fee) + ' ' + config.unitName;
+ return root.formatAmount(fee) + ' ' + config.unitName;
};
root.processTx = function(tx) {
diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js
index 362b88618..5b9221fef 100644
--- a/src/js/services/walletService.js
+++ b/src/js/services/walletService.js
@@ -1,7 +1,7 @@
'use strict';
// DO NOT INCLUDE STORAGE HERE \/ \/
-angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, bwcService, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus) {
+angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, bwcService, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus, txFormatService, $ionicModal) {
// DO NOT INCLUDE STORAGE HERE ^^
//
//
@@ -30,29 +30,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
- // // RECEIVE
- // // Check address
- // root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
- // if (used) {
- // $log.debug('Address used. Creating new');
- // $rootScope.$emit('Local/AddressIsUsed');
- // }
- // });
- //
-
- root.Utils = bwcService.getUtils();
- root.formatAmount = function(amount, fullPrecision) {
- var config = configService.getSync().wallet.settings;
- if (config.unitCode == 'sat') return amount;
-
- //TODO : now only works for english, specify opts to change thousand separator and decimal separator
- var opts = {
- fullPrecision: !!fullPrecision
- };
- return this.Utils.formatAmount(amount, config.unitCode, opts);
- };
-
-
var _signWithLedger = function(wallet, txp, cb) {
$log.info('Requesting Ledger Chrome app to sign the transaction');
@@ -169,12 +146,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
wallet.unitName = config.unitName;
//STR
- wallet.totalBalanceStr = root.formatAmount(wallet.totalBalanceSat) + ' ' + wallet.unitName;
- wallet.lockedBalanceStr = root.formatAmount(wallet.lockedBalanceSat) + ' ' + wallet.unitName;
- wallet.availableBalanceStr = root.formatAmount(wallet.availableBalanceSat) + ' ' + wallet.unitName;
+ wallet.totalBalanceStr = txFormatService.formatAmount(wallet.totalBalanceSat) + ' ' + wallet.unitName;
+ wallet.lockedBalanceStr = txFormatService.formatAmount(wallet.lockedBalanceSat) + ' ' + wallet.unitName;
+ wallet.availableBalanceStr = txFormatService.formatAmount(wallet.availableBalanceSat) + ' ' + wallet.unitName;
if (wallet.pendingAmount) {
- wallet.pendingAmountStr = root.formatAmount(wallet.pendingAmount) + ' ' + wallet.unitName;
+ wallet.pendingAmountStr = txFormatService.formatAmount(wallet.pendingAmount) + ' ' + wallet.unitName;
} else {
wallet.pendingAmountStr = null;
}
@@ -365,8 +342,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
$log.debug('Fixing Tx Cache Unit to:' + name)
lodash.each(txs, function(tx) {
- tx.amountStr = root.formatAmount(tx.amount) + name;
- tx.feeStr = root.formatAmount(tx.fees) + name;
+ tx.amountStr = txFormatService.formatAmount(tx.amount) + name;
+ tx.feeStr = txFormatService.formatAmount(tx.fees) + name;
});
};