markets: cryptopia maintenance + livecoin deposit addr

This commit is contained in:
Tanguy Pruvot 2017-01-31 23:36:54 +01:00
parent 448144949a
commit 8d930e0f33
3 changed files with 33 additions and 3 deletions

View file

@ -156,7 +156,8 @@ class ExchangeCommand extends CConsoleCommand
} }
if (!empty(EXCH_CRYPTOPIA_KEY)) { if (!empty(EXCH_CRYPTOPIA_KEY)) {
$balance = cryptopia_api_user('GetBalance',array("Currency"=>"BTC")); $balance = cryptopia_api_user('GetBalance',array("Currency"=>"BTC"));
echo("cryptopia btc: ".json_encode($balance->Data)."\n"); if (!is_object($balance)) echo("cryptopia error ".json_encode($balance)."\n");
else echo("cryptopia btc: ".json_encode($balance->Data)."\n");
} }
if (!empty(EXCH_KRAKEN_KEY)) { if (!empty(EXCH_KRAKEN_KEY)) {
$balance = kraken_api_user('Balance'); $balance = kraken_api_user('Balance');

View file

@ -775,6 +775,10 @@ function updateCryptopiaMarkets()
$market->message = 'disabled from settings'; $market->message = 'disabled from settings';
$market->save(); $market->save();
continue; continue;
} else if ($market->message == 'disabled from settings') {
$market->disabled = 0;
$market->message = '';
$market->save();
} }
foreach ($data->Data as $ticker) { foreach ($data->Data as $ticker) {
@ -1021,9 +1025,34 @@ function updateLivecoinMarkets()
if (empty($coin->price2)) { if (empty($coin->price2)) {
$coin->price = $market->price; $coin->price = $market->price;
$coin->price2 = $market->price2; $coin->price2 = $market->price2;
$coin->market = 'empoex'; //$coin->market = 'shapeshift';
$coin->save(); $coin->save();
} }
if(!empty(EXCH_LIVECOIN_KEY) && $market->disabled == 0)
{
$last_checked = cache()->get($exchange.'-deposit_address-check-'.$coin->symbol);
if(empty($market->deposit_address) && !$last_checked)
{
sleep(1);
$data = livecoin_api_user('payment/get/address', array('currency'=>$coin->symbol));
if(!empty($data) && objSafeVal($data, 'wallet', '') != '') {
$addr = arraySafeVal($data, 'wallet');
if (!empty($addr) && $addr != $market->deposit_address) {
if (strpos($addr, 'Error') !== false)
$market->message = $addr;
else {
$market->deposit_address = $addr;
// delimiter "::" for memo / payment id
$market->message = null;
debuglog("$exchange: deposit address for {$coin->symbol} updated");
}
$market->save();
}
}
}
cache()->set($exchange.'-deposit_address-check-'.$coin->symbol, time(), 24*3600);
}
} }
} }
} }

View file

@ -72,7 +72,7 @@ function cryptopia_api_user($method, $params=NULL)
$result = json_decode($res); $result = json_decode($res);
if(!is_object($result) && !is_array($result)) { if(!is_object($result) && !is_array($result)) {
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
debuglog("cryptopia: $method failed ($status) $res"); debuglog("cryptopia: $method failed ($status) ".strip_data($res));
} }
curl_close($ch); curl_close($ch);