Adds bitcoin cash basic support (unit convertion, integrations, request specific amount, etc)

This commit is contained in:
Gustavo Maximiliano Cortez 2017-08-24 17:02:49 -03:00
commit 94363704ab
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
24 changed files with 376 additions and 302 deletions

View file

@ -69,14 +69,15 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.$on("$ionicView.beforeEnter", function(event, data) {
function setWalletSelector(network, minAmount, cb) {
function setWalletSelector(chain, network, minAmount, cb) {
// no min amount? (sendMax) => look for no empty wallets
minAmount = minAmount || 1;
$scope.wallets = profileService.getWallets({
onlyComplete: true,
network: network
network: network,
chain: chain
});
if (!$scope.wallets || !$scope.wallets.length) {
@ -137,6 +138,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
toEmail: data.stateParams.toEmail,
toColor: data.stateParams.toColor,
network: (new bitcore.Address(data.stateParams.toAddress)).network.name,
chain: data.stateParams.chain || 'BTC',
txp: {},
};
@ -146,23 +148,21 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.isWindowsPhoneApp = isWindowsPhoneApp;
$scope.showAddress = false;
updateTx(tx, null, {}, function() {
$scope.walletSelectorTitle = gettextCatalog.getString('Send from');
$scope.walletSelectorTitle = gettextCatalog.getString('Send from');
setWalletSelector(tx.network, tx.toAmount, function(err) {
if (err) {
return exitWithError('Could not update wallets');
}
if ($scope.wallets.length > 1) {
$scope.showWalletSelector();
} else if ($scope.wallets.length) {
setWallet($scope.wallets[0], tx);
}
});
setWalletSelector(tx.chain, tx.network, tx.toAmount, function(err) {
if (err) {
return exitWithError('Could not update wallets');
}
if ($scope.wallets.length > 1) {
$scope.showWalletSelector();
} else if ($scope.wallets.length) {
setWallet($scope.wallets[0], tx);
}
});
});
@ -238,7 +238,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (!tx.toAmount) return;
// Amount
tx.amountStr = txFormatService.formatAmountStr(tx.toAmount);
tx.amountStr = txFormatService.formatAmountStr(wallet, tx.toAmount);
tx.amountValueStr = tx.amountStr.split(' ')[0];
tx.amountUnitStr = tx.amountStr.split(' ')[1];
txFormatService.formatAlternativeStr(tx.toAmount, function(v) {
@ -280,7 +280,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
tx.sendMaxInfo = sendMaxInfo;
tx.toAmount = tx.sendMaxInfo.amount;
updateAmount();
showSendMaxWarning(sendMaxInfo);
showSendMaxWarning(wallet, sendMaxInfo);
}
// txp already generated for this wallet?
@ -292,7 +292,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
getTxp(lodash.clone(tx), wallet, opts.dryRun, function(err, txp) {
if (err) return cb(err);
txp.feeStr = txFormatService.formatAmountStr(txp.fee);
txp.feeStr = txFormatService.formatAmountStr(wallet, txp.fee);
txFormatService.formatAlternativeStr(txp.fee, function(v) {
txp.alternativeFeeStr = v;
});
@ -337,26 +337,26 @@ angular.module('copayApp.controllers').controller('confirmController', function(
};
function showSendMaxWarning(sendMaxInfo) {
function showSendMaxWarning(wallet, sendMaxInfo) {
function verifyExcludedUtxos() {
var warningMsg = [];
if (sendMaxInfo.utxosBelowFee > 0) {
warningMsg.push(gettextCatalog.getString("A total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
amountBelowFeeStr: txFormatService.formatAmountStr(sendMaxInfo.amountBelowFee)
amountBelowFeeStr: txFormatService.formatAmountStr(wallet, sendMaxInfo.amountBelowFee)
}));
}
if (sendMaxInfo.utxosAboveMaxSize > 0) {
warningMsg.push(gettextCatalog.getString("A total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded.", {
amountAboveMaxSizeStr: txFormatService.formatAmountStr(sendMaxInfo.amountAboveMaxSize)
amountAboveMaxSizeStr: txFormatService.formatAmountStr(wallet, sendMaxInfo.amountAboveMaxSize)
}));
}
return warningMsg.join('\n');
};
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees.", {
fee: txFormatService.formatAmountStr(sendMaxInfo.fee)
fee: txFormatService.formatAmountStr(wallet, sendMaxInfo.fee)
});
var warningMsg = verifyExcludedUtxos();