Ref chain to coin. Adds create wallet
This commit is contained in:
parent
ac5ede702d
commit
2c33f186af
37 changed files with 90 additions and 89 deletions
|
|
@ -65,8 +65,8 @@ angular.module('copayApp.services').factory('feeService', function($log, $timeou
|
|||
|
||||
var walletClient = bwcService.getClient();
|
||||
|
||||
walletClient.getFeeLevels('livenet', function(errLivenet, levelsLivenet) {
|
||||
walletClient.getFeeLevels('testnet', function(errTestnet, levelsTestnet) {
|
||||
walletClient.getFeeLevels('btc', 'livenet', function(errLivenet, levelsLivenet) {
|
||||
walletClient.getFeeLevels('btc', 'testnet', function(errTestnet, levelsTestnet) {
|
||||
if (errLivenet || errTestnet) {
|
||||
return cb(gettextCatalog.getString('Could not get dynamic fee'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
return true;
|
||||
}
|
||||
|
||||
function goSend(addr, amount, message, chain) {
|
||||
function goSend(addr, amount, message, coin) {
|
||||
$state.go('tabs.send', {}, {
|
||||
'reload': true,
|
||||
'notify': $state.current.name == 'tabs.send' ? false : true
|
||||
|
|
@ -58,12 +58,12 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
toAmount: amount,
|
||||
toAddress: addr,
|
||||
description: message,
|
||||
chain: chain
|
||||
coin: coin
|
||||
});
|
||||
} else {
|
||||
$state.transitionTo('tabs.send.amount', {
|
||||
toAddress: addr,
|
||||
chain: chain
|
||||
coin: coin
|
||||
});
|
||||
}
|
||||
}, 100);
|
||||
|
|
@ -92,17 +92,17 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
var message = parsed.message;
|
||||
|
||||
var amount = parsed.amount ? parsed.amount : '';
|
||||
var chain = parsed.extras && parsed.extras.chain ? (parsed.extras.chain).toUpperCase() : '';
|
||||
var coin = parsed.extras && parsed.extras.coin ? (parsed.extras.coin).toUpperCase() : '';
|
||||
|
||||
if (parsed.r) {
|
||||
payproService.getPayProDetails(parsed.r, function(err, details) {
|
||||
if (err) {
|
||||
if (addr && amount) goSend(addr, amount, message, chain);
|
||||
if (addr && amount) goSend(addr, amount, message, coin);
|
||||
else popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
} else handlePayPro(details);
|
||||
});
|
||||
} else {
|
||||
goSend(addr, amount, message, chain);
|
||||
goSend(addr, amount, message, coin);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -89,10 +89,11 @@ angular.module('copayApp.services')
|
|||
wallet.copayerId = wallet.credentials.copayerId;
|
||||
wallet.m = wallet.credentials.m;
|
||||
wallet.n = wallet.credentials.n;
|
||||
wallet.chain = wallet.credentials.chain ? (wallet.credentials.chain).toUpperCase() : 'BTC';
|
||||
wallet.coin = wallet.credentials.coin ? wallet.credentials.coin : 'btc';
|
||||
console.log('[profileService.js:92]',wallet); //TODO/
|
||||
|
||||
// TODO: Should return "chain" = "BTC" or "BCH"
|
||||
client.credentials.chain = 'BTC';
|
||||
// TODO: Should return "coin" = "btc" or "bch"
|
||||
//client.credentials.coin = 'btc';
|
||||
|
||||
root.updateWalletSettings(wallet);
|
||||
root.wallet[walletId] = wallet;
|
||||
|
|
@ -756,9 +757,9 @@ angular.module('copayApp.services')
|
|||
|
||||
var ret = lodash.values(root.wallet);
|
||||
|
||||
if (opts.chain) {
|
||||
if (opts.coin) {
|
||||
ret = lodash.filter(ret, function(x) {
|
||||
return (x.credentials.chain == opts.chain);
|
||||
return (x.credentials.coin == opts.coin);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
|
||||
root.formatAmountStr = function(wallet, satoshis) {
|
||||
if (isNaN(satoshis)) return;
|
||||
return root.formatAmount(satoshis) + ' ' + wallet.chain;
|
||||
return root.formatAmount(satoshis) + ' ' + wallet.coin;
|
||||
};
|
||||
|
||||
root.toFiat = function(satoshis, code, cb) {
|
||||
|
|
@ -196,13 +196,13 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
amountUnitStr = root.formatAmountStr(wallet, amountSat);
|
||||
// convert sat to BTC or BCH
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = wallet.chain;
|
||||
currency = (wallet.coin).toUpperCase();
|
||||
} else {
|
||||
amountSat = parseInt((amount * unitToSatoshi).toFixed(0));
|
||||
amountUnitStr = root.formatAmountStr(wallet, amountSat);
|
||||
// convert unit to BTC or BCH
|
||||
amount = (amountSat * satToBtc).toFixed(8);
|
||||
currency = wallet.chain;
|
||||
currency = (wallet.coin).toUpperCase();
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -215,11 +215,11 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
cache.satToUnit = 1 / cache.unitToSatoshi;
|
||||
|
||||
//STR
|
||||
cache.totalBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat) + ' ' + wallet.chain;
|
||||
cache.lockedBalanceStr = txFormatService.formatAmount(cache.lockedBalanceSat) + ' ' + wallet.chain;
|
||||
cache.availableBalanceStr = txFormatService.formatAmount(cache.availableBalanceSat) + ' ' + wallet.chain;
|
||||
cache.spendableBalanceStr = txFormatService.formatAmount(cache.spendableAmount) + ' ' + wallet.chain;
|
||||
cache.pendingBalanceStr = txFormatService.formatAmount(cache.pendingAmount) + ' ' + wallet.chain;
|
||||
cache.totalBalanceStr = txFormatService.formatAmount(cache.totalBalanceSat) + ' ' + wallet.coin;
|
||||
cache.lockedBalanceStr = txFormatService.formatAmount(cache.lockedBalanceSat) + ' ' + wallet.coin;
|
||||
cache.availableBalanceStr = txFormatService.formatAmount(cache.availableBalanceSat) + ' ' + wallet.coin;
|
||||
cache.spendableBalanceStr = txFormatService.formatAmount(cache.spendableAmount) + ' ' + wallet.coin;
|
||||
cache.pendingBalanceStr = txFormatService.formatAmount(cache.pendingAmount) + ' ' + wallet.coin;
|
||||
|
||||
cache.alternativeName = config.settings.alternativeName;
|
||||
cache.alternativeIsoCode = config.settings.alternativeIsoCode;
|
||||
|
|
@ -412,12 +412,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
var fixTxsUnit = function(txs) {
|
||||
if (!txs || !txs[0] || !txs[0].amountStr) return;
|
||||
|
||||
var cacheChain = txs[0].amountStr.split(' ')[1];
|
||||
var cacheCoin = txs[0].amountStr.split(' ')[1];
|
||||
|
||||
if (cacheChain == wallet.chain)
|
||||
if (cacheCoin == wallet.coin)
|
||||
return;
|
||||
|
||||
$log.debug('Fixing Tx Cache Unit to: ' + wallet.chain)
|
||||
$log.debug('Fixing Tx Cache Unit to: ' + wallet.coin)
|
||||
lodash.each(txs, function(tx) {
|
||||
tx.amountStr = txFormatService.formatAmountStr(wallet, tx.amount);
|
||||
tx.feeStr = txFormatService.formatAmountStr(wallet, tx.fees);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue