mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-10-02 08:10:44 +00:00
- fix updateNovaMarkets - slight refactor of trading to handle symbol2 - get deposit addresses
60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
// markets
|
|
|
|
function nova_api_query($method)
|
|
{
|
|
$uri = "https://novaexchange.com/remote/v2/$method/";
|
|
|
|
$ch = curl_init($uri);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
$res= curl_exec($ch);
|
|
$obj = json_decode($res);
|
|
|
|
return $obj;
|
|
}
|
|
|
|
function nova_api_user($method, $params=array())
|
|
{
|
|
require_once('/etc/yiimp/keys.php');
|
|
if (!defined('EXCH_NOVA_SECRET')) define('EXCH_NOVA_SECRET', '');
|
|
|
|
if (empty(EXCH_NOVA_KEY) || empty(EXCH_NOVA_SECRET)) return false;
|
|
|
|
$uri = "https://novaexchange.com/remote/v2/private/$method/?nonce=".time();
|
|
|
|
$headers = array(
|
|
'Content-Type: application/x-www-form-urlencoded',
|
|
);
|
|
|
|
$params['apikey'] = EXCH_NOVA_KEY;
|
|
$params['signature'] = base64_encode(hash_hmac('sha512', $uri, EXCH_NOVA_SECRET, true));
|
|
|
|
$postdata = http_build_query($params, '', '&');
|
|
// Clear the params array so that we don't accidentaly leak our keys
|
|
$params = array();
|
|
|
|
$ch = curl_init($uri);
|
|
//curl_setopt($ch, CURLOPT_POST, 1);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
//curl_setopt($ch, CURLOPT_SSLVERSION, 1 /*CURL_SSLVERSION_TLSv1*/);
|
|
curl_setopt($ch, CURLOPT_SSL_SESSIONID_CACHE, 0);
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Nova API PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
|
|
curl_setopt($ch, CURLOPT_ENCODING , '');
|
|
|
|
$data = curl_exec($ch);
|
|
$res = json_decode($data);
|
|
|
|
if(!is_object($res) || $res->status != 'success') {
|
|
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
debuglog("nova: $method failed ($status) ".strip_data($data).' '.curl_error($ch));
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
return $res;
|
|
}
|