From d7713790ccd9b84e589b4830a1b249f9573c8491 Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Thu, 12 Oct 2017 00:42:17 -0400 Subject: [PATCH 1/5] add code to get total and circulating supply Doing this blind right now, will need to run explorer locally to test. Or maybe yolo, we'll see. --- src/Controller/MainController.php | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 5c773fd..630571a 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -493,7 +493,7 @@ class MainController extends AppController { $this->loadModel('Addresses'); // exclude bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf (genesis block) - $richList = $this->Addresses->find()->where(['Address <>' => 'bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf'])->order(['Balance' => 'DESC'])->limit(500)->toArray(); + $richList = $this->Addresses->find()->where(['Address <>' => 'bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf'])->order(['ff' => 'DESC'])->limit(500)->toArray(); $priceRate = 0; $priceInfo = json_decode($this->redis->get(self::lbcPriceKey)); @@ -680,7 +680,18 @@ class MainController extends AppController { return 'N/A'; } } - + private function _gettxoutsetinfo() { + $req = ['method' => 'gettxoutsetinfo', 'params' => []]; + try { + $res = json_decode(self::curl_json_post(self::rpcurl, json_encode($req))); + if (!isset($res->result)) { + return 0; + } + return $res->result; + } catch (\Exception $e) { + return 'N/A'; + } + } public function apistatus() { $this->autoRender = false; $this->loadModel('Blocks'); @@ -850,6 +861,26 @@ class MainController extends AppController { return $this->_jsonResponse(['success' => true, 'utxo' => $utxo]); } + public function apiutxosupply() { + $this->autoRender = false; + $circulating = 0; + $reservedcommunity = 0; + $reservedoperational = 0; + $reservedinstitutional = 0; + $reservedtotal = 0; + $circulating = 0; + + $txoutsetinfo = $this->_gettxoutsetinfo(); + $reservedcommunity = $this->Addresses->find()->select(['Balance'])->where(['Address =' => 'rFLUohPG4tP3gZHYoyhvADCtrDMiaYb7Qd'])->first(); + $reservedoperational = $this->Addresses->find()->select(['Balance'])->where(['Address =' => 'r9PGXsejVJb9ZfMf3QVdDEJCzxkd9JLxzL'])->first(); + $reservedinstitutional = $this->Addresses->find()->select(['Balance'])->where(['Address =' => 'r9srwX7DEN7Mex3a8oR1mKSqQmLBizoJvi'])->first(); + $reservedtotal = $reservedcommunity->Balance + $reservedoperational->Balance + $reservedinstitutional->Balance; + $circulating = $txoutsetinfo->total_amount - $reservedtotal; + + return $this->_jsonResponse(['success' => true, ['utxosupply' => ['total' => $txoutsetinfo->total_amount, 'circulating' => $circulating]]]); + + } + private static function curl_json_post($url, $data, $headers = []) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); @@ -874,4 +905,4 @@ class MainController extends AppController { } } -?> \ No newline at end of file +?> -- 2.45.2 From 174655d74dde2478915b08b6a8190b881bfebacf Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Thu, 12 Oct 2017 00:46:22 -0400 Subject: [PATCH 2/5] fix typo --- src/Controller/MainController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 630571a..15ef19f 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -493,7 +493,7 @@ class MainController extends AppController { $this->loadModel('Addresses'); // exclude bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf (genesis block) - $richList = $this->Addresses->find()->where(['Address <>' => 'bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf'])->order(['ff' => 'DESC'])->limit(500)->toArray(); + $richList = $this->Addresses->find()->where(['Address <>' => 'bHW58d37s1hBjj3wPBkn5zpCX3F8ZW3uWf'])->order(['Balance' => 'DESC'])->limit(500)->toArray(); $priceRate = 0; $priceInfo = json_decode($this->redis->get(self::lbcPriceKey)); -- 2.45.2 From d7ef06bc1a265fb1477cfe9ecbe47812675df628 Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Thu, 12 Oct 2017 00:53:33 -0400 Subject: [PATCH 3/5] add supply route add supply route to apiutxosupply --- config/routes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.php b/config/routes.php index 270679d..abb4474 100644 --- a/config/routes.php +++ b/config/routes.php @@ -65,6 +65,7 @@ Router::scope('/', function (RouteBuilder $routes) { $routes->connect('/api/v1/realtime/tx', ['controller' => 'Main', 'action' => 'apirealtimetx']); $routes->connect('/api/v1/recentblocks', ['controller' => 'Main', 'action' => 'apirecentblocks']); $routes->connect('/api/v1/status', ['controller' => 'Main', 'action' => 'apistatus']); + $routes->connect('/api/v1/supply', ['controller' => 'Main', 'action' => 'apiutxosupply']); //$routes->connect('/api/v1/recenttxs', ['controller' => 'Main', 'action' => 'apirecenttxs']); $routes->connect('/api/v1/claims/browse', ['controller' => 'Claims', 'action' => 'apibrowse']); -- 2.45.2 From 5b1abb0c9d48bdd40272f405d813f7994bf3a2fa Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Fri, 13 Oct 2017 01:28:35 -0400 Subject: [PATCH 4/5] add another address with LBRY funds fix $this->loadModel('Addresses') --- src/Controller/MainController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 15ef19f..e04f6b3 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -863,6 +863,8 @@ class MainController extends AppController { public function apiutxosupply() { $this->autoRender = false; + $this->loadModel('Addresses') + $circulating = 0; $reservedcommunity = 0; $reservedoperational = 0; @@ -874,8 +876,12 @@ class MainController extends AppController { $reservedcommunity = $this->Addresses->find()->select(['Balance'])->where(['Address =' => 'rFLUohPG4tP3gZHYoyhvADCtrDMiaYb7Qd'])->first(); $reservedoperational = $this->Addresses->find()->select(['Balance'])->where(['Address =' => 'r9PGXsejVJb9ZfMf3QVdDEJCzxkd9JLxzL'])->first(); $reservedinstitutional = $this->Addresses->find()->select(['Balance'])->where(['Address =' => 'r9srwX7DEN7Mex3a8oR1mKSqQmLBizoJvi'])->first(); - $reservedtotal = $reservedcommunity->Balance + $reservedoperational->Balance + $reservedinstitutional->Balance; - $circulating = $txoutsetinfo->total_amount - $reservedtotal; + //aux is the address where some of the LBRY operational fund are, but not sold on market. + $reservedaux = $this->Addresses->find()->select(['Balance'])->where(['Address =' => 'bRo4FEeqqxY7nWFANsZsuKEWByEgkvz8Qt'])->first(); + $reservedtotal = $reservedcommunity->Balance + $reservedoperational->Balance + $reservedinstitutional->Balance + $reservedaux->Balance; + + + $circulating = $txoutsetinfo->total_amount - $reservedtotal; return $this->_jsonResponse(['success' => true, ['utxosupply' => ['total' => $txoutsetinfo->total_amount, 'circulating' => $circulating]]]); -- 2.45.2 From b6f9424569f1182ab5fec8f685cd9b9a68d35ba6 Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Fri, 13 Oct 2017 01:31:13 -0400 Subject: [PATCH 5/5] semicolon --- src/Controller/MainController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index e04f6b3..a68e08a 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -863,7 +863,7 @@ class MainController extends AppController { public function apiutxosupply() { $this->autoRender = false; - $this->loadModel('Addresses') + $this->loadModel('Addresses'); $circulating = 0; $reservedcommunity = 0; -- 2.45.2