예제 #1
0
 /**
  * add a wallet address to a user
  * 
  * @access public
  * @param int $user_id
  * @param string $label
  */
 public function addAddress($user_id, $label = '')
 {
     $params = JComponentHelper::getParams('com_dogecointipping');
     $apiKey = $params->get('api_key');
     $pin = $params->get('secret_pin');
     require_once JPATH_ADMINISTRATOR . '/components/com_dogecointipping/libs/block_io.php';
     $block_io = new BlockIO($apiKey, $pin, 2);
     try {
         if (empty($label)) {
             $getNewAddressInfo = $block_io->get_new_address();
         } else {
             $getNewAddressInfo = $block_io->get_new_address(array('label' => $label));
         }
         $newAddress = $getNewAddressInfo->data->address;
         $newLabel = $getNewAddressInfo->data->label;
         $db = JFactory::getDBO();
         $record = new stdClass();
         $record->user_id = $user_id;
         $date = JFactory::getDate();
         $record->created = $date->toSql();
         $record->label = $newLabel;
         $record->address = $newAddress;
         $db->insertObject('#__dogecointipping_address', $record);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
 }
예제 #2
0
 public static function getBalance($address)
 {
     $params = JComponentHelper::getParams('com_dogecointipping');
     $apiKey = $params->get('api_key');
     $pin = $params->get('secret_pin');
     require_once JPATH_ADMINISTRATOR . '/components/com_dogecointipping/libs/block_io.php';
     $block_io = new BlockIO($apiKey, $pin, 2);
     $getBalanceInfo = $block_io->get_balance($address);
     return $getBalanceInfo->data->available_balance;
 }
예제 #3
0
 public function addAddress($label)
 {
     $params = JComponentHelper::getParams('com_dogecointipping');
     $apiKey = $params->get('api_key');
     $pin = $params->get('secret_pin');
     require_once JPATH_ADMINISTRATOR . '/components/com_dogecointipping/libs/block_io.php';
     $block_io = new BlockIO($apiKey, $pin, 2);
     try {
         if (empty($label)) {
             $getNewAddressInfo = $block_io->get_new_address();
         } else {
             $getNewAddressInfo = $block_io->get_new_address(array('label' => $label));
         }
         $newAddress = $getNewAddressInfo->data->address;
         $newLabel = $getNewAddressInfo->data->label;
         return array('label' => $newLabel, 'address' => $newAddress);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
 }