mirror of https://github.com/BTCPrivate/copay.git
Testing coinbase
This commit is contained in:
parent
f6245652d9
commit
04db3f9159
|
@ -1,9 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('buyCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, $ionicConfig, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService, txFormatService) {
|
angular.module('copayApp.controllers').controller('buyCoinbaseController', function($scope, $log, $state, $timeout, $ionicHistory, $ionicScrollDelegate, $ionicConfig, lodash, coinbaseService, popupService, profileService, ongoingProcess, walletService, txFormatService, feeService) {
|
||||||
|
|
||||||
var amount;
|
var amount;
|
||||||
var currency;
|
var currency;
|
||||||
|
var feeBTC;
|
||||||
|
|
||||||
var showErrorAndBack = function(err) {
|
var showErrorAndBack = function(err) {
|
||||||
$scope.sendStatus = '';
|
$scope.sendStatus = '';
|
||||||
|
@ -46,11 +47,31 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
|
||||||
var parsedAmount = txFormatService.parseAmount(
|
var parsedAmount = txFormatService.parseAmount(
|
||||||
data.stateParams.amount,
|
data.stateParams.amount,
|
||||||
data.stateParams.currency);
|
data.stateParams.currency);
|
||||||
|
console.log('[buyCoinbase.js:46]',parsedAmount); //TODO/
|
||||||
|
|
||||||
|
// Buy always in BTC
|
||||||
|
amount = (parsedAmount.amountSat / 100000000).toFixed(8);
|
||||||
|
console.log('[buyCoinbase.js:52]',amount); //TODO/
|
||||||
|
currency = 'BTC';
|
||||||
|
console.log('[buyCoinbase.js:54]',currency); //TODO/
|
||||||
|
|
||||||
amount = parsedAmount.amount;
|
|
||||||
currency = parsedAmount.currency;
|
|
||||||
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
$scope.amountUnitStr = parsedAmount.amountUnitStr;
|
||||||
|
console.log('[buyCoinbase.js:57]',$scope.amountUnitStr); //TODO/
|
||||||
|
|
||||||
|
// Fee Normal for a single transaction
|
||||||
|
var txNormalFeeKB = 450 / 1024;
|
||||||
|
console.log('[buyCoinbase.js:60]',txNormalFeeKB); //TODO/
|
||||||
|
feeService.getCurrentFeeValue(null, 'normal', function(err, feePerKB) {
|
||||||
|
feeBTC = (feePerKB * txNormalFeeKB / 100000000).toFixed(8);
|
||||||
|
console.log('[buyCoinbase.js:60]',feePerKB, feeBTC, amount - feeBTC); //TODO/
|
||||||
|
// Check if transaction has enough funds to transfer bitcoin from Coinbase to Copay
|
||||||
|
if (amount - feeBTC < 0) {
|
||||||
|
showErrorAndBack('Not enough funds for fee');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return; // TODO
|
||||||
$scope.network = coinbaseService.getNetwork();
|
$scope.network = coinbaseService.getNetwork();
|
||||||
$scope.wallets = profileService.getWallets({
|
$scope.wallets = profileService.getWallets({
|
||||||
onlyComplete: true,
|
onlyComplete: true,
|
||||||
|
|
Loading…
Reference in New Issue