diff --git a/accounts.json b/accounts.json index 94a7cf1..771b513 100644 --- a/accounts.json +++ b/accounts.json @@ -3,6 +3,7 @@ "beeeeer": "\\Account\\MiningPool\\Beeeeer", "bitminter": "\\Account\\MiningPool\\BitMinter", "btcguild": "\\Account\\MiningPool\\BTCGuild", + "clevermining": "\\Account\\MiningPool\\CleverMining", "coinhuntr": "\\Account\\MiningPool\\CoinHuntr", "cryptopools_dgc": "\\Account\\MiningPool\\CryptoPoolsDGC", "cryptotroll_doge": "\\Account\\MiningPool\\CryptoTrollDOGE", @@ -28,9 +29,11 @@ "liteguardian": "\\Account\\MiningPool\\LiteGuardian", "litepooleu": "\\Account\\MiningPool\\LitepoolEu", "ltcmineru": "\\Account\\MiningPool\\LTCMineRu", + "ltcrabbit": "\\Account\\MiningPool\\LTCRabbit", "miningforeman": "\\Account\\MiningPool\\MiningForemanLTC", "miningforeman_ftc": "\\Account\\MiningPool\\MiningForemanFTC", "miningpoolco": "\\Account\\MiningPool\\MiningPoolCo", + "miningpoolhub": "\\Account\\MiningPool\\MiningPoolHub", "multipool": "\\Account\\MiningPool\\Multipool", "mupool": "\\Account\\MiningPool\\MuPool", "nicehash": "\\Account\\MiningPool\\NiceHash", @@ -50,5 +53,6 @@ "teamdoge": "\\Account\\MiningPool\\TeamDoge", "triplemining": "\\Account\\MiningPool\\TripleMining", "westhash": "\\Account\\MiningPool\\WestHash", - "ypool": "\\Account\\MiningPool\\YPool" + "ypool": "\\Account\\MiningPool\\YPool", + "zpool": "\\Account\\MiningPool\\ZPool" } diff --git a/src/CleverMining.php b/src/CleverMining.php new file mode 100644 index 0000000..3ed35bc --- /dev/null +++ b/src/CleverMining.php @@ -0,0 +1,77 @@ + array( + 'title' => "API key", + 'regexp' => "#^.{20}$#" + ), + ); + } + + public function fetchSupportedCurrencies(CurrencyFactory $factory, Logger $logger) { + // there is no API call to list supported currencies + return array('btc'); + } + + public function fetchSupportedHashrateCurrencies(CurrencyFactory $factory, Logger $logger) { + return array(); + } + + public function fetchBalances($account, CurrencyFactory $factory, Logger $logger) { + + $result = array(); + + foreach ($this->fetchSupportedCurrencies($factory, $logger) as $cur) { + $abbr = strtoupper($cur); + $instance = $factory->loadCurrency($cur); + if ($instance != null) { + $abbr = $instance->getAbbr(); + } + + $url = "https://www.clevermining.com/api/v1/users/" . urlencode($account['api_key']); + $json = $this->fetchJSON($url, $logger); + + switch ($cur) { + case "btc": + $result[$cur] = array( + 'confirmed' => $json['general']['balance'], + ); + } + } + + return $result; + + } + +} diff --git a/src/LTCRabbit.php b/src/LTCRabbit.php new file mode 100644 index 0000000..f45e606 --- /dev/null +++ b/src/LTCRabbit.php @@ -0,0 +1,77 @@ + array( + 'title' => "API key", + 'regexp' => "#^.{20}$#" + ), + ); + } + + public function fetchSupportedCurrencies(CurrencyFactory $factory, Logger $logger) { + // there is no API call to list supported currencies + return array('ltc'); + } + + public function fetchSupportedHashrateCurrencies(CurrencyFactory $factory, Logger $logger) { + return array(); + } + + public function fetchBalances($account, CurrencyFactory $factory, Logger $logger) { + + $result = array(); + + foreach ($this->fetchSupportedCurrencies($factory, $logger) as $cur) { + $abbr = strtoupper($cur); + $instance = $factory->loadCurrency($cur); + if ($instance != null) { + $abbr = $instance->getAbbr(); + } + + $url = "https://www.ltcrabbit.com/index.php?page=api&action=getappdata&appname=openclerk&appversion=1&api_key=" . urlencode($account['api_key']); + $json = $this->fetchJSON($url, $logger); + + switch ($cur) { + case "ltc": + $result[$cur] = array( + 'confirmed' => $json['getappdata']['user']['balance'], + ); + } + } + + return $result; + + } + +} diff --git a/src/MiningPoolHub.php b/src/MiningPoolHub.php new file mode 100644 index 0000000..3988135 --- /dev/null +++ b/src/MiningPoolHub.php @@ -0,0 +1,82 @@ + array( + 'title' => "API ID", + 'regexp' => "#^[0-9]+$#", + ), + 'api_key' => array( + 'title' => "API key", + 'regexp' => "#^.{20}$#" + ), + ); + } + + public function fetchSupportedCurrencies(CurrencyFactory $factory, Logger $logger) { + // there is no API call to list supported currencies + return array('btc'); // all converted to BTC + } + + public function fetchSupportedHashrateCurrencies(CurrencyFactory $factory, Logger $logger) { + return array(); + } + + public function fetchBalances($account, CurrencyFactory $factory, Logger $logger) { + + $confirmed = 0; + $pending = 0; + $unconfirmed = 0; + + foreach (json_decode(@file_get_contents("http://miningpoolhub.com/index.php?page=api&action=getminingandprofitsstatistics"))->{'return'} as $coin) { + $url = "http://" . $coin->{'coin_name'} . ".miningpoolhub.com/index.php?page=api&action=getdashboarddata&api_key=" . urlencode($account['api_key']) . "&id=" . urlencode($account['api_id']); + $json = @file_get_contents($url); + $data = json_decode($json)->{'getdashboarddata'}->{'data'}; + $confirmed += ((float)$data->{'balance'}->{'confirmed'} + (float)$data->{'balance_for_auto_exchange'}->{'confirmed'}) * (float)$coin->{'highest_buy_price'}; + $pending += (float)$data->{'balance_on_exchange'} * (float)$coin->{'highest_buy_price'}; + $unconfirmed += ((float)$data->{'balance'}->{'unconfirmed'} + (float)$data->{'balance_for_auto_exchange'}->{'unconfirmed'}) * (float)$coin->{'highest_buy_price'}; + } + + return array( + 'btc' => array( + 'confirmed' => $confirmed, + 'pending' => $pending, + 'unconfirmed' => $unconfirmed, + ), + ); + + $result = array(); + + } + +} diff --git a/src/NiceHash.php b/src/NiceHash.php index 49dfff5..f0b7450 100644 --- a/src/NiceHash.php +++ b/src/NiceHash.php @@ -60,10 +60,20 @@ public function fetchBalances($account, CurrencyFactory $factory, Logger $logger throw new AccountFetchException($json['result']['error']); } + $unconfirmed = 0; + foreach (json_decode(@file_get_contents("https://www.nicehash.com/api?method=buy.info"))->{'result'}->{'algorithms'} as $algo) { + for ($location = 0; $location <= 1; $location++) { + foreach (json_decode(@file_get_contents("https://www.nicehash.com/api?method=orders.get&my&id=" . urlencode($account['api_id']) . "&key=" . urlencode($account['api_key']) . "&location=" . $location . "&algo=" . $algo->{'algo'}))->{'result'}->{'orders'} as $order) { + $unconfirmed += $order->{'btc_avail'}; + } + } + } + return array( 'btc' => array( 'confirmed' => $json['result']['balance_confirmed'], 'pending' => $json['result']['balance_pending'], + 'unconfirmed' => $unconfirmed, ), ); diff --git a/src/ZPool.php b/src/ZPool.php new file mode 100644 index 0000000..18bb1b7 --- /dev/null +++ b/src/ZPool.php @@ -0,0 +1,75 @@ + array( + 'title' => "API key", + 'regexp' => "#^.{20}$#" + ), + ); + } + + public function fetchSupportedCurrencies(CurrencyFactory $factory, Logger $logger) { + // there is no API call to list supported currencies + return array('btc'); + } + + public function fetchSupportedHashrateCurrencies(CurrencyFactory $factory, Logger $logger) { + return array(); + } + + public function fetchBalances($account, CurrencyFactory $factory, Logger $logger) { + + $result = array(); + + foreach ($this->fetchSupportedCurrencies($factory, $logger) as $cur) { + $abbr = strtoupper($cur); + $instance = $factory->loadCurrency($cur); + if ($instance != null) { + $abbr = $instance->getAbbr(); + } + + $url = "http://www.zpool.ca/api/wallet?address=" . urlencode($account['api_key']); + $json = $this->fetchJSON($url, $logger); + + $result[$cur] = array( + 'confirmed' => $json['balance'], + 'unconfirmed' => $json['unsold'], + ); + } + + return $result; + + } + +} diff --git a/test/CleverMiningTest.php b/test/CleverMiningTest.php new file mode 100644 index 0000000..982459e --- /dev/null +++ b/test/CleverMiningTest.php @@ -0,0 +1,57 @@ + '1Q24z7gHPDbedkaWDTFqhMF8g7iHMehsCb', + ); + } + + /** + * Get some field values for a missing account, + * but one that is still valid according to the fields. + * @return array of fields + */ + function getMissingAccount() { + return array( + 'api_key' => '2Q24z7gHPDbedkaWDTFqhMF8g7iHMehsCb', + ); + } + + /** + * Get some invalid field values. + * @return array of fields + */ + function getInvalidAccount() { + return array( + 'api_key' => 'hello', + ); + } + + function doTestValidValues($balances) { + $this->assertEquals(0, $balances['btc']['confirmed']); + } + +} diff --git a/test/LTCRabbitTest.php b/test/LTCRabbitTest.php new file mode 100644 index 0000000..1e44749 --- /dev/null +++ b/test/LTCRabbitTest.php @@ -0,0 +1,57 @@ + '7ca421ef0b4c700543a0ca6b020e415614ec5fa768483859d0eb56af015a06f2', + ); + } + + /** + * Get some field values for a missing account, + * but one that is still valid according to the fields. + * @return array of fields + */ + function getMissingAccount() { + return array( + 'api_key' => '8ca421ef0b4c700543a0ca6b020e415614ec5fa768483859d0eb56af015a06f2', + ); + } + + /** + * Get some invalid field values. + * @return array of fields + */ + function getInvalidAccount() { + return array( + 'api_key' => 'hello', + ); + } + + function doTestValidValues($balances) { + $this->assertEquals(0, $balances['ltc']['confirmed']); + } + +} diff --git a/test/MiningPoolHubTest.php b/test/MiningPoolHubTest.php new file mode 100644 index 0000000..3ba865e --- /dev/null +++ b/test/MiningPoolHubTest.php @@ -0,0 +1,59 @@ + '3f92996d71ca91be5bf5cee9f332fa6b06d428d038b5be41c6ece066eaaf83ff', + ); + } + + /** + * Get some field values for a missing account, + * but one that is still valid according to the fields. + * @return array of fields + */ + function getMissingAccount() { + return array( + 'api_key' => '4f92996d71ca91be5bf5cee9f332fa6b06d428d038b5be41c6ece066eaaf83ff', + ); + } + + /** + * Get some invalid field values. + * @return array of fields + */ + function getInvalidAccount() { + return array( + 'api_key' => 'hello', + ); + } + + function doTestValidValues($balances) { + $this->assertEquals(0, $balances['btc']['confirmed']); + $this->assertEquals(0, $balances['btc']['pending']); + $this->assertEquals(0, $balances['btc']['unconfirmed']); + } + +} diff --git a/test/ZPoolTest.php b/test/ZPoolTest.php new file mode 100644 index 0000000..5c722c5 --- /dev/null +++ b/test/ZPoolTest.php @@ -0,0 +1,58 @@ + '1Q24z7gHPDbedkaWDTFqhMF8g7iHMehsCb', + ); + } + + /** + * Get some field values for a missing account, + * but one that is still valid according to the fields. + * @return array of fields + */ + function getMissingAccount() { + return array( + 'api_key' => '2Q24z7gHPDbedkaWDTFqhMF8g7iHMehsCb', + ); + } + + /** + * Get some invalid field values. + * @return array of fields + */ + function getInvalidAccount() { + return array( + 'api_key' => 'hello', + ); + } + + function doTestValidValues($balances) { + $this->assertEquals(0, $balances['btc']['confirmed']); + $this->assertEquals(0, $balances['btc']['unconfirmed']); + } + +}