mirror of https://github.com/BTCPrivate/copay.git
Selling process
This commit is contained in:
parent
612d706779
commit
4febe719b0
|
@ -52,14 +52,22 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
|
||||
if ($scope.isCoinbase) {
|
||||
var currency = 'USD';
|
||||
|
||||
coinbaseService.init(function(err, data) {
|
||||
if ($scope.isCoinbase == 'buy') {
|
||||
coinbaseService.buyPrice(data.accessToken, currency, function(err, b) {
|
||||
$scope.coinbaseBuyPrice = b.data || null;
|
||||
});
|
||||
} else {
|
||||
coinbaseService.sellPrice(data.accessToken, currency, function(err, b) {
|
||||
$scope.coinbaseSellPrice = b.data || null;
|
||||
coinbaseService.sellPrice(data.accessToken, currency, function(err, s) {
|
||||
$scope.coinbaseSellPrice = s.data || null;
|
||||
});
|
||||
|
||||
var dataSrc = {
|
||||
name: 'Received from ' + $window.appConfig.nameCase
|
||||
};
|
||||
coinbaseService.createAddress(data.accessToken, data.accountId, dataSrc, function(err, data) {
|
||||
$scope.toAddress = data.data.address;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -394,10 +402,15 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
popupService.showAlert(gettextCatalog.getString('Error'), 'No Payment Method Selected');
|
||||
return;
|
||||
}
|
||||
if ($scope.isCoinbase == 'sell' && lodash.isEmpty($scope.toAddress)) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), 'No Destination Address');
|
||||
return;
|
||||
}
|
||||
var amountUSD = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount));
|
||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
||||
$state.transitionTo('tabs.buyandsell.coinbase.confirm', {
|
||||
toAmount: (amount * unitToSatoshi).toFixed(0),
|
||||
toAddress: $scope.toAddress,
|
||||
isCoinbase: $scope.isCoinbase,
|
||||
coinbasePaymentMethodId: $scope.coinbaseSelectedPaymentMethod.id,
|
||||
coinbaseAmount: amountUSD,
|
||||
|
|
|
@ -7,7 +7,6 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
|
|||
var init = function() {
|
||||
ongoingProcess.set('connectingCoinbase', true);
|
||||
coinbaseService.init(function(err, data) {
|
||||
console.log('[coinbase.js:9]',err, data); //TODO)
|
||||
ongoingProcess.set('connectingCoinbase', false);
|
||||
if (err || lodash.isEmpty(data)) {
|
||||
if (err) {
|
||||
|
@ -26,9 +25,8 @@ console.log('[coinbase.js:9]',err, data); //TODO)
|
|||
};
|
||||
|
||||
$scope.updateTransactions = function() {
|
||||
$log.debug('Checking for transactions...');
|
||||
$log.debug('Getting transactions...');
|
||||
coinbaseService.getPendingTransactions($scope.accessToken, $scope.accountId, function(err, txs) {
|
||||
console.log('[coinbase.js:43]',txs); //TODO
|
||||
$scope.pendingTransactions = txs;
|
||||
});
|
||||
|
||||
|
|
|
@ -186,6 +186,19 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
if ($scope.isCoinbase == 'buy') {
|
||||
coinbaseBuyRequest($scope.coinbaseAmount, $scope.coinbaseAmountCurrency, $scope.coinbasePaymentMethodId);
|
||||
}
|
||||
|
||||
if ($scope.isCoinbase == 'sell') {
|
||||
var satToBtc = 1 / 100000000;
|
||||
$scope.coinbaseAmountBTC = (toAmount * satToBtc).toFixed(8);
|
||||
$scope.priceSensitivity = coinbaseService.priceSensitivity;
|
||||
$scope.selectedPriceSensitivity = { data: coinbaseService.selectedPriceSensitivity };
|
||||
|
||||
coinbaseService.init(function(err, data) {
|
||||
coinbaseService.sellPrice(data.accessToken, $scope.coinbaseAmountCurrency, function(err, sell) {
|
||||
$scope.coinbaseSellPrice = sell.data;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function resetValues() {
|
||||
|
@ -373,7 +386,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.wallet = wallet;
|
||||
$scope.fee = $scope.txp = null;
|
||||
|
||||
if ($scope.isGlidera || $scope.isCoinbase) return;
|
||||
if ($scope.isGlidera || $scope.isCoinbase == 'buy') return;
|
||||
if (stop) {
|
||||
$timeout.cancel(stop);
|
||||
stop = null;
|
||||
|
@ -542,6 +555,8 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
if ($scope.isCoinbase) {
|
||||
|
||||
// BUY
|
||||
if ($scope.isCoinbase == 'buy') {
|
||||
ongoingProcess.set('buyingBitcoin', true, onSendStatusChange);
|
||||
coinbaseService.init(function(err, res) {
|
||||
if (err) {
|
||||
|
@ -551,7 +566,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var token = res.accessToken;
|
||||
var accountId = res.accountId;
|
||||
coinbaseService.buyCommit(token, accountId, $scope.coinbaseBuyRequest.id, function(err, b) {
|
||||
console.log('[confirm.js:508] BUY COMMIT',b); //TODO
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
return;
|
||||
|
@ -560,10 +574,8 @@ console.log('[confirm.js:508] BUY COMMIT',b); //TODO
|
|||
if (!tx) return;
|
||||
|
||||
coinbaseService.getTransaction(token, accountId, tx.id, function(err, updatedTx) {
|
||||
console.log('[confirm.js:517] GET TRANSACTION',updatedTx); //TODO
|
||||
if (err) $log.debug(err);
|
||||
walletService.getAddress($scope.wallet, false, function(err, walletAddr) {
|
||||
console.log('[confirm.js:521] GET ADDRESS',walletAddr); //TODO
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
@ -581,6 +593,85 @@ console.log('[confirm.js:521] GET ADDRESS',walletAddr); //TODO
|
|||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// SELL
|
||||
if ($scope.isCoinbase == 'sell') {
|
||||
|
||||
ongoingProcess.set('sellingBitcoin', true, onSendStatusChange);
|
||||
createTx($scope.wallet, false, function(err, txp) {
|
||||
var message = gettextCatalog.getString('Selling {{amountStr}} from {{name}}', {
|
||||
amountStr: $scope.coinbaseAmount + ' ' + $scope.coinbaseAmountCurrency,
|
||||
name: $scope.wallet.name
|
||||
});
|
||||
var okText = gettextCatalog.getString('Confirm');
|
||||
var cancelText = gettextCatalog.getString('Cancel');
|
||||
|
||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||
if (!ok) {
|
||||
$scope.sendStatus = '';
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
});
|
||||
return;
|
||||
}
|
||||
// SIMULATE publishAndSign
|
||||
//$log.warn('Simulating publishAndSign...');
|
||||
publishAndSign(wallet, txp, onSendStatusChange);
|
||||
|
||||
$timeout(function() {
|
||||
|
||||
coinbaseService.init(function(err, res) {
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
var token = res.accessToken;
|
||||
var accountId = res.accountId;
|
||||
|
||||
coinbaseService.getAddressTransactions(token, accountId, $scope.toAddress, function(err, ctxs) {
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
$log.debug(err);
|
||||
return;
|
||||
}
|
||||
var coinbaseTransactions = ctxs.data;
|
||||
var txFound = false;
|
||||
var ctx;
|
||||
for(var i = 0; i < coinbaseTransactions.length; i++) {
|
||||
ctx = coinbaseTransactions[i];
|
||||
if (ctx.type == 'send' && ctx.from) {
|
||||
txFound = true;
|
||||
if (ctx.status == 'completed') {
|
||||
coinbaseSellRequest(token, accountId, ctx, onSendStatusChange);
|
||||
} else {
|
||||
$log.debug('Saving transaction to process later');
|
||||
ctx['price_sensitivity'] = $scope.selectedPriceSensitivity.data;
|
||||
ctx['sell_price_amount'] = $scope.coinbaseSellPrice ? $scope.coinbaseSellPrice.amount : '';
|
||||
ctx['sell_price_currency'] = $scope.coinbaseSellPrice ? $scope.coinbaseSellPrice.currency : 'USD';
|
||||
ctx['description'] = $window.appConfig.nameCase + ' Wallet: ' + $scope.wallet.name;
|
||||
$scope.coinbaseSendInfo = ctx;
|
||||
coinbaseService.savePendingTransaction(ctx, null, function(err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, onSendStatusChange);
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!txFound) {
|
||||
// Transaction sent, but can not verify it on Coinbase.com
|
||||
// TODO: improve error message
|
||||
ongoingProcess.clear();
|
||||
return setSendError('Transaction not found. Please, verify if transaction exists on Coinbase.com');
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 5000);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -635,7 +726,8 @@ console.log('[confirm.js:521] GET ADDRESS',walletAddr); //TODO
|
|||
processName === 'broadcastingTx' ||
|
||||
((processName === 'signingTx') && $scope.wallet.m > 1) ||
|
||||
(processName == 'sendingTx' && !$scope.wallet.canSign() && !$scope.wallet.isPrivKeyExternal()) ||
|
||||
(processName == 'buyingBitcoin')
|
||||
(processName == 'buyingBitcoin') ||
|
||||
(processName == 'sellingBitcoin' && ($scope.coinbaseSellRequest || $scope.coinbaseSendInfo))
|
||||
) && !isOn) {
|
||||
$scope.sendStatus = 'success';
|
||||
$timeout(function() {
|
||||
|
@ -979,7 +1071,6 @@ console.log('[confirm.js:521] GET ADDRESS',walletAddr); //TODO
|
|||
return;
|
||||
}
|
||||
coinbaseService.buyRequest(res.accessToken, res.accountId, dataSrc, function(err, data) {
|
||||
console.log('[confirm.js:931] BUY REQUEST',data); //TODO
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
return;
|
||||
|
@ -989,6 +1080,25 @@ console.log('[confirm.js:931] BUY REQUEST',data); //TODO
|
|||
});
|
||||
};
|
||||
|
||||
var coinbaseSellRequest = function(accessToken, accountId, ctx, onSendStatusChange) {
|
||||
var dataSrc = ctx.amount;
|
||||
dataSrc['payment_method'] = $scope.coinbasePaymentMethodId || null;
|
||||
dataSrc['commit'] = true;
|
||||
|
||||
coinbaseService.sellRequest(accessToken, accountId, dataSrc, function(err, data) {
|
||||
if (err) {
|
||||
ongoingProcess.clear();
|
||||
$log.error(err);
|
||||
return;
|
||||
}
|
||||
$scope.coinbaseSellRequest = data.data;
|
||||
coinbaseService.savePendingTransaction($scope.coinbaseSellRequest, null, function(err) {
|
||||
ongoingProcess.set('sellingBitcoin', false, onSendStatusChange);
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var coinbaseSendToCopay = function(token, accountId, tx, onSendStatusChange) {
|
||||
var data = {
|
||||
to: tx.toAddr,
|
||||
|
@ -997,20 +1107,17 @@ console.log('[confirm.js:931] BUY REQUEST',data); //TODO
|
|||
description: 'Copay Wallet: ' + $scope.wallet.name
|
||||
};
|
||||
coinbaseService.sendTo(token, accountId, data, function(err, res) {
|
||||
console.log('[confirm.js:938] SEND TO',res); //TODO
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
$scope.coinbaseReceiveInfo = res.data;
|
||||
if (!res.data.id) return;
|
||||
coinbaseService.getTransaction(token, accountId, res.data.id, function(err, sendTx) {
|
||||
console.log('[confirm.js:945] GET TRANSACTION',sendTx); //TODO
|
||||
coinbaseService.savePendingTransaction(tx, {
|
||||
remove: true
|
||||
}, function(err) {
|
||||
coinbaseService.savePendingTransaction(sendTx.data, {}, function(err) {
|
||||
ongoingProcess.set('buyingBitcoin', false, onSendStatusChange);
|
||||
console.log('[confirm.js:948] LISTO',err); //TODO
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
|
|
|
@ -955,7 +955,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('tabs.buyandsell.coinbase.confirm', {
|
||||
url: '/confirm/:toAmount/:isCoinbase/:coinbasePaymentMethodId/:coinbaseAmount/:coinbaseAmountCurrency',
|
||||
url: '/confirm/:toAmount/:toAddress/:isCoinbase/:coinbasePaymentMethodId/:coinbaseAmount/:coinbaseAmountCurrency',
|
||||
views: {
|
||||
'tab-home@tabs': {
|
||||
controller: 'confirmController',
|
||||
|
|
|
@ -6,9 +6,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
var isCordova = platformInfo.isCordova;
|
||||
var isNW = platformInfo.isNW;
|
||||
|
||||
// FAKE DATA
|
||||
var isFake = true;
|
||||
|
||||
root.priceSensitivity = [
|
||||
{
|
||||
value: 0.5,
|
||||
|
@ -271,7 +268,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
root.getTransaction = function(token, accountId, transactionId, cb) {
|
||||
if (isFake) return cb(null, get_transaction);
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/accounts/' + accountId + '/transactions/' + transactionId, token)).then(function(data) {
|
||||
$log.info('Coinbase Transaction: SUCCESS');
|
||||
|
@ -282,6 +278,17 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
});
|
||||
};
|
||||
|
||||
root.getAddressTransactions = function(token, accountId, addressId, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/accounts/' + accountId + '/addresses/' + addressId + '/transactions', token)).then(function(data) {
|
||||
$log.info('Coinbase Address s Transactions: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
}, function(data) {
|
||||
$log.error('Coinbase Address s Transactions: ERROR ' + data.statusText);
|
||||
return cb(data.data);
|
||||
});
|
||||
};
|
||||
|
||||
root.getTransactions = function(token, accountId, cb) {
|
||||
if (!token) return cb('Invalid Token');
|
||||
$http(_get('/accounts/' + accountId + '/transactions', token)).then(function(data) {
|
||||
|
@ -325,7 +332,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
root.getPaymentMethods = function(token, cb) {
|
||||
if (isFake) return cb(null, payment_methods);
|
||||
$http(_get('/payment-methods', token)).then(function(data) {
|
||||
$log.info('Coinbase Get Payment Methods: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
|
@ -385,7 +391,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
root.buyRequest = function(token, accountId, data, cb) {
|
||||
if (isFake) return cb(null, buy_request);
|
||||
var data = {
|
||||
amount: data.amount,
|
||||
currency: data.currency,
|
||||
|
@ -402,7 +407,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
root.buyCommit = function(token, accountId, buyId, cb) {
|
||||
if (isFake) return cb(null, buy_commit);
|
||||
$http(_post('/accounts/' + accountId + '/buys/' + buyId + '/commit', token)).then(function(data) {
|
||||
$log.info('Coinbase Buy Commit: SUCCESS');
|
||||
return cb(null, data.data);
|
||||
|
@ -426,7 +430,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
};
|
||||
|
||||
root.sendTo = function(token, accountId, data, cb) {
|
||||
if (isFake) return cb(null, send_to_copay);
|
||||
var data = {
|
||||
type: 'send',
|
||||
to: data.to,
|
||||
|
@ -485,7 +488,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
(dataFromStorage.type == 'send' && dataFromStorage.status == 'completed'))
|
||||
return cb(null, coinbasePendingTransactions);
|
||||
root.getTransaction(accessToken, accountId, txId, function(err, tx) {
|
||||
if (err) {
|
||||
if (err || lodash.isEmpty(tx)) {
|
||||
_savePendingTransaction(dataFromStorage, {
|
||||
status: 'error',
|
||||
error: err
|
||||
|
@ -633,208 +636,6 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
|||
});
|
||||
};
|
||||
|
||||
var buy_request = {
|
||||
"data" : {
|
||||
"id": "a333743d-184a-5b5b-abe8-11612fc44ab5",
|
||||
"status": "created",
|
||||
"payment_method": {
|
||||
"id": "83562370-3e5c-51db-87da-752af5ab9559",
|
||||
"resource": "payment_method",
|
||||
"resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
|
||||
},
|
||||
"transaction": {
|
||||
"id": "763d1401-fd17-5a18-852a-9cca5ac2f9c0",
|
||||
"resource": "transaction",
|
||||
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/441b9494-b3f0-5b98-b9b0-4d82c21c252a"
|
||||
},
|
||||
"amount": {
|
||||
"amount": "10.00000000",
|
||||
"currency": "BTC"
|
||||
},
|
||||
"total": {
|
||||
"amount": "102.01",
|
||||
"currency": "USD"
|
||||
},
|
||||
"subtotal": {
|
||||
"amount": "101.00",
|
||||
"currency": "USD"
|
||||
},
|
||||
"created_at": "2015-04-01T18:43:37-07:00",
|
||||
"updated_at": "2015-04-01T18:43:37-07:00",
|
||||
"resource": "buy",
|
||||
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/buys/a333743d-184a-5b5b-abe8-11612fc44ab5",
|
||||
"committed": false,
|
||||
"instant": false,
|
||||
"fee": {
|
||||
"amount": "1.01",
|
||||
"currency": "USD"
|
||||
},
|
||||
"payout_at": "2015-04-07T18:43:37-07:00"
|
||||
}
|
||||
};
|
||||
|
||||
var payment_methods = {
|
||||
"pagination": {
|
||||
"ending_before": null,
|
||||
"starting_after": null,
|
||||
"limit": 25,
|
||||
"order": "desc",
|
||||
"previous_uri": null,
|
||||
"next_uri": null
|
||||
},
|
||||
"data": [
|
||||
{
|
||||
"id": "127b4d76-a1a0-5de7-8185-3657d7b526ec",
|
||||
"type": "fiat_account",
|
||||
"name": "USD Wallet",
|
||||
"currency": "USD",
|
||||
"primary_buy": false,
|
||||
"primary_sell": false,
|
||||
"allow_buy": true,
|
||||
"allow_sell": true,
|
||||
"allow_deposit": true,
|
||||
"allow_withdraw": true,
|
||||
"instant_buy": true,
|
||||
"instant_sell": true,
|
||||
"created_at": "2015-02-24T14:30:30-08:00",
|
||||
"updated_at": "2015-02-24T14:30:30-08:00",
|
||||
"resource": "payment_method",
|
||||
"resource_path": "/v2/payment-methods/127b4d76-a1a0-5de7-8185-3657d7b526ec",
|
||||
"fiat_account": {
|
||||
"id": "a077fff9-312b-559b-af98-146c33e27388",
|
||||
"resource": "account",
|
||||
"resource_path": "/v2/accounts/a077fff9-312b-559b-af98-146c33e27388"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "83562370-3e5c-51db-87da-752af5ab9559",
|
||||
"type": "ach_bank_account",
|
||||
"name": "International Bank *****1111",
|
||||
"currency": "USD",
|
||||
"primary_buy": true,
|
||||
"primary_sell": true,
|
||||
"allow_buy": true,
|
||||
"allow_sell": true,
|
||||
"allow_deposit": true,
|
||||
"allow_withdraw": true,
|
||||
"instant_buy": false,
|
||||
"instant_sell": false,
|
||||
"created_at": "2015-01-31T20:49:02Z",
|
||||
"updated_at": "2015-02-11T16:53:57-08:00",
|
||||
"resource": "payment_method",
|
||||
"resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var get_transaction = {
|
||||
"data" : {
|
||||
"id": "57ffb4ae-0c59-5430-bcd3-3f98f797a66c",
|
||||
"type": "send",
|
||||
"status": "completed",
|
||||
"amount": {
|
||||
"amount": "-0.00100000",
|
||||
"currency": "BTC"
|
||||
},
|
||||
"native_amount": {
|
||||
"amount": "-0.01",
|
||||
"currency": "USD"
|
||||
},
|
||||
"description": null,
|
||||
"created_at": "2015-03-11T13:13:35-07:00",
|
||||
"updated_at": "2015-03-26T15:55:43-07:00",
|
||||
"resource": "transaction",
|
||||
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/57ffb4ae-0c59-5430-bcd3-3f98f797a66c",
|
||||
"network": {
|
||||
"status": "off_blockchain",
|
||||
"name": "bitcoin"
|
||||
},
|
||||
"to": {
|
||||
"id": "a6b4c2df-a62c-5d68-822a-dd4e2102e703",
|
||||
"resource": "user",
|
||||
"resource_path": "/v2/users/a6b4c2df-a62c-5d68-822a-dd4e2102e703"
|
||||
},
|
||||
"details": {
|
||||
"title": "Send bitcoin",
|
||||
"subtitle": "to User 2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var buy_commit = {
|
||||
"data" : {
|
||||
"id": "a333743d-184a-5b5b-abe8-11612fc44ab5",
|
||||
"status": "created",
|
||||
"payment_method": {
|
||||
"id": "83562370-3e5c-51db-87da-752af5ab9559",
|
||||
"resource": "payment_method",
|
||||
"resource_path": "/v2/payment-methods/83562370-3e5c-51db-87da-752af5ab9559"
|
||||
},
|
||||
"transaction": {
|
||||
"id": "763d1401-fd17-5a18-852a-9cca5ac2f9c0",
|
||||
"resource": "transaction",
|
||||
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/441b9494-b3f0-5b98-b9b0-4d82c21c252a"
|
||||
},
|
||||
"amount": {
|
||||
"amount": "10.00000000",
|
||||
"currency": "BTC"
|
||||
},
|
||||
"total": {
|
||||
"amount": "102.01",
|
||||
"currency": "USD"
|
||||
},
|
||||
"subtotal": {
|
||||
"amount": "101.00",
|
||||
"currency": "USD"
|
||||
},
|
||||
"created_at": "2015-04-01T18:43:37-07:00",
|
||||
"updated_at": "2015-04-01T18:43:37-07:00",
|
||||
"resource": "buy",
|
||||
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/buys/a333743d-184a-5b5b-abe8-11612fc44ab5",
|
||||
"committed": true,
|
||||
"instant": false,
|
||||
"fee": {
|
||||
"amount": "1.01",
|
||||
"currency": "USD"
|
||||
},
|
||||
"payout_at": "2015-04-07T18:43:37-07:00"
|
||||
}
|
||||
};
|
||||
|
||||
var send_to_copay = {
|
||||
"data" : {
|
||||
"id": "3c04e35e-8e5a-5ff1-9155-00675db4ac02",
|
||||
"type": "send",
|
||||
"status": "pending",
|
||||
"amount": {
|
||||
"amount": "-0.10000000",
|
||||
"currency": "BTC"
|
||||
},
|
||||
"native_amount": {
|
||||
"amount": "-1.00",
|
||||
"currency": "USD"
|
||||
},
|
||||
"description": null,
|
||||
"created_at": "2015-01-31T20:49:02Z",
|
||||
"updated_at": "2015-03-31T17:25:29-07:00",
|
||||
"resource": "transaction",
|
||||
"resource_path": "/v2/accounts/2bbf394c-193b-5b2a-9155-3b4732659ede/transactions/3c04e35e-8e5a-5ff1-9155-00675db4ac02",
|
||||
"network": {
|
||||
"status": "unconfirmed",
|
||||
"hash": "463397c87beddd9a61ade61359a13adc9efea26062191fe07147037bce7f33ed",
|
||||
"name": "bitcoin"
|
||||
},
|
||||
"to": {
|
||||
"resource": "bitcoin_address",
|
||||
"address": "1AUJ8z5RuHRTqD1eikyfUUetzGmdWLGkpT"
|
||||
},
|
||||
"details": {
|
||||
"title": "Send bitcoin",
|
||||
"subtitle": "to User 2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return root;
|
||||
|
||||
});
|
||||
|
|
|
@ -29,6 +29,37 @@
|
|||
<span class="item-note" ng-if="!paymentExpired.value">{{remainingTimeStr.value}}</span>
|
||||
<span class="item-note" ng-if="paymentExpired.value" ng-style="{'color': 'red'}" translate>Expired</span>
|
||||
</div>
|
||||
|
||||
<div class="item single-line" ng-if="isCoinbase == 'sell'">
|
||||
At what percentage lower price would you accept to sell?
|
||||
</div>
|
||||
<label class="item item-input item-select" ng-if="isCoinbase == 'sell' && priceSensitivity">
|
||||
<span class="label">Price Sensitivity</span>
|
||||
<select
|
||||
ng-model="selectedPriceSensitivity.data"
|
||||
ng-options="item as item.name for item in priceSensitivity track by item.value">
|
||||
</select>
|
||||
</label>
|
||||
<div class="item" ng-if="isCoinbase == 'sell' && selectedPriceSensitivity">
|
||||
<div class="m10b size-12">
|
||||
Coinbase has not yet implemented an immediate method to sell bitcoin from a wallet. To make this sale, funds
|
||||
will be sent to your Coinbase account, and sold when Coinbase accepts the transaction (usually one
|
||||
hour).
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
Estimated sale value:
|
||||
<span ng-if="coinbaseSellPrice">
|
||||
{{coinbaseSellPrice.amount * coinbaseAmountBTC | currency : 'USD ' : 2}}
|
||||
</span>
|
||||
</div>
|
||||
Still sell if price fall until:
|
||||
<span ng-if="coinbaseSellPrice">
|
||||
{{(coinbaseSellPrice.amount - (selectedPriceSensitivity.data.value / 100) *
|
||||
coinbaseSellPrice.amount) * coinbaseAmountBTC | currency : 'USD ' : 2}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<span class="label" ng-if="!(isGlidera || isCoinbase)" translate>To</span>
|
||||
<span class="label" ng-if="(isGlidera || isCoinbase) == 'buy'">From</span>
|
||||
|
@ -75,14 +106,14 @@
|
|||
</div>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet && !(isGlidera || isCoinbase)" ng-click="showDescriptionPopup()">
|
||||
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet && !(isGlidera || isCoinbase == 'buy')" ng-click="showDescriptionPopup()">
|
||||
<span class="label" translate>Add Memo</span>
|
||||
<span class="item-note m10l">
|
||||
{{description}}
|
||||
</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet && !(isGlidera || isCoinbase)">
|
||||
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet && !(isGlidera || isCoinbase == 'buy')">
|
||||
<span class="label">{{'Fee' | translate}}: {{feeLevel | translate}}</span>
|
||||
<span class="item-note">
|
||||
{{fee || '...'}}
|
||||
|
@ -159,6 +190,8 @@
|
|||
slide-success-on-confirm="onSuccessConfirm()"
|
||||
slide-success-hide-on-confirm="true">
|
||||
<span ng-show="isCoinbase == 'buy'">Bought</span>
|
||||
<span ng-show="isCoinbase == 'sell' && coinbaseSendInfo">Funds sent to Coinbase Account</span>
|
||||
<span ng-show="isCoinbase == 'sell' && coinbaseSellRequest">Sale initiated</span>
|
||||
<div ng-show="!isCoinbase">
|
||||
<span ng-show="wallet.m == 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Payment Sent</span>
|
||||
<span ng-show="wallet.m > 1 && (wallet.canSign() || wallet.isPrivKeyExternal())" translate>Proposal Created</span>
|
||||
|
@ -177,7 +210,14 @@
|
|||
Buy confirmed. Funds will be send soon to your selected wallet
|
||||
</span>
|
||||
</span>
|
||||
<span ng-show="isCoinbase == 'sell'">Sale initiated</span>
|
||||
<span ng-show="isCoinbase == 'sell'">
|
||||
<span ng-show="coinbaseSendInfo">
|
||||
The transaction is not yet confirmed, and will show as "Processing" in your Activity. The bitcoin sale will be completed automatically once it is confirmed by Coinbase.
|
||||
</span>
|
||||
<span ng-show="coinbaseSellRequest">
|
||||
A transfer has been initiated to your bank account and should arrive at {{coinbaseSellRequest.payout_at | amCalendar}}.
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</slide-to-accept-success>
|
||||
|
||||
|
|
Loading…
Reference in New Issue