Example #1
0
 public function tagAddress()
 {
     $address = $this->bootstrap->httpRequest->request->getAlnum('address');
     $tag = $this->bootstrap->httpRequest->request->getAlnum('tag');
     if (empty($address)) {
         $response = array('success' => false, 'error' => 'Error no address in request.');
     } elseif (empty($tag)) {
         $response = array('success' => false, 'error' => 'You need to enter a tag for the address.');
     } else {
         $paycoinDb = new PaycoinDb();
         try {
             $paycoinDb->addTagToAddress($address, $tag);
         } catch (\Exception $e) {
             if (stristr($e->getMessage(), 'Duplicate') !== false) {
                 $response = array('success' => false, 'error' => 'This address is already tagged. Tagging disabled. <a href="#" class="a-normal">Claim Address</a> to add a Tag');
                 $this->disputeAddressTag($address);
             } else {
                 $response = array('success' => false, 'error' => $e->getMessage());
             }
         }
         if (empty($response)) {
             $response = array('address' => $address, 'tag' => $tag, 'success' => true, 'error' => false);
         }
     }
     $this->outputJsonResponse($response);
 }
Example #2
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');
 }