Ejemplo n.º 1
0
 public function nodes()
 {
     $subver = $this->bootstrap->httpRequest->request->get('subversion');
     //$subver = urldecode($subver);
     $subver = $_GET['subversion'];
     $paycoinDb = new PaycoinDb();
     $nodes = $paycoinDb->getNodes($subver);
     $nodes = array_column($nodes, 'addr');
     foreach ($nodes as &$node) {
         $node = str_replace(':8998', '', $node);
     }
     $response['nodes'] = $nodes;
     $this->outputJsonResponse($response);
 }
Ejemplo n.º 2
0
 public function getChartData()
 {
     header("Content-Type: text/javascript");
     $paycoinDb = new PaycoinDb();
     $chart = $this->bootstrap->route['chart'];
     if (!$chart) {
         $chart = 'outstanding';
     }
     switch ($chart) {
         case 'transactions-per-block':
             $dataPoints = $paycoinDb->getTransactionsPerBlockDataPoints(100000);
             break;
         case 'difficulty':
             $dataPoints = $paycoinDb->getDifficultyDataPoints(100000);
             break;
         default:
             $dataPoints = $paycoinDb->getOutstandingDataPoints(100000000);
     }
     echo $this->bootstrap->httpRequest->get('callback') . "( [ \n";
     echo join($dataPoints, ",");
     echo "\n ]);\n";
 }
Ejemplo n.º 3
0
 public function buildRichList()
 {
     $paycoinDb = new PaycoinDb();
     echo "Building rich list" . PHP_EOL;
     $paycoinDb->buildRichList();
 }
Ejemplo n.º 4
0
 public function tagging()
 {
     $this->addJs('/js/tagging.js');
     $message = 'Paycoin Blockchain';
     $this->setData('messageToSign', $message);
     $this->setData('pageTitle', 'Tag a Paycoin address');
     $this->setData('success', false);
     if ($this->bootstrap->httpRequest->getRealMethod() == 'POST') {
         $address = $this->bootstrap->httpRequest->request->getAlnum('address');
         $tag = $this->bootstrap->httpRequest->get('tag');
         $signature = $this->bootstrap->httpRequest->request->get('signature');
         $url = $this->bootstrap->httpRequest->request->get('url');
         $message = 'Paycoin Blockchain';
         $this->setData('messageToSign', $message);
         $this->setData('address', $address);
         $this->setData('tag', $tag);
         $this->setData('url', $url);
         $paycoinRpc = new PaycoinRPC();
         $error = false;
         if (!empty($url)) {
             $pu = parse_url($url);
             if (empty($pu['scheme']) || empty($pu['host'])) {
                 $error = 'Invalid URL';
             }
         }
         if (empty($address)) {
             $error = 'Invalid Address';
         }
         if (empty($signature)) {
             $error = 'Invalid Signature';
         }
         if (empty($tag)) {
             $error = 'Invalid Tag';
         }
         if (empty($error)) {
             $isVerified = $paycoinRpc->verifySignedMessage($address, $signature, $message);
             if ($isVerified === true) {
                 $this->setData('success', true);
                 $paycoinDb = new PaycoinDb();
                 $paycoinDb->addTagToAddress($address, $tag, $url, 1);
             } elseif ($isVerified === false) {
                 $this->setData('error', 'Failed to Verify Message');
             } elseif ($isVerified !== true) {
                 $this->setData('error', $isVerified);
             } else {
                 $this->setData('error', 'Unknown error');
             }
         } else {
             $this->setData('error', $error);
         }
     }
     $this->setData('pageName', 'Address Tagging');
     $this->render('header');
     $this->render('tagging');
     $this->render('footer');
 }